- changed status to wontfix
functions need to be declared before they can be used
Issue #12
wontfix
function test()
say "hello";
end
test();
works
test();
function test()
say "hello";
end
Error: Attempted to call a nil value.
Is this intended ? Because it makes things a lot more complicated.
Comments (5)
-
-
Out of curiosity, in what situations will this make it more complicated? I worked with Lua for a long time and never encountered a situation where this would complicate anything.
-
reporter Well I think I just thought confused something. Thought it would be like in C, that I need to reorder them before I can use them. But that's nonsense, so it's fine. :D
Though I'd like to know how it will work with multiple script files. One needs to run over each script once to make the functions accessible ?
-
Yeah, something like that. Currently still fleshing out the details. Gonna share more at the forums!
-
- removed version
Removing version: 2.1 (automated comment)
- Log in to comment
This is indeed intended and is how most imperative scripting languages work.
Function definitions are essentially a statement where an anonymous function is assigned to a value. If you try to access a value before it is assigned, the logical result is nil.
//edit: To clarify, asking to make this possible is like asking for
to print "Hello World!" instead of "nil".