in reply to Double your return!!!!

There's a paper on continuations here. It mentions Scheme, which is where I recall hearing of these sorts of things. I haven't programmed Scheme, but my rather weak understanding of continuations is that they're similar to C's setjmp/longjmp except that you can longjmp back to a location even if it's in a function that's already returned. I think Forth also has the ability to alter the calling stack in a way that does this sort of thing but I may be wrong.

Here's another interesting read that should make your head hurt a little.

Replies are listed 'Best First'.
Double your return, In forth!
by xmath (Hermit) on Feb 19, 2003 at 08:24 UTC
    FORTH can do it indeed, by manipulating the return stack directly. For example:

    : foo ( -- ) ." enter foo" cr rdrop exit ." exit foo" cr ; : bar ( -- ) ." enter bar" cr foo ." exit bar" cr ; : baz ( -- ) ." enter baz" cr bar ." exit baz" cr ;
    gives the output:
    enter baz enter bar enter foo exit baz
    If your forth doesn't have rdrop, use r> drop or define it with: : rdrop r> r> drop >r ;

    I also strongly recall having seen words specifically for this purpose, but I can't find one in this forth (maybe they left it out in modern implementations)

Re: Re: Double your return!!!!
by bsb (Priest) on Feb 19, 2003 at 05:39 UTC
    The ;=) operator should've given it away.