[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua and composition
- From: Dirk Laurie <dirk.laurie@...>
- Date: Wed, 1 Mar 2017 17:06:43 +0200
2017-03-01 15:11 GMT+02:00 Soni L. <fakedme@gmail.com>:
>
Apropos [2] http://lua-users.org/lists/lua-l/2016-04/msg00184.html
There is a typo in the original, so just read here.
> I mean, do you want arguments about the order the arguments
> should show up in? Because there are just as many arguments for
>
> x:y:z() -> x.y.z(x,x.y)
>
> as there are for:
>
> x:y:z() -> x.y.z(x.y,x)
>
> Here's how the latter is better:
>
> local x = {}
>
> x.y = {}
>
> function x.y:z(obj)
> assert(self == x.y)
> end
>
> x:y:z() --> In your variant, we get assertion failed,
> --> With reverse order, the assertion passes.
>
> Your variant would probably be bad for composition.
No, it is purely a typographical issue. Instead of ":.",
two characters, I want the colon to be movable.
At present:
a.b.c(...) -- no implied argument
a:b.c(...) -- illegal
a.b:c(...) --> a.b.c(a.b,...)
I want the illegal construction to become legal.
a:b.c(...) -- a.b(a,...)
And in general, one colon allowed, and the object
found up to just before that colon is the one passed.
a.b.c:d.e.f(...) --> a.b.c.d.e.f(a.b.c, ...)
a.b.c.d:e.f(...) --> a.b.c.d.e.f(a.b.c.d, ...)
Unless I misread your post, that is what you mean too,
just different notation.