[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Shorthand for appending to a table (was Re: 5.2 feature list?)
- From: Adrian Perez <moebius.lists@...>
- Date: Tue, 12 Sep 2006 18:48:50 +0200
On Tue, 12 Sep 2006 09:28:13 -0700
Eric Scouten <email@example.com> wrote:
> On 12 Sep 2006, at 09:08, Vyacheslav Egorov wrote:
> > Eric Scouten wrote:
> >> p[ #p + 1 ] = value
> > We also can reuse end keyword for this
> > p[end] = value
> I like that.
I've been reading the discussion so far, and I agree that it would be
nice having some kind of syntactic sugar for such an operation, but
this is the only option which really makes sense for ;-)
t[ #t + 1 ] = item -- Sometimes hairy, as everybody says.
t:append(item) -- Implies lookup and function call.
t = item -- Seems that t will have a copy of all
the elements in "item" (like when you
do "x = y[:]" with Python slices).
t[end] = item -- I like it!
I was quite impressed by the implementation of "t = item" done with
the token filters patch. I did hear about the patch before -- but never
imagined it could make that tricky stuff because I didn't know too much
That were my two cents. Cheers,
P.S: Maybe I will be using Lua in my end-of-degree project at the
University ;-) If something interesting arises, I'll drop an email to
the mailing list.
"I used to think that *I* was stupid, and then I met philosophers."
-- (Terry Pratchett, Small Gods)
Description: PGP signature