lua-users home
lua-l archive

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


steve donovan wrote:
[...]
> But how to tell when something's being called as a method? Lua
> requires us to know this upfront so we can say ':' and ensure that the
> self argument is passed implicitly.

>From my limited knowledge of Javascript, you can tell from the syntax.
The three types of calls are:

Func()
object.Func()
new Func()

...which are very roughly equivalent to the Lua:

Func(this)
Func(object)
o={}; Func(o); return o

(this in Javascript is passed implicitly and is not a function argument.)

But life is made more complex by the way that Javascript variables don't
really work the same way that Lua ones do --- *all* 'var' variables end
up in the equivalent of the local environment, I believe, and I'm not
entirely sure of when new environments show up.

(I'd like to find out about this stuff at some point, but the Javascript
reference documentation is largely incomprehensible. Anyone know where I
can find a clear description of how it all works?)

-- 
David Given
dg@cowlark.com