lua-users home
lua-l archive

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




On Friday, September 11, 2015, Rodrigo Azevedo <rodrigoams@gmail.com> wrote:

This is not a syntactic sugar! It is completely different. I am not assigment to diffent keys, but to a multiple keys. This cant be done with table as metamethod because only functions accept multiple arguments.  The body of index and newindex is an arbitrary function not a simple replacement of multiple assigments.

I see your point. To my way of thinking m, that may be a decent argument against this syntax. If something looks like multiple assignment and may not be, that would be terrible. Whether that feature would *actually result* in people writing abusively weird software is a matter for debate. 

You could also imagine an alternative proposal where the definition of __newindex/__newindex remains the same, and your syntax would result in multiple calls to the same metamethod. This would make it impossible(?) to do anything funny with regards to multiple assignment. 

I don't like this:

`a, b[1, 2], c = 1, 2, 3, 4`


I'm bothering to respond because there is _something about_ your idea that I do like. I use lua every day and the more I use it, the more I resize that designing a language is hard and it is very different than imagining features that could be added to a language. No matter the domain, "wanting" is not something I have trouble doing. 

And all of that is to say that the most I can suggest is that sometimes I wonder how "ranges" might be reified in lua.