gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gforth] the return stack necessity


From: Terrence Brannon
Subject: [gforth] the return stack necessity
Date: Sun, 7 Mar 2010 05:51:36 -0500

Re: 
http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Return-Stack-Tutorial.html

"""
Forth programmers usually use the return stack for storing data
temporarily, if using the data stack alone would be too complex, and
factoring and locals are not an option:

     : 2swap ( x1 x2 x3 x4 -- x3 x4 x1 x2 )
      rot >r rot r> ;
"""

(0) So Forth does not have lexical variables, similar to let in Lisp
or :> in Factor?

(1) I was able to use locals --

: my2swap { a b c d -- c d a b }
    c d a b ;

So I dont really think the tutorial example strongly exemplifies the
need for abusing the return stack.

(2) It seems like a form of hijacking to use the return stack for
temporary data. Why arent there arbitrary numbers of temporary stacks,
and/or associative structures like hashtables/property lists which
allow for temporary data storage?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]