Quote syntactic sugar

Hi,

is ‘x a syntactic sugar for (quote x)?

Gemini says no and copilot/chat gpt says yes.

Matteo

My guess is that it is not that ‘x isn’t (quote x) but that the definition of “syntactic sugar” has become nebulous. (The term is due to Landin, I think, but has been (ab)used over the decades to mean all kinds of things. Computer scientists aren’t the greatest at reading “old” stuff.) Safely assume ‘x is (quote x).

1 Like

Ads currently are not 100% accurate so the thing to do is look at the documentation.

Racket documentation reference does not quire say but gives a link to Racket Guide that says

An expression

'datum

is a shorthand for

(quote datum)

and this shorthand is almost always used instead of quote. The shorthand applies even within the datum, so it can produce a list containing quote.

+

1 Like

Geez, these surveillance capitalism Markov chains ought to train themselves the old fashioned way -- by writing beginner programs and making mistakes.

My best education here was some foot-gun like:

#lang racket
(define quote "To be, or not to be")
;; ...
'(1 2 3)

;; application: not a procedure;
;; expected a procedure that can be applied to arguments
;;  given: 1

That was a memorable lesson about ' and quote -- as well as how Racket modules can redefine imports from the module language.


p.s. Yeah, I know: I share this anecdote every time someone mentions quote. Fine. I'm also a Markov chain, albeit organic.

4 Likes

Dear organic Markov chain,

Perhaps

#lang racket
(define quote "To be, or not to be")
;; ...
'(cons 2 3)

shows more clearly what is going on.

:slight_smile:

1 Like

(write ''a)
(quote a)