3 ms·
Stack is cool as long as it's the top element or two that you care about. Anything more complex, and you want (well, I do) some sort of a binding syntax, so tha
by eequah9L 7y ago
Stack is cool as long as it's the top element or two that you care about. Anything more complex, and you want (well, I do) some sort of a binding syntax, so that it is possible to refer to the value symbolically. I find all those swaps and dups impossible to reason about.
- codr7 7y agoDup and Swap are all about the two top values though. Otherwise I strongly agree, I like to use bindings for anything non-obvious. In my own designs [0] I tend to add named arguments [1] as well, which helps a lot. [0] https://github.com/codr7/gfoo https://github.com/codr7/gfoo [1] https://github.com/codr7/gfoo#methods https://github.com/codr7/gfoo#methods
- yumaikas 7y agoI've found that there can be some cool stack combinators (like Factor's dip), but binding in stack based languages is nice in that it lets you effectively turn off having to think about the stack in depth, which frees up mental resources for thinking about the problem at hand.