Thread View: comp.lang.modula2
5 messages
5 total messages
Started by gstark
Tue, 27 Feb 1996 13:56
An ISO Standard Question
Author: gstark
Date: Tue, 27 Feb 1996 13:56
Date: Tue, 27 Feb 1996 13:56
34 lines
1173 bytes
1173 bytes
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
Re: An ISO Standard Question
Author: Graham Perkins
Date: Tue, 27 Feb 1996 19:11
Date: Tue, 27 Feb 1996 19:11
29 lines
1590 bytes
1590 bytes
gstark@ifs.org.uk wrote:
>.. 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
bits: grp@dmu.ac.uk United Kingdom
Re: An ISO Standard Question
Author: Alex Nedorya
Date: Wed, 28 Feb 1996 20:51
Date: Wed, 28 Feb 1996 20:51
42 lines
1680 bytes
1680 bytes
gstark@ifs.org.uk wrote:
>
> 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"};
The XDS translator reports "Can not generate object declaration" error in the second case.
It does not have any connection with ISO standard. It is just a restriction in the code
generator which generates C code. Both texts are valid accorording to the standard.
BTW, Native XDS (which generates native code for Win95/WinNT)
compiles both texts without problems.
I cannot say now why this structure constant is not generated by our translator,
I'll have a look.
BTW, new XDS web pages are available as
http://www.iis.nsk.su/xtech/xds/
and will be available soon as
http://www.dct.com/~johnm/xds.html
-- Alex Nedorya, xTech Ltd
Re: An ISO Standard Question
Author: Alex Nedorya
Date: Wed, 28 Feb 1996 20:52
Date: Wed, 28 Feb 1996 20:52
46 lines
1688 bytes
1688 bytes
gstark@ifs.org.uk wrote:
>
> 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"};
The XDS translator reports "Can not generate object declaration" error
in the second case.
It does not have any connection with ISO standard. It is just a
restriction in the code
generator which generates C code. Both texts are valid accorording to
the standard.
BTW, Native XDS (which generates native code for Win95/WinNT)
compiles both texts without problems.
I cannot say now why this structure constant is not generated by our
translator,
I'll have a look.
BTW, new XDS web pages are available as
http://www.iis.nsk.su/xtech/xds/
and will be available soon as
http://www.dct.com/~johnm/xds.html
-- Alex Nedorya, xTech Ltd
Re: An ISO Standard Question
Author: Alex Nedorya
Date: Wed, 28 Feb 1996 20:53
Date: Wed, 28 Feb 1996 20:53
46 lines
1688 bytes
1688 bytes
gstark@ifs.org.uk wrote:
>
> 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"};
The XDS translator reports "Can not generate object declaration" error
in the second case.
It does not have any connection with ISO standard. It is just a
restriction in the code
generator which generates C code. Both texts are valid accorording to
the standard.
BTW, Native XDS (which generates native code for Win95/WinNT)
compiles both texts without problems.
I cannot say now why this structure constant is not generated by our
translator,
I'll have a look.
BTW, new XDS web pages are available as
http://www.iis.nsk.su/xtech/xds/
and will be available soon as
http://www.dct.com/~johnm/xds.html
-- Alex Nedorya, xTech Ltd
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads