lua-users home
lua-l archive

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

On Tue, 12 Sep 2006 09:28:13 -0700
Eric Scouten <> 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
about it!

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)

Attachment: signature.asc
Description: PGP signature