Out of range values in

Bart van den Broek bart_van_den_broek at hotmail.com
Thu Apr 6 17:56:15 CEST 2006


> > If I (as an inactive observer) may comment / make a suggestion;
> > when a constant of ByteBoole, WordBoole or LongBoole is evaluated,
> > presumably at compile time, convert it to a value of type Boolean.
> > As a consequence:
> >   type VeryTrue = ByteBool (10) .. ByteBool (42);
> > means
> >   type VeryTrue = True..True;
> > Also, in the test program fjf1102, (Ord (a) = 1) and (Ord (b) = 1) and 
>(Ord
> > (c) = 1) holds, and more specifically Ord( ByteBool(42) ) = 1.
>
>Interesting idea, but if done only for constants (as I understand
>your suggestion), it would also lead to strange effects:
>
>program foo;
>
>var
>   n: Integer = 42;
>
>begin
>   WriteLn (ByteBool (n) = ByteBool (42))  { => False }
>end.

Since the Borland Delphi 3 Object Pascal Language Guide mentions:
"....Whenever a ByteBool, WordBool or LongBool  value is used in a context 
where a Boolean value is expected, the  compiler will automatically generate 
code that converts any nonzero  value to the value True."
If i interpret the expression ByteBool(n) = ByteBool(42) as "a context where 
a Boolean value is expected" then it is equivalent to (ByteBool(n) <> 0) = 
(ByteBool(42) <> 0), or (ByteBool(n) <> 0) = True, and foo would print True.

>Besides, it probably wouldn't be 100% Delphi compatible, as Delphi
>documentation (as quoted by Adriaan) states that Ord of "True" of
>such types can be any value <> 0.

Well, 1 is such a value <> 0, so how do u think it is incompatible?
I dont have Delphi available right now, but i vaguely remember Delphi does 
the following:
  ByteBool(True) = $FF
  WordBool(True) = $FFFF
  LongBool(True) = $FFFFFF
If so (will check later) then this means my suggestion is different and 
maybe incompatible.

I won't dwell on this further and am happy to see what you decide.

Bart.

>Frank
>
>







More information about the Gpc mailing list