Re:A Case Against Using CoffeeScript
by extension on Wednesday December 14, 2011 @05:11AM
(#3351304)
To elaborate, Lua has special syntax for defining and calling methods vs unbound functions. In Lua,
function woot:donk() ... end
woot:donk()
is equivalent to
woot.donk = function(self) ... end
woot.donk(woot)
and when you define a function normally e.g.
function() ... end
there is no self parameter, thus the one from the parent scope is captured. The flaw with JS, really, is that it forces every function to be a method, and doesn't let you express whether you are defining one or the other.
(think I got this right, my Lua is a bit rusty)