lua-users home
lua-l archive

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


When a string I typed contained '^', the Serial-Tool(Serial for Mac) ONLY sent the characters before '^'.
When I typed "2 \^ 2", the result was 4.0.
So, it is NOT a bug/err of lua.

Long Z <zandzx02cn@gmail.com> 于2020年7月13日周一 下午9:59写道:
Checked
When I typed "2 \^ 2", the result was 4.0 ...

Long Z <zandzx02cn@gmail.com> 于2020年7月13日周一 下午9:51写道:
Thank you, guys.
It seems the Serial-Tool used by me send error string to the Lua-Interpreter.
When a string I typed contained '^', the Serial-Tool just sent the characters before '^'.
So, it is NOT a bug/err of lua.

Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> 于2020年7月13日周一 下午8:45写道:
> "2^2" have NOT went into OP_TAILCALL, and also OP_POW.
> So strange...

"2^2" is computed at compile time because it's a constant _expression_.
"return 2^2" gives this bytecode:

VARARGPREP      0
LOADF           0 4
RETURN          0 2 1   ; 1 out
RETURN          0 1 1   ; 0 out

which matches your report except that you had LOADI instead of LOADF.


--
龙的传人


--
龙的传人


--
龙的传人