3 ms·
> FORTH ... is almost "take the parenthesis out of your LISP program, reverse the order of the tokens, and... it works!" Strictly speaking, FORTH does not have
by zozbot234 6y ago
> FORTH ... is almost "take the parenthesis out of your LISP program, reverse the order of the tokens, and... it works!"
Strictly speaking, FORTH does not have a lambda syntax. But if you literally "reverse the order" of function application (while keeping lambda abstraction the same) in lambda calculus, you get De Bruijn notation which is rather more compelling than the LISP default, and also rather FORTH-like as you note. (Even moreso if variable names are replaced by De Bruijn indices.)
- MaxBarraclough 6y agoFor those like me who hadn't heard of De Bruijn notation, check out this PDF from Cornell. [0] I found the Wikipedia article pretty impenetrable, but no doubt it makes sense to a reader who already knows all about De Bruijn notation. [0] (PDF) https://www.cs.cornell.edu/courses/cs4110/2018fa/lectures/lecture15.pdf https://www.cs.cornell.edu/courses/cs4110/2018fa/lectures/le...
- PaulHoule 6y agoFORTH is very different from LISP but it's very similar in that you can use the quote operator to write control structures the same way you write any other function. Common LISP had CLOS that implemented object-oriented programming in a style not too different from Python, but as a library without compiler support and that was also true for late 1980s FORTH.
- ska 6y ago> but as a library without compiler support I'm not sure what you mean by this;As part of CL, CLOS always had compiler (and run time compiler) support. Many early OO systems were implemented in lisps, partially because they are flexible enough to add language features reasonably well, by default. See, e.g. Flavors, Loops. These predate CL and influenced the design of CLOS.
- dasyatidprime 6y agoCLOS generics+methods style is actually quite a different model in some ways from the Smalltalk-like model Python runs on! Primarily, method dispatch has the generic function primary and the classes secondary: methods are separately-definable specializations of what would otherwise be functions, rather than “owned” by a receiver object via its class. There was a recent item on Python versus CL: https://news.ycombinator.com/item?id=27011942 https://news.ycombinator.com/item?id=27011942
- kazinator 6y ago> can use the quote operator to write control structures The quote operator cannot be used for writing control structures in Lisp, unless we are referring to something you generally should not do in production code, like: (defun meta-circular-if (cond then else) (if (eval cond) (eval then) (eval else))) (meta-circular-if (quote (> 3 2)) (quote (+ 4 4)) 0) Quoting is nothing like referring to Forth words as data. When Forth code refers to a Forth word foo, that's more like (function foo) than (quote foo).
- a1369209993 6y ago> The quote operator cannot be used for writing control structures in Lisp I'm not sure this is what they had in mind, but I've actually done pretty much this when bootstrapping. Eg: (def (do-if cond) # actually a built-in, but defined this way (if cond id quote)) ((do-if tee) (foo)) # (id (foo)) ((do-if nil) (bar)) # (quote (bar))
- fmakunbound 6y agoThe Python object model is quite unlike CLOS.
- ethagnawl 6y agoI can't find a link to it at the moment, but Pierre de Lacaze gave an excellent talk about the CLOS/MOP systems at Lisp NYC about 5 years ago. If anyone is interested in these topics, I'd recommend digging around to see if you can find it.
- chalst 6y ago> Even moreso if variable names are replaced by De Bruijn indices. De Bruijn indices are not simply variable names: they vary dynamically depending where in the term (i.e. under how many binders) they occur, which is why beta reduction is so hairy with the De Bruijn notation.