[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua Needs
- From: Coda Highland <chighland@...>
- Date: Mon, 26 Nov 2018 16:31:06 -0600
On Mon, Nov 26, 2018 at 6:58 AM Egor Skriptunoff
<egor.skriptunoff@gmail.com> wrote:
>
> On Mon, Nov 26, 2018 at 1:30 PM Soni "They/Them" L. 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... Javascript doesn't usually do
it that way but its ability to do dynamic function rebinding would
make it POSSIBLE to do it there (I just don't know anyone that
bothers).
The syntax isn't usually that pretty, though. Python's the only one I
know of off the top of my head that can make it look that clean. In C#
it looks more like foo.GetComponent<Component>().Method().
Lua actually can pull it off with foo[component]:method() if you have
foo's __index metamethod return a binding object, but that comes at
the cost of a fair amount of overhead relative to the syntax patch.
/s/ Adam