[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] lisp -> spad question
From: |
Waldek Hebisch |
Subject: |
Re: [Axiom-developer] lisp -> spad question |
Date: |
Thu, 13 Sep 2007 05:14:51 +0200 (CEST) |
Arthur Ralfs wrote:
> Hello,
>
> The following lisp seems to do what I want, i.e. capture stuff written to
> *standard-output* in a string,
>
> (1) -> )lisp (setq out (with-output-to-string (*standard-output*)
> (write-line "hello universe")))
> (1) ->
> Value = "hello universe
> "
> (1) -> )lisp (write-line out)
> hello universe
>
> Value = "hello universe
> "
>
> However when I try to translate this to spad with the following function:
>
> testCommand2():Void ==
>
> SETQ(out$Lisp,WITH_-OUTPUT_-TO_-STRING(LIST(_*STANDARD_-OUTPUT_*$Lisp)$Lisp,
> WriteLine("Hello Universe")$Lisp)$Lisp)$Lisp
>
>
> I get this:
>
> (1) -> testCommand2()
> Loading /home/arthur/axiom/silver/silver-07-08-25/AXSERV.nrlib/code
> for package AxiomServer
>
> >> System error:
> #<synonym stream to *TERMINAL-IO*> is not a string with a fill-pointer.
>
> Can anybody tell me what's going on?
>
Your Spad code corresponds to:
(setq out (with-output-to-string (list *standard-output*)
(write-line "hello universe")))
which wants *standard-output* to be a string with fill pointer
(and list would be the resulting stream). To get your Lisp
you need something like:
SETQ(out$Lisp,WITH_-OUTPUT_-TO_-STRING(_*STANDARD_-OUTPUT_*()$Lisp)$Lisp,
WriteLine("Hello Universe")$Lisp)$Lisp)$Lisp
(which IMHO is extremally ugly).
I would say that it if you need things like with-output-to-string than
it is better to write your function in Lisp -- Spad version is
impossible to understand without knowing Lisp and a Lisper will
still have trouble translating Spad syntax to Lisp.
--
Waldek Hebisch
address@hidden