Appendix to https://softwareengineering.stackexchange.com/a/418149/61264: Postfix stack languages
Point-free style is the default in "concatenative" programming languages like FORTH and PostScript. And, since they use postfix order, with function argument coming before the function, simulating "let" should be easy, right?
Funnily, there are no named-arg lambdas in most of these languages*. Not even the modern Factor (supports named arguments for named functions, but not in anonymous "quotations").
But FORTH and PostScript do have ways to simulate local variables. So we can show the equivalence the other way around: implement "let", then implement "lambda" in terms of "let" 😁.
- EDIT: I'm wrong, Factor has
[| var | body ]
lambdas as well as mid-quotation bindings[ ... value :> var ... ]
. It seems[let
is just same as[
except it immediately executes the quotation! https://docs.factorcode.org/content/article-locals-examples.html
Or clone this, and run ghostscript named-locals-let-lambda.ps
Output:
(xxyyxxyy)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
(goo of foo of Hello!)
PS<SSSSSSSSS>