Peter Gerwinski wrote:
According to Frank Heckenbach:
[...] However, the following still doesn't work (if it's already/still on the bug list, please ignore):
PROGRAM x; CONST n:1..16=6; {"subrange bounds are not of the same type"} BEGIN END.
Is this really a bug??? Extended Pascal allows expressions as the upper bound of a subrange. In this case, the expresson "16 = 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 = 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 = 1..16; (* here some integer maths could be applied on the bounds *) CONST somewhere_in_between_c : short_range_type = 6; VAR a_value : short_range_type; BEGIN a_value := 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öping, Sweden. mailto:Jakob.Heinemann@ericsson.com