lua-users home
lua-l archive

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



I think that the ease of adding this syntactic change is really irrelevant to whether it should be included. I personally think that it leads to unclear and cryptic code. Also it is not consistent, the same syntax means different things in in different places. Which is a Bad Thing.

Yes, there are certainly good reasons to stay away from this hack :)

The strongest argument against it, I think, is that there's really not much precedent for this kind of shorthand in any other language.  So any programmer who comes across it, no matter how experienced, is going to be confused.  And  that's never a good thing :)

But, in my own scripts at least, the shorthand is simplifying a lot of situations where I'd otherwise be writing highly repetitive code.  And after living with it for a couple months, I'm finding it clearer than vanilla lua.  My hope, when I first wrote it up, was that the shorthand would have an obfuscation/simplification tradeoff similar to +='s.  So while it would certainly be obscure for people who weren't used to it, it would have a chance of clarifying things for people who were.  To that end, I think it works better if it's implemented using a relatively large, multi-character token.  {.star} or {!star} are both easy to miss-read as {star}.  But {..star} is fairly obviously some kind of shorthand.  And I like that it's evocative of '...', as the semantics remind me of an 'et cetera'.

That said, if I had to pick a single addition to make to the 5.2 Lua spec, this wouldn't be it.  I'd go with either Peter's table unpack semantic, or possibly an increment operator.  But, there's a small community of people on the list who enjoy playing around with parser hacks, and for their benefit, I thought the idea might still be worth posting :)

-Sven