lua-users home
lua-l archive

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



On 12 Sep 2006, at 10:23, Paul Hudson wrote:

I'm with some of the other posters.

t[] = value

does not clearly say "append value to t" to me.

If we really need

t[#t+1] = value

to go faster, then the parser could be changed to recognise it as a special
case?


Actually no-one was arguing it should go faster, merely that it should be easier to type. There are two legitimate concerns as I see it:

1) when t is a long name. Could be particularly embarrassing if you misspell it (personally I don't like long names, but hey)

2) when t is a more complex expression, eg: f(x)[#? + 1] = value.

I'm always very loath to suggest or support more syntax, but how about if '#' on its on in an expression inside [] were to mean the length of the table being indexed. So you could go:

t[#+1] = value

It's pretty clear, and almost syntactically unambiguous.

drj