[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [gforth] CASE syntax?
From: |
Dennis Ruffer |
Subject: |
RE: [gforth] CASE syntax? |
Date: |
Sat, 6 Mar 2010 15:15:18 -0800 |
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: address@hidden [mailto:gforth-
> address@hidden On Behalf Of Terrence Brannon
> Sent: Saturday, March 06, 2010 2:55 PM
> To: address@hidden
> 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:
>
> : address@hidden ( n -- ) \ gforth compile-f-fetch-local
> case
> 0 of postpone address@hidden endof
> 1 floats of postpone address@hidden endof
> ( otherwise ) dup postpone address@hidden ,
> 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.