An ISO Standard Question 
Author Message
 An ISO Standard Question

Dear All,

I wonder if someone out there could clarify something
in the ISO standard.

Using one of the two "ISO Compliant" compilers we've tested (XDS), this is legal:

TYPE
  Str = ARRAY[1 .. 10] OF CHAR;
  StrArr = ARRAY[1 .. 2] OF Str;
VAR
  s : StrArr;
BEGIN
  s := StrArr{"Hello" , "Mum" };

... but this is *illegal*:

TYPE
  Str = ARRAY[1 .. 10] OF CHAR;
  StrArr = ARRAY[1 .. 2] OF Str;
CONST
  s = StrArr{"Hello" , "Mum"};

However this structured constant *is* allowed under GPM2, the other
"ISO-conformant" M2 compiler that we've been using. Which is right?
In our existing code (using TopSpeed) we declare a lot of arrays of
strings as constants. So we'd like GPM to be right!

And if it is the case that variable constructors are legal but constant
constructors illegal, what was the thinking behind it?

regards,

Graham Stark



Sat, 15 Aug 1998 03:00:00 GMT  
 An ISO Standard Question

Quote:

>.. one of two "ISO Compliant" compilers we've tested (XDS), this is legal:
> VAR
>   s : StrArr;
> BEGIN
>   s := StrArr{"Hello" , "Mum" };

> ... but this is *illegal*:

> TYPE
>   Str = ARRAY[1 .. 10] OF CHAR;
>   StrArr = ARRAY[1 .. 2] OF Str;
> CONST
>   s = StrArr{"Hello" , "Mum"};

> However this structured constant *is* allowed under GPM2,

I've got Fourth Draft of the ISO standard, which I believe was quite close to
the final.  It clearly states that the value given for a named constant in a
constant declaration must be a constant expression.  It is also states that an
array constructor is a constant expression if its contents are constant expressions.
My understanding of that is that one could construct arbitrarily nested array/record
structures, so long as "leaf" items were constant values.

--
person: Graham Perkins         paper: School of Computing
voice:  +44 (0)1908 834936            De Montfort University
dots:   +44 (0)1908 834948            Milton Keynes MK7 6HP



Sat, 15 Aug 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. ISO standard question

2. Standards questions, from ISO Convener

3. branching in proposed ISO standard

4. ISO Standards Documents

5. ISO International Standard IS8485

6. ISO Standard for Headless Images?

7. ISO Standard Forth

8. ISO Standard for Software Revisions

9. ISO Standard Approved

10. ISO standard for EBNF

11. Oberon ISO-Standard?

12. Static scoping in BCPL (was Re: Are nested functions legal in ANSI/ISO Standard C)

 

 
Powered by phpBB® Forum Software