lua-users home
lua-l archive

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

Roberto Ierusalimschy wrote:
> What we do in Lua is to expose the underlying rules
> to the programmer, so that if your "machine" says that
> `a ~= a', so does Lua.

Be careful with that definition.  You don't know what the
system does and so you may get problems to 'pass' that
through to the app.  I.e. at the moment Lua may break
depending an what kind of fp-math the machine uses.  I.e. on
a system with NaNs where NaN != NaN the hashes will not work.

  x={a=1,b=1} -- initialized to avoid a SEGV [1]
  print(x[nan])    --> nil, not 1

On systems that raise expections on NaNs, Infs, etc the acos
may SIGFPE.  etc etc

Better say that anything that has to do with unnormal floats
is undefined.

Ciao, ET.

[1] If you do the above check with 'x={}' the 'x[nan]=1' segfaults
in newkey:381 (the luaH_get in newkey returns nilobject).
You could add a check in luaH_set after the 'index is nil' check:

  if (ttype(key)==LUA_TNUMBER && nvalue(key)!=nvalue(key)) error(...)