by jacktoole1 · 14y ago · 0 comments
Any thoughts of letting the 'do' keyword support coffeescript-style 'do' semantics as well? Invoking a multi-line anonymous function is currently a bit impractical, and allowing do to invoke a single function parameter would make that a lot nicer, and allow for capturing variable's in a closure more easily. Example from the coffeescript docs:
for filename in list
do (filename) ->
fs.readFile filename, (err, contents) ->
compile filename, contents.toString()
[1] http://www.codingspellbook.com/http://moonscript.org/compiler/#14
Here I create 10 functions closed on the loop value. Then I loop over them and call them all. In JavaScript this would print 10 10 times, but in Lua we get the 1 through 10.
Keep up the good work!