[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Once again a plea for slash
- To: lisp-forum at MIT-MC, Scott.Fahlman at CMU-10A, GJS at MIT-AI, rwg at SU-AI, Fateman at Berkeley
- Subject: Re: Once again a plea for slash
- From: Guy.Steele at CMU-10A
- Date: Sun ,21 Dec 80 00:33:00 EDT
I am firmly convinced that the MacLISP-and-sons community would be
much better off if we were to change the "slash" character to something
other than "/". The sooner we do it, the better.
(1) Sussman and others report that the single greatest stumbling
block for novice LISP users trying to do numerical tasks is
remembering to double the "/" for the division operator. This
is the only operator of the four standard arithmetic operators
that does not have the same name used in almost every other
programming language ("+", "-", "*", "/").
(2) The "/" character is common in English text. It looks odd to have
to double it in error messages, etc. Have you ever written
(FORMAT T "~S got an I/O error." FOO)
only to get the error message
FROBBOZ got an IO error. ?
On the other hand, doesn't (FORMAT T "~S got an I//O error." FOO)
look awfully silly? (I observe that in a recent note KMP instead
wrote "I\O" for "I/O" to avoid this difficulty. I suspect this
usage looks strange to all except users of APL\360.
(3) I want to push for rational numbers as a standard part of LISP,
supported along with bignums and floating point, with appropriate
contagion rules and operations. An obvious syntax for a rational
number -- the *only* obvious syntax -- is <fixnum>/<fixnum>,
for example, 43/17. One might argue that this syntax could be
accommodated as an exception anyway, but it would be an awfully
kludgy exception.
(4) At least one operating system, UNIX, uses the "/" character
in pathnames. Other operating systems are likely to emulate
this, given the popularity of UNIX plus the lower-caseness of "/"!
For this reason, FRANZ LISP has used "\" as the quote character,
so that one may use file names like "/usr/gls/win.lsp" rather than
"//usr//gls//win.lsp".
For all these reasons, I propose that we switch -- and soon -- to "\"
as the standard character quoter. With the advent of " strings
and | symbols, I think you may be surprised at how few / characters
actually appear in code nowadays. This will ahve the following
repercussions:
(a) The name of the division function will be "/". (Actually,
I further propose that "/" be the universal *correct* division
operator, which floats (or uses rationals) if necessary to
give a correct result. For example, (/ 7 2) => 3.5. Then let
"//" be the one which produces integer results for integer
inputs (or maybe always produces an integer result??).
The name of remainder would change to "\\", and why don't we
just flush integer GCD, as it is seldom used?
(b) The #/ syntax would become #\. Following KMP's recent suggestion,
#\ could take on the burden of both #/ and #\.
(c) In other situations, / would become \ (for quoting characters).
So how about it, people? Maybe it's not worth changing MacLISP,
but I predict it would be a well worthwhile investment for LISPM, NIL,
and SPICE LISP.