lua-users home
lua-l archive

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

You only get one disappointment a day? Lucky boy!

I guess "obvious" is in the eye of the beholder - this is not at all obvious
to me!

On the other hand, using the "__call" metamethod you CAN write:

for v in myobject do print(v) end

without the empty parenthesis, which seems inconsistent since both cases are
ultimately just function calls.

The generic for is an easily distinguished "special" context, so it would
not be unreasonable for behaviour to be different between "in" and "do" from
other contexts.

The annoying thing here is I keep getting "but you can do that anyway if you
make a few compromises" type answers. But "__pairs" and "__ipairs" seems to
be going forward, and this really is a trivial change that anyone interested
can easily do themselves with the current version (just replace the global
pairs and ipairs functions with your own).

> -----Original Message-----
> From: [mailto:lua-
>] On Behalf Of Miles Bader
> Sent: 11 September 2009 10:20
> To: steve donovan
> Cc: Lua list
> Subject: Re: Regarding the name 'pairs'
> steve donovan <> writes:
> >> for v in myobject:myiterator do print(v) end
> >
> > This seems a wee bit odd, to make a core change so that we save two
> > characters and end up confusing people anyway.
> Yup, this proposal doesn't make much sense to me...
> [Whereas the alternate proposal, to just make foo:bar without parens do
> the "obvious" thing, and return a closure that captures foo, makes
> quite
> a lot of sense -- on the surface at least, it seems to be very natural
> behavior.]
> -Miles
> --
> Year, n. A period of three hundred and sixty-five disappointments.