Sorry I'm late to the party guys, my net access is sporadic here. Zed A. Shaw wrote: > However, that's not a very clear rule I can follow since add does what > push does but leaves things on the stack. Choose one or the other and > make a succinct rule I can follow so it's less cognitive burden to work > in the language. > add and push are different in an important way; push modifies its input, whereas add returns a new sequence. Since push does not construct anything new, it does not return anything on the stack. add constructs a new sequence, and so it outputs it on the stack.
As others have said, words do not return their inputs, except shuffle words. > It's the last part after OR that creates the inconsistency and > annoyance for no explained advantage other than "that's just how it is". > The advantage is that you don't accidentally believe that 'push' returns a new sequence (this makes a big difference). Another thing that might help is to remember that most words which are side-effecting have a non-side-effecting equivalent. push add push-all append reverse-here reverse change-each map etc. > As a programmer it tends to not matter how things are, so long as they > are explained clearly and I get a decent reason that doesn't make me > scream "bullshit". If the rule's #2 then that's the rule, but I > haven't seen any "standard stack protocol design guide" yet. > Let's write one :-) Also, check out http://www.cs.rit.edu/usr/local/doc/gforth/Designing-the-stack-effect-Tutorial.html#Designing%20the%20stack%20effect%20Tutorial Have fun, Slava ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
