lua-users home
lua-l archive

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


It's my understanding that tonumber(), when called with a single
parameter, is expected to return nil if it is given a non-numeric
value, not to throw an error:

 print(tonumber('aaa')) --> nil
 print(tonumber({ })) --> nil
 print(tonumber(io.stdin)) --> nil

However, it *does* throw an error if you give it an FFI cdata value
which is non-numeric:

 print(tonumber(ffi.new 'struct { }')) --> (!) cannot convert struct to double

I believe this should be changed, to be consistent with the general case.

-Duncan