[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Serialization of math.huge
- From: Paul K <paulclinger@...>
- Date: Tue, 29 May 2012 10:03:16 -0700
Hi All,
I've been working on a simple serialization module (yes, I carefully
reviewed the implementations listed here
http://lua-users.org/wiki/TableSerialization) and came across an issue
with math.huge. tostring(math.huge) returns "1.#INF", but this value
isn't interpreted as a valid number (when I'm loading the generated
string with loadstring). It seems like these values (+/-math.huge)
need to be treated as special cases, but I don't see this logic in any
of the modules I reviewed (including those that aim to provide a
complete serialization solution).
A simple test using serialize.lua from metalua:
require "serialize"
local s = serialize {[math.huge] = -math.huge}
local _, err = loadstring(s)
print(s, err)
This outputs:
return { [1.#INF] = -1.#INF } [string "return { [1.#INF] = -1.#INF
}"]:1: ']' expected near '#'
Does this indeed need to be handled as a special case, or am I missing
some simple solution?
Paul (http://notebook.kulchenko.com/).