lua-users home
lua-l archive

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




On 01/03/17 12:06 PM, Dirk Laurie wrote:
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.


Pretty sure you talked about multiple colons in the post you linked.

You proposed, a.b.c:d.e.f:g.h.i(...) --> a.b.c.d.e.f.g.h.i(a.b.c, a.b.c.d.e.f, ...)

I think it'd be better to have, a.b.c:d.e.f:g.h.i(...) --> a.b.c.d.e.f.g.h.i(a.b.c.d.e.f, a.b.c, ...)

Aka inverse colon order. It's more natural/useful.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.