Skip to content

Instantly share code, notes, and snippets.

@pbaille
Last active May 12, 2021 15:21
Show Gist options
  • Save pbaille/4ad9a974d0f37e544ba787dc19743ab3 to your computer and use it in GitHub Desktop.
Save pbaille/4ad9a974d0f37e544ba787dc19743ab3 to your computer and use it in GitHub Desktop.
#lisp IRC discution about quote and quasiquote
I'm wondering if a lisp can have only quasiquote and no regular quote. What would be the downsides ? (sorry if this message appears for the second time, I can't tell if it was posted or not)
beach
Do you mean "no reader macro '", or "no special operator QUOTE"?
_death
`(foo ',bar).. you don't need either of course, (list (quote foo) (list (quote quote) bar))
beach
I think the former is definitely possible. Not so much the latter.
phoe
pbaille: a quasiquote without any unquotes inside is equivalent to a regular quote
jackdaniel
mind that quasiquote may allocate new data (hence it is not equivalent, vide ^)
lukego
pbaille: Guessing that's fine provided that you use (QUOTE x) instead of 'x. But if you plan to use quasiquote instead of
quote it will become confusing in certain kinds of code that uses nested quote/quasiquote e.g. `(foo ',(...)) because more quasiquotes means more levels of unquoting
pbaille
yes it is equivalent but why the regular quote is needed , if it is a subset of quasiquote ?
jackdaniel
quote is a special operator in common lisp
jackdaniel
quasiquote is a reader syntactic sugar (i.e not a special operator)
phoe
pbaille: because quasiquote is expressed in terms of quote in CL
phoe
if you wanted to avoid this, you'd need to have quasiquote as a special operator of sorts, likely along with unquote
jackdaniel
also I think that the proper name is backquote
pbaille
Yes I understand, but if someone was creating a new dialect of lisp that only has quasiquote it would be acceptable ?
phoe
pbaille: I guess so, yeah
phoe
jackdaniel: yes, thanks
pbaille
quasiquote is maybe the name in scheme literature
beach
pbaille: You still haven't answered my question, because the answer to yours depends on it.
phoe
yes, CLHS uses backquote whereas e.g. Racket docs call it quasiquote
pbaille
beach: I'm sorry I was a bit distracted, I was meaning no special operator QUOTE
beach
pbaille: Then the answer is that you can't do without it, as lukego pointed out.
phoe
pbaille: if you have nothing else that you can replace QUOTE with then you're toast
pbaille
(I'm not a CL person (I came from clojure) so I may not understand all CL sutleties)
phoe
basically, you need some means of preventing standard evaluation rules from kicking in
phoe
regardless of whether it's special operator QUOTE or special operator BACKQUOTE
phoe
where "special operator", in CL-speech, means "an operator that does not obey standard evaluation rules and also is not a
macro"
phoe
basically, you need some primitive that will fulfill the role that CL:QUOTE fulfills in standard CL
phoe
if your backquote is such an operator, then bingo, you can implement QUOTE in terms of it
(though it would be kinda backwards)
jackdaniel
if you implement a "new dialect of lisp" then you don't need quote because you are designing a new programming language
with its own evaluation rules
but you need a PR team that will argue on reddit that your new dialect of lisp is a lisp :-)
(public relations, not pull request)
pbaille
jackdaniel: haha yes I see !
pbaille
phoe: thank you for the details
lukego
pbaille: I think that for some kinds of code you would miss having ' e.g. in macro-writing macros or html-writing macros and such. The simplest example I can think of it (let ((arg 'quote-me)) `(f ',arg)) => (F 'QUOTE-ME). here you want to preserve the quote inside the backquote while unquoting its argument. If you used two backquotes it would be... different.
pbaille
I was studying this dialect of lisp (which maybe isn't one): https://convex.world/documentation/tutorial
lukego
pbaille: I'm taking your question in the spirit of, "Is quote just there for historical reasons and obsolete with respect to quasiquote?" and the answer to that in practice is no, you want to use both in real programs.
pbaille
lukego: yes I understand, nice point.
pbaille
lukego: Your interpretation of my question is correct
lukego
pbaille: I vaguely remember wondering the same thing and being surprised at how useful plain ol' quote turns out to be :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment