comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@telepath.com>
Subject: Re: LLQ: -1 a valid boolean?
Date: 2000/05/24
Date: 2000-05-24T00:00:00+00:00	[thread overview]
Message-ID: <8ggq7i$dad$1@nnrp1.deja.com> (raw)
In-Reply-To: 0wOW4.27734$T41.665890@newsread1.prod.itd.earthlink.net

In article <0wOW4.27734$T41.665890@newsread1.prod.itd.earthlink.net>,
  "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> wrote:
>
> Robert Dewar <robert_dewar@my-deja.com> wrote in message
> news:8gfe1m$enu$1@nnrp1.deja.com...
> > In article <8gebvj$20i$1@hobbes2.crc.com>,
> >   "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> 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.




  reply	other threads:[~2000-05-24  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-19  0:00 LLQ: -1 a valid boolean? Ted Dennison
2000-05-19  0:00 ` Jeff Carter
2000-05-20  0:00   ` Ted Dennison
2000-05-21  0:00 ` Robert Dewar
2000-05-23  0:00   ` Ted Dennison
2000-05-23  0:00     ` David C. Hoos, Sr.
2000-05-24  0:00       ` Robert Dewar
2000-05-24  0:00         ` David C. Hoos, Sr.
2000-05-24  0:00           ` Ted Dennison [this message]
2000-05-24  0:00             ` Robert Dewar
2000-05-24  0:00           ` Robert Dewar
2000-05-23  0:00     ` Robert Dewar
2000-05-23  0:00       ` Ted Dennison
2000-05-23  0:00         ` Robert Dewar
2000-05-23  0:00           ` Ted Dennison
2000-05-24  0:00             ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox