[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: #\EOF ... Yes, again.
- Subject: Re: #\EOF ... Yes, again.
- From: Kent M. Pitman <KMP at MIT-MC>
- Date: Thu ,25 Sep 80 23:00:00 EDT
Well, I am somewhat encouraged that I spoke with DLW today offline and
he thought he might be swayed so I'll lay this out clearly again once
more, squashing the arguments I have heard:
Argument: #\ should return only representations of characters.
Answer: So should TYI and TYIPEEK. Over time, however, we have found it
useful, especially when dealing with compiler optimizations related
to fixpdls, to return an eof designator, -1. If it's good enough
for TYI and TYIPEEK, it's good enough for me.
Argument: All TYI's and TYIPEEK's return -1 at eof; why not just use that?
Answer: (1) All TYI's and TYIPEEK's return #o101 for "A" being typed, but
#/A was thought to be more readable.
(2) If people change the representation of characters, as the
LispM people have found it useful to do, negative numbers might
want to acquire an interpretation as characters. Do you want
to break code that does (TYI STREAM -1) and which will then
perhaps perceive a premature end of file.
(3) No manual for any existing Lisp documents that -1 is not a
part of the possible character set. Nor does any manual document
that TYI returns -1 at end of file. The fact that it just happens
to annoys me. I want a documented standard.
Argument: Why not do (SETQ EOF -1) and reference #.EOF instead of #\EOF.
Answer: (1) #.EOF doesn't supply visually as much info as #\EOF.
(2) It's maybe now easy but unless conventions are adopted, I
don't see any reason why it won't degenerate, over the years,
into:
(SETQ EOF #+LISPM SI:EOF-REPRESENTATION
#+NIL *:EOF-FIXNUM
#+MACLISP -1)
or something silly like that. Saying DEFCONST instead of
SETQ doesn't make it any less awful. The annoying part is
having system dependencies at all.
The bottom line:
It is annoying to have this supposed abstraction which frees me of
the `representation' specifics of my characters. If I type #/A, I
should have to know only that it is going to return a fixnum which is
the same fixnum as will be returned by TYI'ing an "A". Similarly, I
need to be able to say #\EOF and know that this is the same fixnum,
whatever it is, that will be returned by TYI'ing an eof. If you don't
grant this, then you require me to always know *some* information about
the mapping from characters to fixnums. I have to know the shape of the
set of valid characters so I can choose a character that's not in it.
I claim that if you have an abstraction which is 98% complete, then you
haven't really bought yourself anything. Going this extra 2% will buy
you an elegant bit of insulation from your character set and move you
closer to the goal of robust code that is not bothered by trivial
implementational details.
-kmp