🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.mac
Article #25826

Re: LSC: booleans != TRUE ??

#25826
From: Jim Cathey
Date: Wed, 02 Mar 1988 02:34
38 lines
2302 bytes
In article <7516@apple.Apple.Com> lsr@apple.UUCP (Larry Rosenstein) writes:
>In article <4097@husc6.harvard.edu> olson@endor.UUCP (Eric K. Olson) writes:
>>In a recent article Richard Siegel writes:
>>>
>>>In LightspeedC, TRUE is one and FALSE is zero. 
>>
>>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
>
>MPW Pascal uses 1 to mean TRUE and 0 for FALSE.  Inside Macintosh says that
>a BOOLEAN is represented in bit 0 (the low-order bit) of a byte.

However, it is my understanding that the Lisa Pascal compiler pushed _bytes_ 
on the stack for booleans.  A well-known fact about the 68000 is that it will
only push _words_ on the stack, even when you ask to push a byte.  Less
well-known is the fact that that word pushed will be byte-reversed!

Thus, when using a C compiler (whose minimum argument size is a word)
whenever you have to digest a boolean passed _from_ the toolbox you
will end up with a value of 256 for true and 0 for false since the C
compiler's code will only pop a word.  The Aztec C manual had a nice
little discussion about this, and recommended that you use the 'if
(fun())' and 'if (!fun())' method rather than 'if (fun()==TRUE)'.  

For added fun, the C convention is to use 1==TRUE, but if you have to
pass a boolean to the toolbox you can't use that since the toolbox
essentially uses 256 and 0!  Personally I prefer TRUE==(-1) and
FALSE==0, and never check explicitly for equality with either of these,
but use the fun() and !fun() method.  This gets me the best of both.

+----------------+
! II      CCCCCC !  Jim Cathey
! II  SSSSCC     !  ISC Systems Corp.
! II      CC     !  TAF-C8;  Spokane, WA  99220
! IISSSS  CC     !  UUCP: uunet!iscuva!jimc
! II      CCCCCC !  (509) 927-5757
+----------------+
			"With excitement like this, who is needing enemas?"
Technical Details
Message-ID: <1208@iscuva.ISCS.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!iscuva!jimc
References: <gW83I0y00WABsB40x9@andrew.cmu.edu> <4097@husc6.harvard.edu> <7516@apple.Apple.Com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!iscuva!jimc
From: jimc@iscuva.ISCS.COM (Jim Cathey)
Newsgroups: comp.sys.mac
Subject: Re: LSC: booleans != TRUE ??
Message-ID: <1208@iscuva.ISCS.COM>
Date: 2 Mar 88 02:34:48 GMT
References: <gW83I0y00WABsB40x9@andrew.cmu.edu> <4097@husc6.harvard.edu> <7516@apple.Apple.Com>
Organization: ISC Systems Corporation, Spokane, WA
Lines: 38