From: Slava Akhmechet
Subject: String literals spanning multiple lines
Date: 
Message-ID: <87ps5yom19.fsf@gmail.com>
Hello,

Is there a way to have a Common Lisp string literal span multiple
lines as a convenience (without lisp inserting end of line
characters)?

For example if I do something like

"Hello
World"

or

"Hello\
World"

Lisp inserts an end of line between 'Hello' and 'World'. Is there an
escape character or a read macro that prevents this from happening?

-- 
Regards,
Slava Akhmechet.

From: Harold Lee
Subject: Re: String literals spanning multiple lines
Date: 
Message-ID: <1177100370.018308.293170@b75g2000hsg.googlegroups.com>
On Apr 20, 12:58 pm, Slava Akhmechet <·········@gmail.com> wrote:
> Hello,
>
> Is there a way to have a Common Lisp string literal span multiple
> lines as a convenience (without lisp inserting end of line
> characters)?

The easiest way is to remove newline characters:

CL-USER> (delete #\Newline "hello
world")
"helloworld"
CL-USER>

You can actually change the way Lisp handles double quotes too:

CL-USER> (defvar *original-readtable* (copy-readtable) "Backup copy.")
*ORIGINAL-READTABLE*
CL-USER> (let ((read-string (get-macro-character #\")))
           (flet ((new-read-string (stream char)
             (delete #\Newline
                     (funcall read-string stream char))))
             (set-macro-character #\" #'new-read-string)))
T
CL-USER> "hello
world"
"helloworld"
CL-USER> (setf *readtable* *original-readtable*)
#<READTABLE {B898621}>
CL-USER> "hello
world"
"hello
world"
CL-USER>
From: Edi Weitz
Subject: Re: String literals spanning multiple lines
Date: 
Message-ID: <ur6qeajsb.fsf@agharta.de>
On Fri, 20 Apr 2007 19:58:41 GMT, Slava Akhmechet <·········@gmail.com> wrote:

> Is there a way to have a Common Lisp string literal span multiple
> lines as a convenience (without lisp inserting end of line
> characters)?
>
> For example if I do something like
>
> "Hello
> World"
>
> or
>
> "Hello\
> World"
>
> Lisp inserts an end of line between 'Hello' and 'World'. Is there an
> escape character or a read macro that prevents this from happening?

CL-USER 1 > #.(format nil "Hello ~
World")
"Hello World"

  http://www.lispworks.com/documentation/HyperSpec/Body/02_dhf.htm
  http://www.lispworks.com/documentation/HyperSpec/Body/22_cic.htm

Cheers,
Edi.

-- 

Lisp is not dead, it just smells funny.

Real email: (replace (subseq ·········@agharta.de" 5) "edi")
From: Slava Akhmechet
Subject: Re: String literals spanning multiple lines
Date: 
Message-ID: <87lkgmol3d.fsf@gmail.com>
Edi Weitz <········@agharta.de> writes:

>   http://www.lispworks.com/documentation/HyperSpec/Body/02_dhf.htm
>   http://www.lispworks.com/documentation/HyperSpec/Body/22_cic.htm

Thanks! Sharpsign dot is a gold nugget in its own right.

-- 
Regards,
Slava Akhmechet.