lua-users home
lua-l archive

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

On 21/09/2010, at 6:56 PM, Jonathan Castello wrote:

> On Mon, Sep 20, 2010 at 11:52 PM, Jonathan Castello <> wrote:
>> On Mon, Sep 20, 2010 at 11:44 PM, Geoff Leyland
>> <> wrote:
>>> On 21/09/2010, at 6:37 PM, Jonathan Castello wrote:
>>>> While not exactly about table initializations, one thing I've
>>>> occasionally wanted was to be able to implicitly index the current
>>>> environment. In a table you can do {[a + b] = c}, but it would be nice
>>>> to be able to do [a + b] = c as a normal statement. Likewise with
>>>> accessing: x = [y].
>>> Wouldn't that cause ambiguous syntax problems?   Would "a = b [c]:d()" be one or two statements?
>> I'm not sure how it could be construed in any other way than "a =
>> (b[c]):d()" in that context. Were you supposing that 'b' might be a
>> function? As far as I recall, functions can only accept a string
>> literal or a table literal as an argument without requiring
>> parentheses, so "b t[d]" is already syntactically invalid.
>> ~Jonathan
> Nevermind, I misunderstood what you meant by "statements". You mean it
> could be interpreted as "a = b; [c]:d()"? That's a good point, I guess
> there's no getting around that one.

Yep, I was just writing a reply to that effect.  Apologies for not being clearer!