Re:If I were to invent a programming language for the 21st c...
by tonic-music on Saturday November 17, 2018 @05:25PM
(#18477677)
Indeed. The original description of Lisp included something like 10 primitives. That's it. Numerous examples of full-blown Lisps have been built from just those few primitives. One article I read even showed how arithmetic can be built from car and cdr.
[ Parent
| on HN ]
Re:If I were to invent a programming language for the 21st c...
by kazinator on Sunday November 18, 2018 @03:37AM
(#18479407)
But those full-blown Lisps have to have that full-blowness documented. It can't just be "here is the documentation for the ten primitives we used; to understand everything else, read the source".
It would be a bad doc if for every feature, it rambled on the details about how that feature is constructed out of the ten primitives, rather that specifying the relevant requirements for that feature.
Re:If I were to invent a programming language for the 21st c...
by colejohnson66 on Saturday November 17, 2018 @10:36PM
(#18478747)
Source? I’d love to read more about this
Re:If I were to invent a programming language for the 21st c...
by kungtotte on Sunday November 18, 2018 @08:13AM
(#18480202)
http://languagelog.ldc.upenn.edu/myl/llog/jmc.pdf The Roots of Lisp by Paul Graham.
Re:If I were to invent a programming language for the 21st c...
by AnaniasAnanas on Saturday November 17, 2018 @11:21PM
(#18478866)
Not car and cdr but close enough https://en.wikipedia.org/wiki/Church_encoding
Re:If I were to invent a programming language for the 21st c...
by Someone on Sunday November 18, 2018 @02:44AM
(#18479306)
Also, cons, car, and cdr need not be primitives. They can be built out of lambdas. In Scheme:
(define (cons x y)
(lambda (m) (m x y)))
(define (car z)
(z (lambda (p q) p)))
(define (cdr z)
(z (lambda (p q) q)))
(From https://mitpress.mit.edu/sites/default/files/sicp/full-text/..., exercise 2.4)
Re:If I were to invent a programming language for the 21st c...
by kazinator on Sunday November 18, 2018 @03:41AM
(#18479419)
Sure. Now to implement consp, all you need is a global list which tracks all lambdas that came from the cons function; if the argument object is eq to anything on that list, then it is a cons! We also now need another primitive: weak pointers. We don't want our global list to prevent otherwise unreferenced cells from being reclaimed.
typecase is going to be fun to develop and optimize, with everything being a lambda.