lua-users home
lua-l archive

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


> It would introduce a syntactic inconsistency. x"1" and x{1} are both
unambiguously function calls, but x[1] is a table lookup, and x[1,2]
is a syntax error.

Good point. But if you use table syntax then it could cause issues with var args and nil values? You can also say that calling foo like this foo[] is illegal syntax and must be foo([]) of course. Not sure what the better solution is. I'm personally not a fan of this way of calling functions this way so I wouldn't mind seeing this whole parentheses-less function call sugar go.


On Sat, Jan 20, 2018 at 6:04 AM, Coda Highland <chighland@gmail.com> wrote:
On Fri, Jan 19, 2018 at 10:37 PM, Sean Conner <sean@conman.org> wrote:
> It was thus said that the Great Elias Hogstvedt once stated:
>> I'm also wondering if for instance the introduction
>> of [] as a constructor would cause issues with other syntax (backwards
>> compatibility aside) or if these changes could make the C implementation
>> more difficult.
>
>   I wouldn't mind this change---it would signal intent better in my opinion.
>
>   -spc
>

It would introduce a syntactic inconsistency. x"1" and x{1} are both
unambiguously function calls, but x[1] is a table lookup, and x[1,2]
is a syntax error.

If you want to tag your constructor syntax, consider:

def list(t): return t
x = list{1, 2, 3}

/s/ Adam