From: Peter Keller on
Jorge Gajon <gajon(a)gajon.org> wrote:
> On 2010-07-08, Peter Keller <psilord(a)cs.wisc.edu> wrote:
>>
>> What I found I really need is the equivalent of perl's here documents.
>>
>
> Doug Hoyte shows how to implement a 'heredoc' reader in his book
> "Let Over Lambda". You can actually read that chapter at it's website:
>
> http://letoverlambda.com/index.cl/guest/chap4.html#sec_3

HA! Funnily enough, I own that book. I've been so busy understanding some
of the other chapters that I completely forgot about that example in the
book. :)

Thanks for pointing it out, that is pretty useful for me in my context.

-pete
From: Rupert Swarbrick on
Peter Keller <psilord(a)cs.wisc.edu> writes:
>
> Just before I read this message, I indeed found the same thing. In fact plain
> lisp strings do work just fine for my needs when I need a heredoc-like
> thing.
>
> The usual place where it is unhappy is if I have some chunk of code on the
> right hand side of the screen and want a long string to be wrapped in a
> meaningful manner in accordance with the indention levels around the string.
>

I don't know if things are being passed through FORMAT, but if so you
can use the magic behaviour of ~ followed by a newline. If that occurs
in a format string, the new line and all the whitespace immediately
following it gets ignored:

CL-USER> (format t "Test me ~
please~%")
Test me please
NIL

Of course, if you just want to print string literals, this might be an
icky way to do it...

Rupert
From: Peter Keller on
Rupert Swarbrick <rswarbrick(a)gmail.com> wrote:
> [-- text/plain, encoding 7bit, charset: ISO-8859-1, 26 lines --]
>
> I don't know if things are being passed through FORMAT, but if so you
> can use the magic behaviour of ~ followed by a newline. If that occurs
> in a format string, the new line and all the whitespace immediately
> following it gets ignored:
>
> CL-USER> (format t "Test me ~
> please~%")
> Test me please
> NIL
>
> Of course, if you just want to print string literals, this might be an
> icky way to do it...

This I knew, however, SLIME doesn't indent format strings in this form
correctly. That was the main query concerning this thread. I found other
means around it, but it was surprising there's be an oversight in the
indention algorithm in emacs/SLIME in this context.

Thank you.

-pete
From: Thomas A. Russ on
Peter Keller <psilord(a)cs.wisc.edu> writes:

> Thomas A. Russ <tar(a)sevak.isi.edu> wrote:
> > Either the #. or the constant macro-expansion route will also work. I
> > guess my approach would be to use #. if they are literal constants. One
> > place I might do that is to define seconds-per-day as #.(* 24 60 60) to
> > make it more readable.
>
> Out of curiosity, I would have assumed any of the popular CL implementations
> would have done some kind of optimization with (* 24 60 60), so why would you
> explicitly state it to be compiled at read time?

Because I'm an old guy and early lisp compilers were not always that smart.

--
Thomas A. Russ, USC/Information Sciences Institute










First  |  Prev  | 
Pages: 1 2 3
Prev: New version!!!
Next: remote lisp in virtual linux