Const conflict. Was: Re: New Alpha

Wed, 23 Apr 1997 22:48:26 +0200


Peter Gerwinski wrote:
> =

> According to Frank Heckenbach:
> > [...]
> > However, the following still doesn't work (if it's already/still on t=
he bug
> > list, please ignore):
> >
> > PROGRAM x;
> > CONST n:1..16=3D6; {"subrange bounds are not of the same type"}
> > BEGIN
> > END.
> =

> Is this really a bug???  Extended Pascal allows expressions as the uppe=
r
> bound of a subrange.  In this case, the expresson "16 =3D 6" (with the
> Boolean value "false") is the upper bound - which is indeed not of the
> same type as the lower bound "1".

Its not that easy to tell what your code means, not even for people, =

Franks intention is easily interpreted in the way Peter does and then =

of course its obvious that the compiler should protest.
Thinking of extended Pascals expression evaluation its a matter of =

operator precedence. Which comes first .. or =3D in a constant
declaration. =

 =

I Suppose Frank intended to have a specific value of a subrange as a
constant, but really this is not a good code example, for making good =

use of constants in a program you should make an explicit type
declaration,
and though I have not tried it this should work:

    PROGRAM x;
      TYPE  short_range_type =3D 1..16; (* here some integer maths could
be                                                                       =
           =

applied on the bounds *)
      CONST somewhere_in_between_c : short_range_type =3D 6;
      VAR   a_value : short_range_type;
    BEGIN
      a_value :=3D 4;
      if a_value < somewhere_in_between_c (* comparison with values of
same type*) =

      then
        writeln('Yeah this is working');
    END.



/Jakob :)

Longtimepascalhackerthatnowadayshackalotada.
Ericsson Saab Avionics AB, Link=F6ping, Sweden. =

mailto:Jakob.Heinemann@ericsson.com


Jakob Heinemann (Jakob.Heinemann@ericsson.com)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es