lua-users home
lua-l archive

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


Dear all,

Why doesn't interactive Lua takes into account the __tostring metamethod of the non-string _PROMPT global when it prints the prompt, so that the below code does not help to increment the prompt on any typed command, although on any >=_PROMPT the variable is incremented?

|>_PROMPT = {no = 0}; setmetatable (_PROMPT, {__tostring = function (self) self.no = self.no + 1; return tostring (self.no) .. ' >' end})|

https://stackoverflow.com/a/64474830/6632736


Alexander Mashin