lua-users home
lua-l archive

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

On Tue, Nov 27, 2018 at 1:31 AM Coda Highland wrote:
>>>> Lua has little to no support for composition-based OOP
>>> Can you give an example of what you would want here?
>> The classic Cratera[1] `foo:[component].method()` (note the colon) syntax.
> What OOP languages do support this "composition-based OOP" ?

Lots of them. C++, Java, C#, Python...

Python's the only one I know of off the top of my head
that can make it look that clean.

How does Python support "composition OOP"?
Do you mean the ability to define __getattr__?
It doesn't look like a "support"; a user has to do all the work manually.
It' very similar to Lua's ability to define __index.

I like the suggestion to make "a:b.c()" a valid Lua syntax.

But the next question from Sony L. would be the following:
How to save intermediate value in this code
to rewrite it in optimized way
local x = a:b