[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coercion from X to string
Date: Fri, 16 May 86 15:40:10 PDT
From: Richard Fateman <fateman@edu.berkeley.dali>
Subject: coercion of symbols to strings
To convert a symbol to a string one apparently must use the string function.
That is, (coerce 'x 'string) is illegal. But (string 'x) ==> "X" .
Why not allow the former as a synonym for the latter?
Not only that, (coerce #\a 'string) is an error; you have to use (string #\a).
But for some reason, the powers of 'string' and 'coerce' are reversed for
sequences: 'string' applied to a sequence of characters gives an error,
typically saying the sequence can't be coerced to a string, but 'coerce'
will in fact coerce it. All of this is mentioned in the book (p. 304),
but I found it quite hard to keep it straight at first and had to constantly
refer back to the book.
-- Jeff