Terrence,
You are doing good and helping Anton debug his documentation. It's not
often that anyone asks without just walking away. So thank you for not
giving up. ;)
Anything in comments ( ) is ignored by the compiler so the one after ENDCODE
can be ignored.
The default-code is any code you want to put there and the ( n ) comments
are ment to remind you that the number being used to check against is on top
of the stack and needs to be preserved.
: junk ( n -- ) case
1 of 1 . endof
2 of 2 . endof
dup .
endcase ;
Is a complete waste of space. It simply displays the top number on the
stack and each case ends up doing the same thing.
Does that help?
DaR
> -----Original Message-----
> From: [email protected] [mailto:gforth-
> [email protected]] On Behalf Of Terrence Brannon
> Sent: Saturday, March 06, 2010 2:55 PM
> To: [email protected]
> Subject: [gforth] CASE syntax?
>
> The documented CASE syntax:
> http://www.complang.tuwien.ac.at/forth/gforth/Docs-
> html/Selection.html#Selection
>
> terminates with
>
> ( n ) default-code ( n )
> ENDCASE ( )
>
> but I grepped the source tree and
> 1 - nowhere after default-code is ( n ) seen.
> 2 - nowhere after ENDCASE is ( ) seen.
>
> The best example I could find in the source tree was:
>
> : compil...@local ( n -- ) \ gforth compile-f-fetch-local
> case
> 0 of postpone f...@local0 endof
> 1 floats of postpone f...@local1 endof
> ( otherwise ) dup postpone f...@local# ,
> endcase ;
>
> And clearly there is no ( ) after ENDCASE.
>
> I cant say whether there is ( n ) after default-code because I am
> completely confused by this Forth code. It is far too advanced for me
> to understand completely.
>
> At any rate, I think a fully fleshed out simple example would be
> helpful to Neophyte FORTHers.