home .. forth .. colorforth mail list archive ..

Re: [colorforth] if then else - but why is there no ?else? in colorForth?


Quoting Albert van der Horst
<albert@xxxxxxxxxxxxxxxxxx>:

>... " 
>... " Chuck Moore wanted to have if a meaning by
>... " itself. The same for
>... " then.
>... " --
>... " Albert van der Horst, UTRECHT,THE NETHERLANDS

Nick here:  Interesting to learn that "if" without
'then' might not be a 'syntax error'.  I've just tried
it.  

         n : testif  -1 + -if -1 ; 

That gave -1 for all n.  I tried if then without ';'

     n  : testifthen  -1 +  -if -1  then 1 ;  

That gave 1 if n was positive, but for 0 or negative n
it gave -1 1 together.  Thus acting like 'if ... then
...' ?

Finally tried 'if then' with a ';' to separate them

    n  :  testif;then  -1 +  -if -1 ; then 1 ;  

The semicolon appeared also to separate the two cases, 
yielding 1 for n positive or -1 for 0 and negative n. 
Thus acting like "if ... else ... " ?        

Caritas,

Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: colorforth-unsubscribe@xxxxxxxxxxxxxxxxxx
For additional commands, e-mail: colorforth-help@xxxxxxxxxxxxxxxxxx
Main web page - http://www.colorforth.com