[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gforth] If then else in interpreted mode
From: |
Josh Grams |
Subject: |
Re: [gforth] If then else in interpreted mode |
Date: |
Wed, 1 May 2013 18:48:58 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
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