This page (revision-5) was last changed on 03-Feb-2023 15:21 by Carsten Strotmann 

This page was created on 08-Aug-2010 08:30 by Carsten Strotmann

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
5 03-Feb-2023 15:21 9 KB Carsten Strotmann to previous
4 08-Aug-2010 09:02 6 KB Carsten Strotmann to previous | to last
3 08-Aug-2010 08:46 5 KB Carsten Strotmann to previous | to last
2 08-Aug-2010 08:34 2 KB Carsten Strotmann to previous | to last
1 08-Aug-2010 08:30 2 KB Carsten Strotmann to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 68 changed one line
Figure 2a would look as shown in Figure 3. Let's add two more spoons of syntactic sugar, as in Figure 4. As has been noted elsewhere, too much syntactic sugar causes semantic diabetes. Our __case__ is sweet enough. Figure Five is an example to show some of the possibilities.
Figure 2b
{{{
craps(n)
int n;
{ switch(n) {
case 7, 11: printf("You win"); break;
case 2..3, 12: printf("You lose"); break;
default: printf("%d is you point",n);
}
}
}}}
At line 80 added 38 lines
Figure 3
{{{
: CASE DUP ;
: CRAPS ( n -- )
CASE 7 = IF DROP ." You win" EXIT THEN
CASE 11 = IF DROP ." You win" EXIT THEN
CASE 2 = IF DROP ." You lose" EXIT THEN
CASE 3 = IF DROP ." You lose" EXIT THEN
CASE 12 = IF DROP ." You lose" EXIT THEN
. . is your point" ;
}}}
Figure 2a would look as shown in Figure 3. Let's add two more spoons of syntactic sugar, as in Figure 4. As has been noted elsewhere, too much syntactic sugar causes semantic diabetes. Our __case__ is sweet enough. Figure 5 is an example to show some of the possibilities.
Figure 3
{{{
: OF ( n flag -- ) [COMPILE] IF COMPILE DROP ; IMMEDIATE
: =OR ( n flag n -- n flag ) 2 PICK = DROP ;
: CRAPS ( n -- )
CASE 7 = 11 =OR OF ." You win" EXIT THEN
CASE 2 3 BETWEEN 12 =OR OF ." You lose" EXIT THEN
. ." is your point" ;
}}}
Figure 4
{{{
: WHATEVER ( n -- )
CASE 0= OF ." zero" EXIT THEN
CASE 0< OF ." Negative" EXIT THEN
CASE DUP 1- AND 0= OF ." Power of 2" EXIT THEN
CASE ASCII 0 ASCII 9 BETWEEN OF ." Digit" EXIT THEN
CASE ASCII , ASCII / BETWEEN
ASCII : =OR OF ." Punctuation ,-./: " EXIT THEN
DROP ." Whatever" ;
}}}