From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6da15369b6c53c77 X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: LLQ: -1 a valid boolean? Date: 2000/05/23 Message-ID: <8gebvj$20i$1@hobbes2.crc.com>#1/1 X-Deja-AN: 626346055 References: <39253CD0.C8DC893D@telepath.com> <8g8o3b$9l0$1@nnrp1.deja.com> <8ge39b$g45$1@nnrp1.deja.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@crc.com X-Trace: hobbes2.crc.com 959099699 2066 198.175.145.56 (23 May 2000 16:34:59 GMT) Organization: CRC: A wholly owned subsidiary of Thermo Electron NNTP-Posting-Date: 23 May 2000 16:34:59 GMT Newsgroups: comp.lang.ada Date: 2000-05-23T16:34:59+00:00 List-Id: return To_Bool_Ptr(Addr).all; might look a little less "silly" than if To_Bool_Ptr(Addr).all then return True; else return False; end if; Ted Dennison wrote in message news:8ge39b$g45$1@nnrp1.deja.com... > In article <8g8o3b$9l0$1@nnrp1.deja.com>, > Robert Dewar wrote: > > In article <39253CD0.C8DC893D@telepath.com>, > > Ted Dennison wrote: > > > You'd think that a value that is legal in situ ought to be > > > legal to assign as well. Then again, if Ada_Boolean'Size = 8 > > > or 32 or something, then I can see where one might argue that > > > a value of -1 (all bits set) is out of range of the possible > > > Boolean values, and thus should raise > > > Constraint_Error. > > > > > > So what's right? > > > > Not only is the compiler's behavior conforming, it is actually > > what one would expect, given that you most certainly expect > > that boolean objects have a size of 8 (the choice of a size > > of 1 for boolean objects is typically impractical on most > > architectures due to the task indepedence requirement). > > > > Your code is just wrong here, and you are going to have to > > deal with these booleans in a completely different manner. > > That's what I was afraid of. > > > If your compiler implements Interfaces.Fortran, then everything > > should be fine, since the type Logical should work properly. > > Except that sometimes the value comes from a Fortran program, and > sometimes it comes from a C program. > > I just ended up doing the following, which looks damn silly (so I had > to comment it copiously), but works: > > if To_Bool_Ptr(Addr).all then > return True; > else > return False; > end if; > > -- > T.E.D. > > http://www.telepath.com/~dennison/Ted/TED.html > > > Sent via Deja.com http://www.deja.com/ > Before you buy.