Questions tagged [lua]

Lua is a lightweight multi-paradigm programming language designed as a scripting language with extensible semantics as a primary goal.

Filter by
Sorted by
Tagged with
1
vote
0answers
142 views

Can I refer to a closure in a different thread?

As far as I know Lua uses closures to encapsulate local variables, well I've got a function call in a worker thread which passes reference to a callback function, and the async call will be handled by ...
4
votes
2answers
241 views

Criteria for a language (Terra as a tricky example) to be usable for operating system development, and how to meet missing criteria

For example, a language that I was looking at recently- Terra. You can address the question in the context of any language, I'm just most comfortable with Lua so I'm starting from there. The Terra ...
4
votes
2answers
3k views

Should I use Lua for writing config files?

I heard that Lua is great for configuration files, so long as you are secure about it. Lua has been used as config files by programs such as awesome and (recently) conky. However, I also heard that ...
1
vote
1answer
106 views

Implicit/Explicit Assertions

During code review, a minor suggestion was presented that some implicit behavior be made explicit. The reviewer had skimmed over the code in question, became confused after mistakenly interpreting the ...
3
votes
1answer
157 views

Is it better to accept a dictionary/table or arguments in a function?

In Lua, I can create an object like so: local foo = Foo.new({10, 10}, 3, right) or like so: local foo = Foo.new({ pos = {10, 10}, len = 3, direction = "right" }) The former is more ...
0
votes
1answer
145 views

Assigning variables as lines of code

I know in lua you can do something along the lines of print=System.out.println print("Hello") But is there something similar in java?
2
votes
2answers
187 views

Would using coroutines improve my code?

I am currently developing my own programming language (written in Lua). The text analyzer is composed of two functions: lexer and parser. lexer takes as input a string, cycles over each character of ...
4
votes
2answers
311 views

Simplifying Some Probabilistic If-Then Spaghetti Code

I've got a fairly substantial code base that I'm trying to simplify. One section in particular deals with probabilistically creating objects. It currently uses hundreds of random number generator ...
3
votes
2answers
739 views

What is the point of designing Lua C APIs?

I am a newbie of Lua. After studying some Lua C APIs examples, I am a little confused. I can see the Lua C API is used for processing Lua scripts: ...... lua_State *L = luaL_newstate(); ...
1
vote
1answer
118 views

is there a cleaner / simpler way to code this? [duplicate]

I have a web app that uses ajax to filter db results. So if you have a list of 1000 widgets, that have IDs ranging from 1-1000, by typing numbers into the ID field, you can narrow your search. ...
2
votes
2answers
5k views

proper way to design REST interface with nginx lua.

I'm a noob at nginx and lua. But I'm trying to design a REST interface. The plan is to create a location entry that will match URIs like this: curl -i -X GET 'http://localhost/widgets/widget?name=...
3
votes
1answer
257 views

What algorithm can be used for a more complex version of the bin packing problem?

I'm currently developing a plugin for World of Warcraft in LUA to help optimize a recently introduced part of the game, namely Garrison missions. A Warcraft Garrison (basically a player fortress) has ...
15
votes
7answers
3k views

Function only returns unchanged parameter, useless?

I just found this function in the project I'm working at: -- Just returns the text unchanged. -- Note: <text> may be nil, function must return nil in that case! function Widget:wtr(text) ...
7
votes
1answer
1k views

Creating New Scripts Dynamically in Lua

Right now this is just a crazy idea that I had, but I was able to implement the code and get it working properly. I am not entirely sure of what the use cases would be just yet. What this code does ...
0
votes
1answer
98 views

debugging web applications using debug parameter

A suggestion has been made by a team member to leave all debug code intact in our web pages... and then to create a variable that can be turned on / off to enable / disable debugging. This is a ...
11
votes
2answers
11k views

How Lua handles both integer and float numbers?

As far as I remember myself programming I was taught not to compare floating point numbers for equality. Now, while reading Programming in Lua about Lua number type, I found following: The number ...
3
votes
1answer
678 views

LuaJit FFI and hiding C implementation details

I would like to extend an application using LuaJit FFI. Having seen http://luajit.org/ext_ffi_tutorial.html this is surprisingly easy when comparing this to the Lua C API. So far so good. However I do ...
16
votes
10answers
26k views

Why do we need “callback functions”?

I am reading the book programming in Lua. It said that Closures provide a valuable tool in many contexts. As we have seen, they are useful as arguments to higher-order functions such as sort. ...
5
votes
2answers
2k views

Alternative Scripting Language to Lua? [closed]

I would like to add scripting support to an applications and with plenty scripting languages available I am a bit overwhelmed. At first I thought about Python but I guess Python is a little too big ...
3
votes
1answer
832 views

script engine with no global environment (java)

I am curious about how global variables are handled by script engines. I am looking for a script engine that does not preserve the state of global variables upon invocation. Are there such engines out ...
11
votes
2answers
667 views

Should extension scripts be run in a sandbox?

In particular, this is about game extensions written in lua (luajit-2.0). I was contemplating whether I should restrict what these scripts can do, and arrived at the conclusion that I probably shouldn'...
5
votes
2answers
894 views

Lua and multi-paradigm programming: scope and capabilities

Despite having started learning programming with Pascal and C, after the jump to OO (C++, Java) I lost sense of the structured programming paradigm. I have started learning Lua and I have researched ...
2
votes
1answer
721 views

Lua & Javascript documentation generation

I am in the beginning phase of create a mobile MMO with my team. The server software will be written in JavaScript using NodeJS, and the client software in Lua using Corona. We need a tool to auto-...
9
votes
3answers
4k views

What does (Lua) game scripting mean?

I've read that Lua is often used for embedded scripting and in particular game for scripting. I find it hard to picture how it is used exactly. Can you describe why and for which features and for ...
1
vote
4answers
274 views

best way to do the compile and check cycle

I am trying to learn lua and am experimenting on my linux machine. I am not a programmer, so I am looking for your help to give me some suggestions. What I want to accomplish is making my compile-...
1
vote
4answers
640 views

What is the equivalent word for “compile” in an interpreted language? [closed]

(I was encouraged to ask this question here.) In C, we say: GCC compiles foo.c. For interpreters (such as Lua), what is the equivalent verb? The Lua interpreter ____________ foo.lua. When I ...
3
votes
5answers
2k views

Functional language with C-like syntax [closed]

I've been looking for functional language with C-like syntax and static typing. So far my choice would be Nemerle. Is there anything else/better? EDIT: second choice would be Lua or Go. Any pros ...
45
votes
3answers
87k views

Why Python and not Lua? [closed]

Why has Python been backed by google and become so rapidly popular and Lua has not? Do you know why Lua has stayed in background?