[gambit-list] display of lists
Marc Feeley
feeley at iro.umontreal.ca
Tue May 15 17:16:35 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 15-May-07, at 1:46 PM, Marijn Schouten (hkBst) wrote:
> Hi,
>
> why does gambit eliminate all spacing and parens when displaying
> lists, such
> as in:
>
> (display ((lambda (lambda) `(,lambda ',lambda)) '(lambda (lambda) `
> (,lambda
> ,'lambda))))(newline)
>
> with output:
>
> lambdalambdaquasiquoteunquotelambdaunquotequotelambdaquotelambdalambda
> quasiquoteunquotelambdaunquotequotelambda
Why don't you use "write", "pretty-print" or "pp":
> (pp ((lambda (lambda) `(,lambda ',lambda)) '(lambda (lambda) `
(,lambda ,'lambda))))
((lambda (lambda) `(,lambda ,'lambda)) '(lambda (lambda) `
(,lambda ,'lambda)))
The current behavior of "display" is useful for situations like this:
> (define name "Marc")
> (define amount 1000000)
> (define (prize) (list "the lottery grand prize of " amount "
dollars"))
> (display (list "Hello " name ", you have just won " (prize) ".\n"))
Hello Marc, you have just won the lottery grand prize of 1000000
dollars.
Note that this behavior conforms to the RnRS standard.
Marc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)
iD8DBQFGSiMz//V9Zc2T/v4RAoQUAJ9EhjQ6qy22LybOTZduUT0haHjyfQCgrRwQ
1ghONEsy43rP5UJTFM2MY/I=
=8mhy
-----END PGP SIGNATURE-----
More information about the Gambit-list
mailing list