wOVERd and wUNDERd (Was: PLUCK and THIRD) 
Author Message
 wOVERd and wUNDERd (Was: PLUCK and THIRD)

In the 1980s, wOVERd and wUNDERd were designed to handle functions with
many parameters, local variables, local arrays, and local strings.
Local naming could be done.

In the simplest case:

    : GCD  
        0  { m n rmdr }
        BEGIN  n WHILE
            m n MOD -> rmdr
            n -> m
            rmdr -> n
        REPEAT
        RETURN m ;

"{ ... }" does local naming of stack elements.
"RETURN ... ;" does 0 or more "OVERd", ending with "wDROPn ;".
Unnamed stack elements are shown by lonely ".".

This compiles to:

    : GCD  
        0
        BEGIN  over1 WHILE
            2over1 MOD under0
            over1 under2
            over0 under1
        REPEAT
        over2 3drop1 ;

Equivalent to:

    : GCD  
        0
        BEGIN  over WHILE
            2over1 MOD NIP
            over under2
            dup under
        over2 3drop1 ;

Local variables are done by giving their initial value.

When local arrays and local strings are used, FUNCTION must occur
after the function-name.  FUNCTION does "HERE >R" and sets a switch so
";" does "R> HERE - ALLOT ;".

Local arrays are declared "HERE n CELLS ALLOT".

Local strings are declared "HERE n chars ALLOT".

Referencing a local name does "OVERd".

"->" before a local name becomes "UNDERd".

Functions can't be CREATE-words, but may be used after "DOES>".

In the body of a function, SWAP is only used before an operator to
change the order of its arguments. DROP or NIP may be used after an
operator to make it single-valued.  A line-break followed by a line
of equal or less indentation affirms that all "OVERd"s have been
consumed.  Other stack operatore are not used.

--
Neil Bawd - Goat Hill, California



Sun, 10 Apr 2005 08:41:03 GMT  
 wOVERd and wUNDERd (Was: PLUCK and THIRD)
I can say "wOVERd" and "wUNDERd" but I'm going to have to
practise to be able to say "wDROPn". :-)

Seriously, I enjoy these words!

-- David



Sun, 10 Apr 2005 22:59:07 GMT  
 wOVERd and wUNDERd (Was: PLUCK and THIRD)

1opposed1 to 2word2 for 3reason1 of 3readability1.

[Above, the 1st digit denotes the person (I, you, they),
while the 2nd digit denotes the number (one, many).]

1think1 that this 1English1 is equally readable as 2Forth1.

That is, both are ugly.



Tue, 12 Apr 2005 05:50:46 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PLUCK vs THIRD

2. a name for PLUCK PLUCK

3. Pluck Specific Headers /reassemble on one line.

4. Plucking images from a stream at fixed rate.

5. I am not deaf, but am I mute?

6. Third Parties

7. A third solution

8. APL: the third choice

9. Third party software: Smalltalk / Java

10. the third choice

11. Comparing 2 files to create a third file

12. Merge 2 files into third

 

 
Powered by phpBB® Forum Software