logoalt Hacker News

drunken_thortoday at 2:12 PM0 repliesview on HN

Some of these things are already implemented in PUC Lua. I don't know why they are diverting from lua spec on other aspects though. Why not work together with the PUC Lua team to add some of these to both lua versions and work on bringing their functionality closer to each other instead of further apart. You might as well just make a new language instead. New features will end up not being used in effort to keep lua scripts portable.

In effort to not pollute the github issue, and hopes that the authors read this thread, I will put some of my thoughts here. There are 3 main strengths of Lua: Embeddable, Fast, and Small(easy to learn). I worry some of these changes divert from the last, expanding the language into a more complicated language.

Here is a list of things already implemented in PUC Lua so can be considered safe to add:

  ● ~ a     Bitwise negate
  ● a & b   Bitwise and
  ● a | b   Bitwise or
  ● a ~ b   Bitwise Xor
  ● a << b  Left-shift
  ● a >> b  Logical right-shift
  ● a // b  Floor divide
  ● break   Break statement
Don't get me wrong, I love some of these quality of life changes like:

  ● Const keyword: changing const from `local a <const> = 42` to `const a = 42` is far better syntax. The bracketed syntax was never a good idea.
  ● nil-Coalescing and safe navigation are great additions as they are basically macros at the parsing stage.
  ● Compound assignment is also basically a macro at the parsing stage as well. Lua should already have this honestly.
  ● Ternary Operator: I *like* it and it will help the stumbling block of the `a and b or c` common pattern already in use. Though I think (like others have stated) the If/then/else syntax would be more inline with the language, similar to ruby and would enable far more emergent behaviour. However it does establish a new pattern that the last value in a block is a return value similar to ruby so I am conflicted about that.
  ● `continue` it is nicer than a goto and is helpful.
  ● String interpolation: I honestly don't love lua's concat operator `..` so honestly string interpolation would be a nice to have and a feature of many modern languages. However I do worry about it's effect on parsing performance, and complexity of the language.
  ● Underscores in numbers: *shrug*
These are great ideas for the language but I would want all lua versions to support them, not just JIT. These are things that I think are a distraction:

  ● The `and` `&&` and `or` `||`. This just goes in the wrong direction for lua. It is often confusing in ruby (especially because of precedence issues) but also lua is a wordy language. It has `do` `end` blocks instead of brackets. It adds ambiguity for no reason.
  ● Short form function syntax. Lua does not need this and I am not sure anyone asked for this. Why `a = |x| do ... end` is more helpful than just `a = function(x) ... end` is unclear and would love to hear more about why this is being considered.
  ● Named varargs: It may be nice, but there is no real reason to add this. If you wanted a name for your varargs you could do `local name = ...` or just use the `args` variable already available in every function.
  ● Switch/Match/Select Statements: An optimized if/else block works just as well and another expansion of a small language.