Mixed Metaphors (Was: Are Forth Chips RISCs?) 
Author Message
 Mixed Metaphors (Was: Are Forth Chips RISCs?)

Quote:
David Kastrup writes:
> In the letter referenced it was argued that stack printing words such
> as S. and similar constructs MUST have addressable stacks (implementation
> via PICK).
> Well, not necessarily. You can print one of the stacks by moving it piece
> for piece to the other stack, printing on the while. This is pretty
> inefficient, but if it is used only in debug words, who cares. In fact,
> I have seen implementations on Forth chips of PICK and ROLL which did
> just this ugly sort of thing.

Ugly is in the eye of the beholder :-).  Even before I began designing
Forth chips, I felt that directly addressing the stack was kludgy.
It is the programming equivalent of a mixed metaphor: a stack data
structure is treated as if it were an array.  Pure stack implementations
of PICK, etc. are elegant and, in the case of Forth chips, reasonably
efficient.

For anyone who is curious, here are PICK, ROLL and .S implemented using
only ANS Forth CORE words:

: pick   ?dup if swap >r 1- recurse r> swap else dup then ;
: roll   ?dup if swap >r 1- recurse r> swap then ;
: .s     depth if >r recurse r> dup . then ;

------------------------------------------------------------------------
        John R. Hayes
        Applied Physics Laboratory
        Johns Hopkins University



Sat, 03 Dec 1994 00:58:16 GMT  
 
 [ 1 post ] 

 Relevant Pages 

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

2. Am I missing something in forth!

3. I am new to Forth

4. i am new to forth

5. I am new to forth

6. I am new to forth

7. Repost: I am new to forth (found in comp.lang.c)

8. Are Forth Chips RISCs? (Was: Re: What should the Standard

9. Are Forth Chips RISCs? (Was: Re: What should the Standa

10. Are Forth Chips RISCs? (Was: Re: What should the Standard

11. Are Forth Chips RISCs? (Was: Re: What should the Standard include?)

12. BACUP meeting: Deep SM, mixed-sig, system-on-chip, SPECCTRA

 

 
Powered by phpBB® Forum Software