Top
Best
New

Posted by phreddypharkus 20 hours ago

LuaJIT 3.0 proposed syntax extensions(github.com)
215 points | 144 commentspage 4
yxhuvud 13 hours ago|
In aggregate this looks like a godsend, but there are some examples (like foo?.:method) that looks atrocious.
Ciantic 11 hours ago|
Yeah, "?." as safe navigation operator even in JS where it already exists is eye-sore. They could use some other single character instead of two characters. Question mark is already doing a lot with ternaries etc.

Instead of obj?.:method?.(…) it would be like obj#:method#(…)

Replace # with your favorite extra character instead of questionmark.

JBits 7 hours ago||
Is there any reason why they're not considering a single '?' like rust? Is it a parsing issue?

So you'd have: obj?:method(…)

orthoxerox 4 hours ago||
Mike Pall wrote in the issue that it's easier to parse. If they get rid of the ternary operator, I'll ask him again to drop the period.
nmz 1 hour ago||
a lone ? can mean anything, you can already tell that . is for fetching a subtable.
orthoxerox 1 hour ago||
In C# it's not a lone ?, it's two operators: ?. and ?[

Lua could have ?. ?[ ?" ?{ and ?(

sourcegrift 18 hours ago||
What are some pragmatic embedded scripting languages of choice these days if one has to consider:

1) Ease of learning, ideally minimal deviant behaviour (eg i consider lua tables to be a new concept in itself)

2) Reasonably fast. Not as much as lua jit but even half would be good enough

3) Mature

4) Has Rust bindings

NuclearPM 17 hours ago|
Lua. Lua tables are easy and awesome. My hobby language unites Lua tables with functions too.
kevinten10 11 hours ago||
[dead]
shevy-java 17 hours ago|
Lua has a lot of useless syntax. For instance, the "then". I have been using ruby and python for many years. Lua is living in the old age here.

That's just one example of so many more. I get that lua occupies a useful niche with its focus on embedded systems, but lua is not really a well-designed language in general. JavaScript has a similar problem.

xonre 14 hours ago||
For readability, `then` allows splitting with newlines very long conditional expressions, without having to wrap the condition in parentheses:

  if x + y + z > a
    or verylongconditionalhere ()
    or anotherverylongconditionalhere ()
  then
    ...
after `if` and `elseif` the parser simply goes on until it finds `then`.
nmz 3 hours ago|||
This is something I don't see a lot of people do. I've tended to do

  for long,list,of,variables,here
  in ageneratorhere(bigparameterhere)
  do
  end
and

  local x do
    -- everything after is just here to define x
  end

I'm still a little irked it works so well, the only alternative would be for the language to have labeled blocks. but that might be too terse
drunken_thor 5 hours ago|||
Agreed, it keeps the parser fast as well because it is a lot more clear when the boolean statement ends and the code block begins. You either need parentheses, `then` or brackets around the block to make parsing clearly defined.
Dylan16807 15 hours ago|||
Python spells "then" as ":"

In Ruby you can choose between "then" and a newline.

This is very pot calling the kettle black.

mjmas 14 hours ago|||
English too
modulared 16 hours ago||
[dead]