Re: Format ~<newline> feature request. (Not a bug).

Thomas Russ <[email protected]> Tue, 11 Feb 2003 14:59:58 -0800
Newsgroups gmane.lisp.openmcl.bugs
Message-ID <[email protected]>
On Tuesday, February 11, 2003, at 01:22  PM, Gary Byers wrote:

>
>
> On Tue, 11 Feb 2003, Thomas Russ wrote:
>
>> For the DarwinPPC/Mac OS X version of OpenMCL it would be convenient 
>> to
>> have both ~<Linefeed> and ~<Return> work in format strings.  The Lisp
>> reader currently recognizes both linefeed and return as semicolon
>> comment terminators, but having mixed Unix and Mac Lisp source files
>> will still cause trouble if the format directive doesn't work with 
>> both
>> line terminators.
>>
>
> See <http://openmcl.clozure.com/Doc/line-termination.html>, especially
> the discussion of :EXTERNAL-FORMAT.

I like this solution :)

>> A workaround is fairly simple, namely to include the following in the
>> openmcl-init file, but this might be something that should be built in
>> to at least the Mac version:
>>
>> (setf (aref ccl::*format-char-table* (char-code #\Return))
>>        (aref ccl::*format-char-table* (char-code #\Linefeed))
>
> I'm generally leery of treating #\Return and #\Linefeed as being
> internally equivalent, out of the concern that this would make it
> harder to write programs that need to view them as being distinct.

I understand this concern.  However, I don't think that it is an
issue for the case of the format directives.  That is because there
is no standard mechanism for users to define individual characters
as format dispatch arguments.  (All the extensions are of the form
/name/ instead).

Since there is no way for users to define ~<return>, defining it
won't interfere with user programs.  The only effect is to allow
this to work without an error.  The workaround, although simple,
does have the drawback that it relies on using internal structures
and thus should normally be avoided by users.

In other words, there shouldn't be any user programs that need to
distinguish between <return> and <linefeed> in the special case
where these are single character format directives.  It should
therefore be safe to make this modification, since I don't see
how it could possibly break any existing code.

Additional Serendipity:
It would also work for the DOS/Windows convention since the extra
line terminator would be considered whitespace and just skipped.

-Tom.¯

Thomas Russ, USC Information Sciences Institute          [email protected]