#breaking news (not really.). Hey, I only *just realised* this is a #commonLisp #quine #repl

`(,@-)

CL-USER> `(,@-)
(SI:QUASIQUOTE ((SI:UNQUOTE-SPLICE -)))
CL-USER> `(,@-)
(SI:QUASIQUOTE ((SI:UNQUOTE-SPLICE -)))
CL-USER> (SI:QUASIQUOTE ((SI:UNQUOTE-SPLICE -)))

or similarly,

CL-USER> ((lambda () -))
((LAMBDA () -))

#programming #fun

https://www.lispworks.com/documentation/HyperSpec/Body/v__.htm

CLHS: Variable -

Nice.

Just a stake, I think
((lambda (x) (x x)) (lambda (x) (x x)))
could be done with backquotes in Common Lisp or maybe Elisp.
Or something like that.
Don't trust me.

@screwlisp

@vnikolov I'm sure someone explained it to me before, but while it's trivial to write a macro that creates a quine:

CL-USER> (macrolet ((double (&body body) `'(,@body ,@body))) (double double))
(DOUBLE DOUBLE)

The problem is, I can't get that macrolet inside of the macrolet output without going via a string or something because of how commas (unquotes) work.

By definition, a quine has no normal form [late correction].
For a well-known example, a _single_ β-reduction of the (reducible) term
(λx.xx)(λx.xx)
yields itself.

Thus giving
((lambda (x) (x x)) (lambda (x) (x x)))
to Scheme doesn't terminate.
(Needs an `eval-1', maybe??)

Then
((lambda (x) (list x x)) (lambda (x) (list x x)))
works in Elisp (but obviously not Common Lisp) with lexical binding off.

Off the top of my head, I don't know how to do it with `macrolet'.

#Lisp
#Quines

@screwlisp

P.P.S.

Is this The Heart of Homoiconicity™?

A rare warranted use of `eval' (Elisp):

(let ((q '((lambda (x) (list x x)) (lambda (x) (list x x)))))
(equal q (eval q)))
=> t

after
(setq lexical-binding nil)
as needed.

#Elisp
#EmacsLisp
#Homoiconicity
#Lisp
#Quines

@screwlisp

@vnikolov @screwlisp

"Legitimate" if you think the Y combinator is a "legitimate" programming tool. :-)

I've only ever used it as a goof, with the side effect that the little joke makes people figure out that tail recursion and looping are really the same.

https://en.wikipedia.org/wiki/Fixed-point_combinator

Fixed-point combinator - Wikipedia

Hmmm...

What does "legitimate" refer to here?

As regards the Y combinator, I don't mind talking about it, or what it means for a programming tool to be legitimate, but at a low rate of posting replies, unfortunately.
It is a sizable topic in any case.

@weekend_editor @screwlisp

@vnikolov @screwlisp

Sorry, my mistake. You used the word 'warranted' and I mentally massaged that into 'legitimate'. My faux pas.

What I meant by warranted/legitimate was something like a tool that a reasonably advanced programmer would find useful, efficient, and clear. Some thing that would make it into instruction books, and into widely used libraries.

I can report from personal experience that Y combinators are none of those things. :-)

(Yeah, all that just so I could make a Y combinator joke. Is this the lispy equivalent of 'dad jokes'?)

P.S.
Regarding the Y combinator, apart from its theoretical importance (theory of algorithms, lambda calculus, combinatorial calculus, all distinct from computer programming), it has value for exercises, e.g. working out how it functions without being told.

To repeat after others, to work out on one's own how to construct an anonymous recursive function is good for one's mental fitness, rather than for writing library grade software.

@weekend_editor @screwlisp

@vnikolov @screwlisp

Oh, yes -- Y is absolutely wonderful for learning. Even more mind-bending is knowning there is an infinite family of fixpoint combinators, of which Y is the "least", i.e., makes the least committments necessary.

I still remember the first time I saw it. It was at the Lisp & Functional Programming Symposium in Pittsburgh, in 1982. (Though, looking at the talks below, I no longer recall exactly which one. Might even have been a historical overview given at dinner, instead of in the main proceedings.)

https://sigmod.org/publications/dblp////db/conf/lfp/lfp1982.html

LISP and Functional Programming 1982