🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #25521

Re: LSC: booleans != TRUE ??

#25521
From: Eric K. Olson
Date: Mon, 22 Feb 1988 15:28
38 lines
1722 bytes
In a recent article Richard Siegel writes:
[In reply to a question about why a comparision of a Boolean didn't work]
>The macro definitions for TRUE and FALSE are in <MacTypes.h>. Be sure you're 
>including it. Do a multiple-file search and be CERTAIN you're not changing 
>macros.
>
>In LightspeedC, TRUE is one and FALSE is zero. 

The original question contained a statement like:

	if (functionreturningboolean()==TRUE) ...

If memory serves me correctly, portions of the Mac OS use the highest
order (sign) bit for the state of a Boolean, a Pascalism, I think (forgive
me if this isn't quite exact).  I prefer to define TRUE as -1 for this
reason, so that the Mac won't be confused when I pass it a Boolean.

A safe assumption is that FALSE==0, both in C and in Mac.  I use 0L and
it gets coerced to a short in most cases.

But you shouldn't compare a Boolean anyway.  The statement above can
be replaced by:

	if (functionreturningboolean()) ...

or

	if (!functionreturingboolean()) ...

instead of

	if (functionreturningboolean()==FALSE) ...

-Eric

	    "We're writing tomorrow's software yesterday."
Eric K. Olson     olson@endor.harvard.edu     harvard!endor!olson     D0760
   (Name)                (ArpaNet)                 (UseNet)        (AppleLink)
Technical Details
Message-ID: <4097@husc6.harvard.edu>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olson
References: <gW83I0y00WABsB40x9@andrew.cmu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!endor!olson
From: olson@endor.harvard.edu (Eric K. Olson)
Newsgroups: comp.sys.mac
Subject: Re: LSC: booleans != TRUE ??
Message-ID: <4097@husc6.harvard.edu>
Date: 22 Feb 88 15:28:19 GMT
References: <gW83I0y00WABsB40x9@andrew.cmu.edu>
Sender: news@husc6.harvard.edu
Reply-To: olson@endor.UUCP (Eric K. Olson)
Organization: Lexington Software Design, Lexington, MA
Lines: 38