Re:Masterminds of Programming: Chuck Moore (2009)
by quantified on Sunday January 05, 2020 @08:57PM
(#21965796)
I would like to find the motivated time to analyze how Forth and lambda-calculus functional languages compare/connect. Each Forth word seems to be effectively a lambda that must be connected to a correctly-typed stack, and words can themselves manipulate the stack as its own structure.
[ Parent
| on HN ]
Re:Masterminds of Programming: Chuck Moore (2009)
by thesz on Monday January 06, 2020 @05:31PM
(#21974206)
It is relatively easy.
You can look at stack as a list:
type Stack = [Int]
Adding two values at top of stack is easy:
add (a:b:stk) = (a+b) : stk
Dropping and duping is also easy:
drop (_:stk) = stk dup (x:stk) = x:x:stk
double stk = add (dup stk)
You can encode list using Church encoding [1] and voila! You just connected lambda calculus and stack machine (not Forth, but close).
[1] https://en.wikipedia.org/wiki/Church_encoding#List_encodings
Forth include more that just stack machine - return stack, vocabulary, definintions, memory, etc. This means that these simple definitions will not be as simple as above for complete Forth. But they also can be represented as Church encoded data and they still be representable in lambda calculus.
Re:Masterminds of Programming: Chuck Moore (2009)
by kragen on Monday January 06, 2020 @01:07AM
(#21966906)
Manfred van Thun’s Joy, Christopher Diggins’s Cat, Henry Baker’s Linear Lisp.
Re:Masterminds of Programming: Chuck Moore (2009)
by quantified on Monday January 06, 2020 @11:56AM
(#21970671)
Thanks for the pointers!