[r6rs-discuss] strange escape sequence in string literals

Per Bothner per at bothner.com
Thu Nov 18 16:46:45 EST 2010


On 11/18/2010 12:56 PM, Shiro Kawai wrote:
> From: Andy Wingo<wingo at pobox.com>
> Subject: Re: [r6rs-discuss] strange escape sequence in string literals
> Date: Thu, 18 Nov 2010 21:29:18 +0100
>
>> I wonder though, what is the purpose of allowing intraline whitespace
>> before the line ending?
>
> I don't remember if there was any discussion, but I imagine
> that it might be an annoyance if accidental whitespace between
> the backslash and the line ending changes the meaning.
> (I was bitten with it in dreadful C macro definitions...)

A Scheme source file is a *text* file, rather than a binary file.
The meaning of a text file should (by definition) be independent
of the line-ending convention used.  IMO the meaning of a text file
should also be independent of trailing whitespace:  Otherwise you
will not be able to "store" a text file in a fixed-line-length file,
as in a deck of cards (some of us remember using them) or fixed-length
"record"-based representations, as used to be common on mainframes.

Punch cards and fixed-length records are (hopefully) only of
historical interest, but I think it is still a bad idea for a
file format to place significance on the amount of trailing whitespace,
because most text editors and IDEs don't show them.

What about trailing whitespace in string literals?  This is related
to the issue of what if there is a CR-NL pair in a string literal.
So I think the right think to do is for a lexer (including a Scheme
reader) to normalize line endings: strip of trailing whitespace,
and convert CR-NL to NL.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the r6rs-discuss mailing list