I find this hard to believe:

////////////////////////////////////
var li1 = list("hello","my","World");
var li2 = list (li1, list("my","sweat","lord"), list("janis","joplin"));

// The ULTIMATE!
println$ li1;
var enli1 = Serialise::encode_pointer_closure li1.C_hack::cast[address];
var deli1 = (Serialise::decode_pointer_closure 
enli1).C_hack::cast[list[string]];
println$ deli1;

println$ "-" * 20; 
println$ li2;
var enli2 = Serialise::encode_pointer_closure li2.C_hack::cast[address];
var deli2 = (Serialise::decode_pointer_closure 
enli2).C_hack::cast[list[list[string]]];
println$ deli2;
/////////////////////////////////////

list('hello', 'my', 'World')
list('hello', 'my', 'World')
--------------------
list(list('hello', 'my', 'World'), list('my', 'sweat', 'lord'), list('janis', 
'joplin'))
list(list('hello', 'my', 'World'), list('my', 'sweat', 'lord'), list('janis', 
'joplin'))

////////////////////////////////////

List have pointers in them! And the second example is a list of lists
of strings. 

That it works in not as surprising as the fact that it worked FIRST TIME
(after it finally compiled!).

The serialisation class is 300 lines of complex address calculations
and nasty casts, half of which is new code dealing with pointer
closures.

At present not all is tested -- feel free to help!
Closures and Judy are not handled yet.
[nor regexps or anything with a custom scanner]

To use this facility: 

(1) Gather pointers to all the stuff you want to save in a single
data structure. Don't forget: heap allocated data ONLY.

(2) cast the object to an address. Make sure it is actually
a pointer underneath. varrays and lists are pointers.

(3) Serialise to a string.

(4) save it to disk. 

(5) reload it later into THE SAME PROGRAM.

(6) Unserialise it to an address

(7) Cast the address back to the original data type.



--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to