lua-users home
lua-l archive

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


Hi Dan,

> That is, if the value being serialized is equal to math.huge, instead
> write out the expression 1 / 0 and if the value being serialized is not
> equal to itself (the only way I found to identify the undefined value),
> serialize it as the expression 0 / 0 and otherwise use tostring.

I have similar logic, but use math.huge instead of 1/0:

type(s) == "number" and (s ~= s and '0/0'
    or s == math.huge and 'math.huge' or s == -math.huge and '-math.huge') ...

This generates:
{
  ...
  [math.huge] = -math.huge
}

I'm indeed running on Windows and haven't had a chance to test on
other platforms, so I'm not sure if this is Windows-only effect or
not, but this code should work fine on other platforms too...

Paul (http://notebook.kulchenko.com/).