This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: how to have as-xml output to e.g. a (Scheme) string/port?
- From: "Hoehle, Joerg-Cyril" <Joerg-Cyril dot Hoehle at t-systems dot com>
- To: kawa at sources dot redhat dot com
- Date: Thu, 16 May 2002 16:14:07 +0200
- Subject: Re: how to have as-xml output to e.g. a (Scheme) string/port?
Hi,
> as-xml conceptually evaluates to a string, [...]
> It is a function, without side-effects.
Ah, I see now. "conceptually" is very important (to me).
It's not really a string. It's multiple-values.
As an old Common Lisper, I got very confused that
(list (values 1 2)) -> (12) ; all values represented as an object
whereas in Common Lisp -> (1) ; extra values are dropped.
So in Kawa, I can just send a multiple values representing object to write and have it output the multiple values object to an arbitrary port. I don't need call-with-output-string.
And if I really want a string:
(call-with-output-string (lambda (s) (write (make-element 'p "The time is now: " (make-element 'code (make <java.util.Date>))) s)))
#|kawa:33|# (invoke (as-xml (make-element 'p "The time is now: " (make-element 'code (make <java.util.Date>)))) 'get-class)
class gnu.mapping.Values
#|kawa:34|# (let-values ((x (as-xml (make-element 'p "The time is now: " (make-element 'code (make <java.util.Date>)))))) x)
(< p > T h e t i m e i s n o w : < c o d e > T h u M a y 1 6 1 5
: 4 1 : 4 9 C E S T 2 0 0 2 < / c o d e > < / p >)
#|kawa:35|# (invoke (make-string 5 #\a) 'get-class)
class gnu.lists.FString ; that's the string class, as documented.
That has consequences: Common Lisp in kawa can only be a rough approximation. Behaviour of multiple values is radically different.
Regards,
Jorg Hohle.
PS: I started editing kawa.texi from 1.68. I suppose it's the root of all the other documents.