comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: LLQ: -1 a valid boolean?
Date: 2000/05/23
Date: 2000-05-23T16:34:59+00:00	[thread overview]
Message-ID: <8gebvj$20i$1@hobbes2.crc.com> (raw)
In-Reply-To: 8ge39b$g45$1@nnrp1.deja.com

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 <dennison@telepath.com> wrote in message
news:8ge39b$g45$1@nnrp1.deja.com...
> In article <8g8o3b$9l0$1@nnrp1.deja.com>,
>   Robert Dewar <robert_dewar@my-deja.com> wrote:
> > In article <39253CD0.C8DC893D@telepath.com>,
> >   Ted Dennison <dennison@telepath.com> 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.






  reply	other threads:[~2000-05-23  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. [this message]
2000-05-24  0:00       ` Robert Dewar
2000-05-24  0:00         ` David C. Hoos, Sr.
2000-05-24  0:00           ` Ted Dennison
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