Like Joe said. I think that this "quote" behavior is a very practical
convenience that Scheme inherited, not something about which to hurt
one's brain trying to discern the underlying pure truths.
There are some confusing bits. For example:
#lang racket
(equal? (quote 1) 1) ;==> #t
(equal? (quote (quote 1)) (quote 1)) ;==> #f
This particular confusion, we can clarify or rationalize as "(quote
<NUMBER-LITERAL>)" being a very different thing than "(quote
<LIST-LITERAL>)". Which, as you said, could be seen as conflating.
Taking another look at the above quirk suggests "quote" having
simple-minded automagic to decide which of its multiple personalities
(number or list) is triggered:
(quote 1) ;==> 1
(quote (quote 1)) ;==> (quote (quote 1))
I don't know/recall how CL philosophizes about this. Emacs Lisp people
talked about syntax like numeric literals, "nil", and "t" being
``self-quoting.'' Scheme people tend talk about numeric literals being
``self-evaluating,'' but I don't see how that explains the quirk above.
If you can work out a clean formalism for the syntax/reader that avoids
quirks like these, yet still provides the list construction convenience
that permits non-list constants/self-evals elements without extra syntax
for quoting or unquoting them, I think that would be good.
As long as you're banging around in there, if you can also replace the
names "unquote" and "unquote-splicing" (which I believe are hardly ever
used literally in application code) with names/syntax that don't stomp
on the space of names application code might want to use in, say, quoted
or quasiquoteed embedded SXML, that would be even better. :) I wish
that RnRS had gotten rid of these at the same time that it blessedly got
rid of "nil" and "t". What currently makes more sense to me in Racket
is to move to "#unquote" and "#unquote-splicing" (or "#," and "#,@"),
keeping the same "," and ",@" shorthand. I suspect that changing to
those would be backward-compatible for 99.9% existing code outside of
Racket internals. I could be overlooking some case that makes that
change a bad idea, of course.
Joe Marshall wrote at 01/26/2011 05:17 PM:
On Wed, Jan 26, 2011 at 8:02 AM, J. Ian Johnson <i...@ccs.neu.edu> wrote:
I have a historical question about quoted constants. Does anyone know why '1 =
1? My intuition is that this is an artifact of conflating quote with list
constructors. Is that indeed the case?
I doubt it. More likely it was when someone realized that if (quote 1) is not
the number 1, then everyone would be confused. What else would it be?
--
http://www.neilvandyke.org/
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/dev