lua-users home
lua-l archive

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


On Fri, Jun 27, 2008 at 4:17 PM, Tony Finch <dot@dotat.at> wrote:
> On Fri, 27 Jun 2008, Javier Guerra wrote:
>>
>> differences:
>> - real lexical scoping
>> - OOP is just a little syntax sugar, there's no predefined inheritance style.
>
> Those are actually both similarities, though JS has a more conventional
> OOpy programming style, partly because of the standard libraries.

??

JS doens't have lexical scoping, just two-level scopes. may i had the
terminology wrong and it could be called 2-level lexical scope, while
Lua is full block based lexical scoping.

and OOP... in JS there are lots of arbitrary 'features' built into the
language, not only on the libraries, and not simply as syntax sugar.

the 'new' keyword makes 'constructor' behaviour for functions, the
'prototype' magic reference, making functions and other things into
objects, magically transforming a function into a closure that grabs
the 'object' when you reference it out of the object, the inconsistent
meanings of 'this'... all these are in the language, not everybody
likes them, but you can't fight them if you happen to prefer a more
'pure' prototype based inheritance, or even a non-inheritance OOP
design (like me ;-)

in Lua the only deference to OOP is the obj:method(...) =>
obj.method(obj,...) sugar.  everything else is user-definable.

-- 
Javier