724 posts
Posted 19 August 2012 - 05:21 PM
line 154 of texutils API should be
error( "Cannot serialize type "..sType )
instead of
local sType = type(t)
-- ... --
error( "Cannot serialize type "..t )
because it gives out wrong error.
Also can anyone explain why environment cleared in the process of unserialization?
function unserialize( s )
local func, e = loadstring( "return "..s, "serialize" )
if not func then
return s
else
setfenv( func, {} )
return func()
end
end
86 posts
Posted 19 August 2012 - 06:18 PM
The env is being changed because it needs to make unserialize return properly, probably… I'm tired of looking at the ref. manual. Find out what the call does:
http://www.lua.org/manual/5.1/manual.html#pdf-setfenvThe type(sType) call is perfectly logical, because ofc, it can't serialize a function, nor print it, either.
724 posts
Posted 20 August 2012 - 04:38 PM
Doubt it needed to work properly. It looks like some protection.
Try to serialize function. It will give you wrong error about concatenating string and function.
Also it is possible to serialize function. This API just refuse to do it. I did it succesfully with proper binary input/output. Can Dan200 do it right?
2447 posts
Posted 24 August 2012 - 10:35 AM
It isn't designed to serialise functions. If you want to do that there's nothing stopping you doing that yourself.
724 posts
Posted 24 August 2012 - 10:48 AM
It was designed to give message it cannot serialize functions. But it give message "Cannot concatenate string and function". That is a BUG!.
It's easy to add serialization of function but bad binary file IO hinder it (is it right word?).
Environment clearing prevent me from adding vector (and other known "classes") serialization to this API. Why it was added? Is it really needed?
2447 posts
Posted 24 August 2012 - 07:08 PM
It was designed to give message it cannot serialize functions. But it give message "Cannot concatenate string and function". That is a BUG!.
It's easy to add serialization of function but bad binary file IO hinder it (is it right word?).
Environment clearing prevent me from adding vector (and other known "classes") serialization to this API. Why it was added? Is it really needed?
It was added to serialise most normal Lua types. If you don't like it, use your own solution. I'll fix the small bug (although in reality it will just replace one error with another, but whatever :D/>/>)
496 posts
Location
Harlem, NY
Posted 01 September 2012 - 04:31 PM
You can try immibis's Proper Serialization here on the forums.
724 posts
Posted 15 September 2012 - 09:44 AM
It was added to serialise most normal Lua types. If you don't like it, use your own solution. I'll fix the small bug (although in reality it will just replace one error with another, but whatever :)/>/>)
Thanks for fixing. I want standard utils to be bug-free.
Question about environment clearing still not answered. :D/>/>
You can try immibis's Proper Serialization here on the forums.
I can but standard serialization results can be read by eyes too :P/>/>