Subject: [clisp-list] macros for CLISP -- character literals in strings

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Wed Mar 10 03:11:08 2004

Hi,

Pascal J.Bourguignon wrote:
>(defconstant +space-list+ '(#\newline #\Return #\Linefeed 
>#\space #\tab #\page))
>;; Note, usually, I prefer to keep characters in strings,
>;; and using POSITION instead of MEMBER.
>;; It's just harder to come with a string literal containing 
>these characters.

Uh? What about
(coerce '(#\newline #\Return #\Linefeed #\space #\tab #\page) 'string)

Come on, constant values in Lisp can be computed and result from complex computations, unlike preprocessor literals in C.

Ok, such string literals are not so nice when printed or while in the debugger, but that's not the reason you invoke.
"
^M
 	^L"

I agree that another case is slightly harder: a mixture of text and #\newline in between. E.g. I myself tend to dislike invoking FORMAT to achieve constant strings with embedded newlines like in
(defconstant +foo+ (format nil "First line~%Another line~%"))
But your example with only special characters does not fall into this category.

Regards,
	Jörg Höhle.

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Wed Mar 10 10:06:05 2004

> (coerce '(#\newline #\Return #\Linefeed #\space #\tab #\page) 'string)

Nice!  Thank  you. Up to now  I used FORMAT  to do the same,  but this
sounds better.

> Come on, constant values in Lisp can be computed and result from
> complex computations, unlike preprocessor literals in C.
> 
> Ok, such string literals are not so nice when printed or while in
> the debugger, but that's not the reason you invoke.  " ^M ^L"
> 
> I agree that another case is slightly harder: a mixture of text and
> #\newline in between. E.g. I myself tend to dislike invoking FORMAT
> to achieve constant strings with embedded newlines like in

-- 
__Pascal_Bourguignon__                     http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/