문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top