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, LOTS_OF_MONEY,MSGID_RANDY 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: Ted Dennison Subject: Re: LLQ: -1 a valid boolean? Date: 2000/05/24 Message-ID: <8ggq7i$dad$1@nnrp1.deja.com>#1/1 X-Deja-AN: 626684924 References: <39253CD0.C8DC893D@telepath.com> <8g8o3b$9l0$1@nnrp1.deja.com> <8ge39b$g45$1@nnrp1.deja.com> <8gebvj$20i$1@hobbes2.crc.com> <8gfe1m$enu$1@nnrp1.deja.com> <0wOW4.27734$T41.665890@newsread1.prod.itd.earthlink.net> X-Http-Proxy: 1.0 x58.deja.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Wed May 24 14:50:32 2000 GMT X-MyDeja-Info: XMYDJUIDtedennison Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.7 [en] (WinNT; I) Date: 2000-05-24T00:00:00+00:00 List-Id: In article <0wOW4.27734$T41.665890@newsread1.prod.itd.earthlink.net>, "David C. Hoos, Sr." wrote: > > Robert Dewar wrote in message > news:8gfe1m$enu$1@nnrp1.deja.com... > > In article <8gebvj$20i$1@hobbes2.crc.com>, > > "David C. Hoos, Sr." wrote: > > > 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; > > > > But the return statement *obviously* would not work in this > > context, since we know that the value is abnormal! We can > > see why the if statement might in practice work, but for > > sure the return statement will not work (be sure to read > > the earlier messages in this thread, don't just examine > > the above code at face value!) > > > I certainly stand corrected if there was some earlier > definition of To_Bool_Ptr that would have enabled me to see > that "we know that the value is abnormal!" I had searched > for To_Bool_Ptr in my newsreader's comp.lang.ada messages, > and found no prior reference, so I (foolishly) assumed that > it was a function returning a not abnormal value. > > Then I suppose the fault is at least partially mine, for taking the easy way out and not including all the proper context information. It should have been more like: package Boolean_Ptr_Conversions is new System.Address_To_Access_Conversions (Boolean); Fortran_True : Integer := -1; Ada_Boolean : Boolean; ... if Boolean_Ptr_Conversions.To_Pointer(Fortran_True) then return True; else return False; end if; I figured that since Boolean'Size=1, then the check ought to work, even if assiging the value causes Constraint_Error. Oddly enough, even though my logic was faulty, in this instance I was right. But if the comparison itself is erronious, then this is not the way to do it. -- T.E.D. http://www.telepath.com/~dennison/Ted/TED.html Sent via Deja.com http://www.deja.com/ Before you buy.