Hi Alex,

> Having list cells behave like variables (by referring to their CAR
> parts) is a very useful feature. Not only for properties, but also
> for other list structures.
>    : (setq L (1 2 3 4 5 6 7 8 9))
>    -> (1 2 3 4 5 6 7 8 9)
>    : (nth L 6)                   
>    -> (6 7 8 9)
>    : (inc (nth L 6) 100)
>    -> 106
>    : (set (nth L 9) 777)
>    -> 777
>    : L                  
>    -> (1 2 3 4 5 106 7 8 777)

ohh, I see now!  Thanks for your patience:-)

>> # convert xml "list" (as returned by xml function) to xml "symbol"
>> ...
>> # convert xml "symbol" to xml "list" (as consumed by xml function)
>> ...
> As I said, this might give surprising results if you by chance encounter
> symbols used somewhere else in the system. Try (getl 'select)!

If I try to convert 'select to XML, I get an error:

(setq X2 (new))
(put X2 'select 'select)
(xwrite X2)

<?xml version="1.0" encoding="utf-8"?>
!? (getl S)
((("@Obj" . "@X") . "@Lst") (@ unify (-> "@X")) ("@P" box (cdr (-> "@Lst"))) 
("@C" box (let L (car (-> "@Lst")) (setq L (or (mapcan "select" L) ("select" 
(car L) T))) (cons NIL L L))) (_gen "@Obj") (_sel)) -- Symbol expected

which is completely fine because it is not a "valid" input for
sym2xml.  It is a bit like feeding the 'xml' function with invalid
XML, just get an error.  Well, I do not know how to convert

((("@Obj" . "@X") . "@Lst") (@ unify (-> "@X")) ("@P" box (cdr (-> "@Lst"))) 
("@C" box (let L (car (-> "@Lst")) (setq L (or (mapcan "select" L) ("select" 
(car L) T))) (cons NIL L L))) (_gen "@Obj") (_sel))

to XML so an error seems quite reasonable.

However, if I feed it with the example Henrik provided:

(class +Product +Entity)
(rel name (+Need +String))
(rel id (+Need +Number))
(rel descr (+String))

(setq Product (new '(+Product) 'name "PC" 'id 123))

(setq X (new))
(put X 'product Product)
(xwrite X)

I get an XML:

<?xml version="1.0" encoding="utf-8"?>

I think that Henrik is basically aiming for similar thing, except his
output format is not XML but JSON.

> It always returns the _whole_ property list, and this may contain
> other irrelevant data (as, for example, also Pilog stores rules in
> symbol properties, and the debug environment file names and line
> numbers).

I think that storing these irrelevant data (or rather specific purpose
data) is the good thing about representing XML using symbols.  I can
easily add more helper properties to a symbol during a computation.
It might be more efficient working with lists, but maybe not so
convenient.  This would need an example though which I currently don't



Reply via email to