Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

quote

20 views
Skip to first unread message

none albert

unread,
Apr 29, 2022, 5:54:32 AM4/29/22
to
What with the superfluous parentheses with quote ?

Why
(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.

Groetjes Albert
--
"in our communism country Viet Nam, people are forced to be
alive and in the western country like US, people are free to
die from Covid 19 lol" duc ha
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

Siebe de Vos

unread,
Apr 29, 2022, 6:36:02 AM4/29/22
to
On 29/04/2022 11.54, albert wrote:
> What with the superfluous parentheses with quote ?
>
> Why
> (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.
>
> Groetjes Albert

What does (quote a) mean in your proposal:

'a

or

'(a)

none albert

unread,
Apr 29, 2022, 7:37:34 AM4/29/22
to
In article <t4gf2d$17mo$1...@gioia.aioe.org>,
You implicitly answered the question.
There would be no distinction between
(quote a) and (quote (a)) and I can see
that this is necessary.

Kaz Kylheku

unread,
Apr 29, 2022, 3:15:37 PM4/29/22
to
On 2022-04-29, albert@cherry.(none) (albert) <albert@cherry> wrote:
> What with the superfluous parentheses with quote ?
>
> Why
> (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.

Hi Albert.

The syntax of quote is actually

(quote expression)

The extra level of list nesting there comes from the expression being a
compound:

(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
handled.

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:

',@splice
(quote ,@splice)

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.

Cheers!

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Stefan Monnier

unread,
Apr 29, 2022, 4:46:34 PM4/29/22
to
> The syntax of quote is actually
>
> (quote expression)

Of course, it could have been

(quote . <expression>)

so that (quote a b c) indeed returns the value (a b c), but then you'd
need to write (quote . 42) to return the value 42.

> Quotes disappear at compile time. Extra nesting in a bit of
> compile-time syntax is nothing.

Indeed,


Stefan

steve g

unread,
Oct 24, 2022, 5:54:21 PM10/24/22
to
none wrote:

> What with the superfluous parentheses with quote ?
>
> Why
> (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.
>
> Groetjes Albert

The special form quote takes one argument.

CL-USER> (defmacro maybe-quote (itm)
(if (constantp itm) itm `',itm))
MAYBE-QUOTE
CL-USER> (maybe-quote 3)
3
CL-USER> (maybe-quote 4)
4
CL-USER> (maybe-quote this)
THIS
CL-USER> (maybe-quote this)
THIS
CL-USER>
; No value
CL-USER> (maybe-quote 'that)
THAT
CL-USER>
0 new messages