On 2013-05-02 12:57AM, Marcos Cruz wrote:
>On 2013-05-01 23:15, John Allsup wrote :
>>
>>     : jif 0 = if 0 else 1 then ;
>
>A simpler alternative:
>
>       : jyf 0<> abs ;

Yikes!  How about:

        : jif 0<> 1 and ;

>Usually in Forth a calculation can be used instead of a condition.

Well, that's true in a lot of languages, it's just that most other
language communities condemn it as bad style, and it's more acceptable in
the Forth culture.

I will sometimes AND a value with a flag, giving the value or zero.
Beyond that I usually find them hard to read, so I avoid them.

But then I'm not doing tiny embedded stuff, so I don't have any
situations where I consider those kinds of tiny CPU-time savings to be
worth the extra programmer time writing and maintaining the code.

YMMV, etc.

--Josh

Reply via email to