On 2022-04-29, albert@cherry.(none) (albert) <albert@cherry> wrote:
> What with the superfluous parentheses with quote ?
> (quote (a b c ))
> in stead of
> (quote a b c ) ?
> After all quote is a special function, it decides for itself
> whether the arguments are evaluated.
The syntax of quote is actually
The extra level of list nesting there comes from the expression being a
(quote (list 1 2 3)) -> (list 1 2 3)
It doesn't have to be a compound:
(quote a) -> a ;; quote a symbol
Given that expression can be anything, it follows that quote must
support (quote (a b c)).
So there is the possibility that quote could *also* support
(quote a b c) as a shorthand for (quote (a b c)).
But that would only complicate every single situation in which a piece
of syntax must be analyzed; both representations would have to be
So then we could also think about banishing (quote (a b c)) and
requiring it that the representation of that must be (quote a b c). But
then, because lists can sometimes be one element long, what do you do
with (quote (a))? If that is required to be written (quote a), then you
have confusion with quoting a symbol.
Then there are other considerations. Consider the backquote.
What if you have this:
`(.... (quote ,@splice))
If the splice variable happens to contain the list (a), we get
(quote a), which means quote the a symbol.
If it contains (a b c) we get (quote a b c), which means
(quote (a b c)). Yikes; the shape of the run-time value being spliced
determines the meaning of the code being generated.
Currentg backquote implementations will diagnose the istuation
when two or more elements are spliced into quote form.
If you have splice under a quote:
and splice does not evaluate to a list of exactly one elements, the
backquote implementation will somehow diagnose it. (Possibly
by just generating the bad quote and letting the quote operator
diagnose it, or by itself recognizing the bad quote, since
the backquote expander does have to walk and understand quotes.)
Lastly, there is no utility whatsoever in trying to reduce the
list shape of the quote syntax to a less nested form, because
there is already a read syntax which hides it: '(a b c)!
Quotes disappear at compile time. Extra nesting in a bit of
compile-time syntax is nothing.
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal