lua-users home
lua-l archive

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



On Feb 5, 2009, at 1:04 PM, Michal Kolodziejczyk wrote:

Doug Rogers wrote:
Michal Kolodziejczyk wrote:
I am also missing __tonumber metamethod...

It seems like this could be a useful feature, but if it were to behave
like __tostring it would be of limited value - limited to programmers
calling tonumber() explicitly.

Yes, I am aware of that, and this is what I meant - use __tonumber only
when explicity calling tonumber() (and maybe adding an optional number
base as a second argument to __tonumber). I did not mean to change the
internals of VM (as I also appreciate the simplicity of lua).

One place where calling the __tonumber method implicitly would be very useful is in string.format when given a numeric format option.

See: http://lua-users.org/lists/lua-l/2006-10/msg00001.html

e