Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

spreading a format string across lines

2 views
Skip to first unread message

Dorai Sitaram

unread,
Mar 27, 2002, 10:16:36 AM3/27/02
to
What do you think

(format t "This is just ~
one line.~%")

should return?

--d

Daniel Barlow

unread,
Mar 27, 2002, 10:33:09 AM3/27/02
to
ds...@goldshoe.gte.com (Dorai Sitaram) writes:

NIL


-dan

--

http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources

Dorai Sitaram

unread,
Mar 27, 2002, 10:50:20 AM3/27/02
to
In article <87hen28...@noetbook.telent.net>,

Daniel Barlow <d...@telent.net> wrote:
>ds...@goldshoe.gte.com (Dorai Sitaram) writes:
>
>> What do you think
>>
>> (format t "This is just ~
>> one line.~%")
>>
>> should return?
>
>NIL
>

Right; I'd like to get a feel for what people generally
expect this call to print. Ie, its side-effect.
I myself would expect it to print the immediately
following not-completely-whitespace line.

This is just one line.

It doesn't though, and I wonder if other people
find that not quite right.

--d

Barry Margolin

unread,
Mar 27, 2002, 11:03:48 AM3/27/02
to

There's a space between the tilde and the newline. I don't think ~<space>
is defined as a standard format control, so the consequences are
undefined. Are you under the impression that ~<space><newline> should be
treated the same as ~<newline>?

--
Barry Margolin, bar...@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

Dorai Sitaram

unread,
Mar 27, 2002, 11:18:34 AM3/27/02
to
In article <E3mo8.6$vU1...@paloalto-snr2.gtei.net>,

Barry Margolin <bar...@genuity.net> wrote:
>In article <a7spns$l3i$1...@news.gte.com>, Dorai Sitaram <ds...@gte.com> wrote:
>>>
>>>> (format t "This is just ~
>>>> one line.~%")
>>>>
>>I'd like to get a feel for what people generally
>>expect this call to print...

>>I myself would expect it to print the immediately
>>following not-completely-whitespace line.
>>
>>This is just one line.
>>
>>It doesn't though, and I wonder if other people
>>find that not quite right.
>
>There's a space between the tilde and the newline. I don't think ~<space>
>is defined as a standard format control, so the consequences are
>undefined. Are you under the impression that ~<space><newline> should be
>treated the same as ~<newline>?

Wouldn't that be "nice" though? It is disconcerting,
to me at least, that invisible trailing space,
should so drastically affect a program's behavior.
(Something even Python doesn't dare allow. :-)

One might counter that invisible trailing space in
calls like

(princ "abc
def")

does change meaning, but all that does is faithfully
reproduce invisible trailing space when given
invisible trailing space, ie, the effect isn't as
drastic.

--d

Pierpaolo BERNARDI

unread,
Mar 27, 2002, 11:31:50 AM3/27/02
to

"Dorai Sitaram" <ds...@goldshoe.gte.com> ha scritto nel messaggio
news:a7spns$l3i$1...@news.gte.com...

What do you mean with "it doesn't though"?
It must print "This is just one line<end-of-line>",
If the implementation you are using behaves
differently, it must have a bug.

Or, do you mean that there is an ambiguity
in the spec? Where exactly?

P.

Erik Naggum

unread,
Mar 27, 2002, 12:48:17 PM3/27/02
to
* Dorai Sitaram

It should not return, it should signal an error because the final space
is not defined as a format control. This is no different from

(format t "This is just ~ one line.~%")

Trailing whitespace within strings is not invisible to the Lisp reader.

///
--
In a fight against something, the fight has value, victory has none.
In a fight for something, the fight is a loss, victory merely relief.

Larry Clapp

unread,
Mar 27, 2002, 7:49:06 PM3/27/02
to
In article <a7srcq$l43$1...@news.gte.com>, Dorai Sitaram wrote:
> In article <E3mo8.6$vU1...@paloalto-snr2.gtei.net>,
> Barry Margolin <bar...@genuity.net> wrote:
>>In article <a7spns$l3i$1...@news.gte.com>, Dorai Sitaram <ds...@gte.com> wrote:
>>>>
[...]

>>
>>There's a space between the tilde and the newline. I don't think
>>~<space> is defined as a standard format control, so the
>>consequences are undefined. Are you under the impression that
>>~<space><newline> should be treated the same as ~<newline>?
>
> Wouldn't that be "nice" though? It is disconcerting, to me at
> least, that invisible trailing space, should so drastically affect a
> program's behavior. (Something even Python doesn't dare allow. :-)

Every language I know that uses backslash ( \ ) to do line
continuation will do "something disconcerting" (i.e. not continue the
line) if a space (or anything else) follows the backslash. It has
little to do with daring. :) Similarly, Unix's make program demands
leading tabs.

Whitespace, and sometimes different *kinds* of whitespace, matters --
as you now know. :)

I find it useful to go through my code every so often and look for
whitespace at the end of lines. I don't think it's caused me any
trouble yet, but only because I eliminate it whenever I find it. :)

-- L

0 new messages