Wednesday, January 16, 2008

Lua local functions

In the following snippet, the "end)(2,3)" need to be on the same line for the code to work. Not sure why, maybe Lua interprets the (2,3) on a separate line as a possible function call. The error call says "ambiguous syntax".

> function(A,B)
>> print(A+B)
>> end)(2,3)

The above works, the below doesn't.

>function(A,B)
>> print(A+B)
>> end)
>> (2,3)

According to Beginning Lua Programming "... Lua doesn't allow a newline before the open parenthesis of a function call. [page 107]"

No comments: