Hello Michael,

Let's add one important case to your fine collection.
Here is .s implementation in openfirmware/forth/kernel/kernel.fth:

: (.s        (s -- )
   depth 0 ?do  depth i - 1- pick n.  loop
;
: .s         (s -- )
   depth 0<
   if   ." Stack Underflow "  sp0 @ sp!
   else depth
        if (.s else ." Empty " then
   then
;

Using the usual "stack picture" (of-course).  Since only Matthias has
commit rights, it's his call. I don't suggest to fork over this issue
though :-)

Regards, Enoch.


"Michael Kalus" <mi-ka...@t-online.de>
writes:

> Hi.
> Lets take a look at some common Forths, Revision appended.
> They do it in the typed order left to right.
> Only VFX does it top down linewise, like amforth in its older days.
> Though not a "standard", typed order is "Normative Kraft des  
> Faktischen".
> (google: "normative power of the factual")
>
> Brodies I like best. Unfortunately he does not tell us how the  
> negative numbers are treated.
>
> Regards, Michael
> :-)
>
> -
> Revision of Examples
>
> gforth:
> 11 -22 33 .s <3> 11 -22 33  ok
>
>
> win32forth:
> 11 -22 33 .s [3] 11 -22 33  ok...
> (with a dot for each item, none if empty stack)
>
>
> VFX Forth for Windows IA32:
> 11 -22 33 .s
> DATA STACK
>       top
>               33 0000:0021
>              -22 FFFF:FFEA
>               11 0000:000B
>   ok-3
>
>
> SwiftX MSP430 EVALUATION 3.5.9 12-Apr-2011:
> 11 -22 33 .s
> 11 -22 33 <-Top  ok
>
>
> And last but not least, the Masters Voice:
> Starting Forth by Leo Brodie - Chapter 2
> http://www.forth.com/starting-forth/sf2/sf2.html
>
> <snip>
> A Handy Hint
> A Non-destructive Stack Print
>
> Beginners who are just learning to manipulate numbers on the stack in  
> useful ways very often find themselves typing a series of dots to see  
> what's on the stack after their manipulations. The problem with dots,  
> though, is that they don't leave the numbers on the stack for future  
> manipulation.
>
> The Forth word .S prints out all the values that happen to be on the  
> stack "non-destructively"; that is, without removing them. Let's test  
> it, first with nothing on the stack:
>
> .S <0>  ok
>
> As you can see, in this version of .S, we see at least one number.  
> This is the number of items actually on the stack.
>
> Now let's try with numbers on the stack:
>
> 1 2 3 .S <3> 1 2 3  ok
>
> ROT .S <3> 2 3 1  ok
> </snip>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to