From: Christophe Rhodes
Subject: Re: How do I create a string with #\Newline in it?
Date:
Message-ID: <sqhdhhl7tp.fsf@cam.ac.uk>
Jeffrey Cunningham <····················@boeing.com> writes:
> (setf s "A string#\Newlinewith some #\Newline.#\Newline)
>
> => "A stringNewlinewith some Newlines.N"
Is that really what you get? You _should_ get (if you add the closing
quote :-) "A string#Newlinewith some #Newline.#Newline".
> I can get what I want using a (concatentate 'string) kludge, or by after
> the fact character substitution using char. Somehow I doubt this is how
> it should be done, but I have yet to see any examples.
>
> How do you do this?
(defvar *string*
"A string
with some
.
")
Christophe
On Thu, 05 May 2005 21:46:26 +0100, Christophe Rhodes wrote:
> Is that really what you get? You _should_ get (if you add the closing
> quote :-) "A string#Newlinewith some #Newline.#Newline".
I just KNEW I should have looked instead of relying on memory... :-]
> (defvar *string*
> "A string
> with some
> .
> ")
I love it. Right under my nose. Is there a way to do it without losing the
indentation?
-jeff
+ Jeffrey Cunningham <·······@cunningham.net>:
| On Thu, 05 May 2005 21:46:26 +0100, Christophe Rhodes wrote:
|
| > (defvar *string*
| > "A string
| > with some
| > .
| > ")
|
|
| I love it. Right under my nose. Is there a way to do it without losing the
| indentation?
Write your own string parser and install it using set-macro-character?
It's probably not a terribly difficult thing to do.
But then make sure it is present when you're loading or compiling
files relying on this syntax. I believe the right way to do this is
to put something like
#.(setf *readtable* (copy-readtable))
#.(set-macro-character #\" #'new-reader-syntax:new-string-reader)
in the file. Or what do people think?
(The first bit, about copying the readtable, is so our local changes
will not be reflected in the global environment.
LOAD and COMPILE-FILE do rebind *readtable* but don't make copies.)
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow
From: Edi Weitz
Subject: Re: How do I create a string with #\Newline in it?
Date:
Message-ID: <ur7gkn133.fsf@agharta.de>
On 06 May 2005 10:51:53 +0200, Harald Hanche-Olsen <······@math.ntnu.no> wrote:
> Write your own string parser and install it using
> set-macro-character?
<http://weitz.de/cl-interpol/>
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
Jeffrey Cunningham <·······@cunningham.net> writes:
> On Thu, 05 May 2005 21:46:26 +0100, Christophe Rhodes wrote:
>
>> Is that really what you get? You _should_ get (if you add the closing
>> quote :-) "A string#Newlinewith some #Newline.#Newline".
>
> I just KNEW I should have looked instead of relying on memory... :-]
>
>> (defvar *string*
>> "A string
>> with some
>> .
>> ")
>
>
> I love it. Right under my nose. Is there a way to do it without losing the
> indentation?
Well, you could write:
(defparameter *string* (format nil "A ·······@
with ·····@
··········@
~& and beginning with spaces."))
*string*
-->
"A string
with some
newlines.
and beginning with spaces."
--
__Pascal Bourguignon__ http://www.informatimago.com/
Kitty like plastic.
Confuses for litter box.
Don't leave tarp around.