Elie

I logged off too early to respond when you asked, but there are two
ways to convert a piece of data like { "a" 1 "b" 2 } into a string and
back.  Factor, like Lisp and Prolog, has homoiconic syntax--it can
treat its syntax as data and contains functions for converting any
data to a string and back. To take advantage of that, you can use

[ pprint ] string-out

to convert any data to a string. To convert it back, use

parse first

(parse yields a quotation which the string represents, and taking the
first one gets the data, assuming there's one piece of data there.)
However, this has huge security issues. Imagine if the code to be
parsed was something like this:

: EXIT 0 exit ; parsing EXIT

As an alternative, Chris Double (doublec) has made a serializer in
Factor which works on all objects. It's in libs/serialize. Its API is
extremely simple, with the main three words, serialize, deserialize
and with-serialized, all well-documented. It looks like it even works
with recursive data structures, which pprint can't handle properly.

Daniel Ehrenberg

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to