Re:Writing a Forth in Haskell
by lacampbell on Friday June 09, 2017 @08:32AM
(#14520896)
I had this dumb idea of actually evaluating LISP in a forth inspired way. It would be a stack of subroutine/accumulator pairs. so given
(+ 1 2 3)
"(" would pop an pair on a stack, + would set its subroutine, and 1 2 3 would be fed to the subroutine and accumulate a value. when ) is encountered, the data is fed into the subroutine/accumulator pair lower on the stack, so you could still have nesting.Horribly inefficient, but I thought the idea was neat. I'm sure I'm not the first to think of it though.
some antique famous lisper (Henry .. forgot last name) did write a linear lisp that works by stack evaluation. From the few that I grasped, since everything is mostly duped, it's like a new value each time; free borrowing ?
Re:Writing a Forth in Haskell
by evincarofautumn on Friday June 09, 2017 @07:48PM
(#14525411)
Higher-level concatenative languages like Factor do feel somewhat Lisp-like because most code is structured with quotations and combinators. But typical Forth isn’t very much like typical Factor or Joy at all, even though they’re all nominally concatenative.
(ANSI) Lisp function calls are safe w.r.t. wrong number of arguments, and support optional and variadic arguments also. This is true of compiled code without source: when we load someone's compiled file and call a function in it with the wrong number of arguments, it is diagnosed.
Forth and Lisp are so miles apart, that I have to scratch my head why a comparison comes up in discussion from time to time.
(It is pretty much always from someone who uses Forth and doesn't know Lisp (or, worse, anything that isn't Forth). "Hey, I heard Lisp is also interactive and meta-programmable, so it must just be a Forth with postfix switched to prefix and parentheses added ...").