Question

Many of script interpreters like irb or node works as evaluator. If I execute this code,

10

it will evaluate and print the value itself, and make no error.

When I installed lua it worked as executor rather than evaluator. So when I put 10, it will make an error.

Can I make the Lua interpreter work as evaluator?

Was it helpful?

Solution

There's also iLua. It is an extended interpreter and does pretty much all you want.

OTHER TIPS

There is no such thing as "evaluator mode". The Lua interpreter only interprets valid Lua code. That is except for one exception, that is lines starting with =.

In the stand alone interpreter, you have this shortcut to start a line with = , which translates to return. And in the interpreter, when a value gets returned to the "main" routine, it gets printed.

So these are effectively equivalent when entered at the command line:

= 10, 22
return 10, 22
print(10, 22)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top