[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [LuaJIT FFI] tonumber() and cdata
- From: Duncan Cross <duncan.cross@...>
- Date: Sun, 29 May 2011 20:55:21 +0100
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