lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>-- z = function() end
>
>(setfenv(function() end, built_ins))()    -- <----- line 78
>
>runtime error loading module 'value' from file 
'/modules/value.lua':
>	modules/value.lua:78: ambiguous syntax (function call 
x new statement) near '('
>

This is ambiguous because there are two ways to interpret 
this. Take the following example.

z = (function(...) print(...); return "Bar"; end)
("Foo"):sub(1,1)

There are two interpretations to this:

1) Store the newly created function, which calls print and 
returns "Bar" into the variable z, then call string.sub on 
"Foo" and discard the result

2) Create a temporary function which prints out the parameters 
and returns "Bar", pass in "Foo" to that function, then 
execute string.sub on "Bar" (returning "B" to store into 
variable z)

Use a semicolon to disambiguate this problem.

-- Matthew P. Del Buono
Embry-Riddle Aeronautical University
EcoEagles, Controls Team Leader
(703) 395-5425