lua-users home
lua-l archive

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


On Mon, Sep 20, 2010 at 11:44 PM, Geoff Leyland
<geoff_leyland@fastmail.fm> 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