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

[ColorForth] Equality


How about

dup 5 xor -if 5thing ; then
etc.

Alex

On Thursday 20 June 2002 13:22, Richard Collins wrote:
> I feel like an idiot asking this. But here goes anyway.
>
> How does one get by without an equals operator. I want to say something
> like this:
>
> 5 5 eq if 5thing then ;
>
> I could rearrange it to:
>
> 5 5 xor if ; then 5thing ;
>
> But this seems like too much of a fudge, particularily because what I
> really want to do is more like,
>
> : things
>
> dup 5 eq if 5thing ; then
> dup 11 eq if 11thing ; then
> dup 38 eq if 38 thing ; then
> drop otherthing ;
>
> which becomes
>
> : things
>
> dup 5 xor if
>     dup 11 xor if
>         dup 38 xor if drop otherthing  ; then 38thing ;
>     then 11thing ;
> then 5thing ;
>
> Defining eq as
>
> : eq xor - drop ;
>
> doesn't work as - doesn't affect the pentiums flags.
>
> My last resort is to define a new 'if', 'if0' which jumps forward to the
> next 'then' when the zero flag is not set, instead of when it is set, which
> is how 'if' works. This would not be hard, but I can't help but think that
> if it was needed, Chuck would have put it there.
>
> I'll be grateful for any advice. I suspect I am approaching things from the
> wrong angle.
>
> Thanks, Richard Collins
> ------------------------
>
> To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx
> with: unsubscribe ColorForth
> as the first and only line within the message body
> Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
> Main ColorForth site   -   http://www.colorforth.com
------------------------

To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems   -   List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site   -   http://www.colorforth.com