[M3devel] assignability of fixed and open arrays, was: RE: release engineering 5.8: code generator error for IP address initializers

Tony Hosking hosking at cs.purdue.edu
Fri Apr 16 17:06:27 CEST 2010


There is no open array in this code.  Just a fixed array type and an array constructor.  It is perfectly reasonable code.

On 16 Apr 2010, at 08:55, Olaf Wagner wrote:

> Quoting Jay K <jay.krell at cornell.edu>:
> 
>> (back to the topic :) )
>> 
>> somewhat reduced case:
>> 
>> MODULE Main;
>> 
>> TYPE T1 = ARRAY [0..0] OF INTEGER;
>> 
>> CONST const: T1 = ARRAY OF INTEGER{2};
>> BEGIN
>> END Main.
>> 
>> The problem is two global integers are overlapping.
>> The open array size and its first element.
>> 
>> Are these syntaxes legal?
>> This apparent mixing of open and fixed arrays?
> 
> You mean it would work for
> 
>  CONST const: T1 = ARRAY [0..0] OF INTEGER{2};
> 
> The type of const is no open array, but the fixed array A1.
> So the question would be: is an open array (of the correct size)
> assignable to a fixed array type?
> 
>  An expression e is assignable to a variable v if:
> 
>    * the type of e is assignable to the type of v, and
>    * the value of e is a member of the type of v, is not a local procedure,
>      and if it is an array, then it has the same shape as v.
> 
> though this is not a variable assignment, but a constant definition.
> Nonetheless, if that's assumed to be equivalent, then it would depend
> on the definition of shape: does it include the length field or not?
> 
> I'd tend to think it does not (since that's just a representation the
> compiler (writer) chose), but only the number of dimensions and elements
> should count.
> 
> But this is certainly subtle and others may see it differently.
> 
> Olaf
> -- 
> Olaf Wagner -- elego Software Solutions GmbH
>               Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
> phone: +49 30 23 45 86 96  mobile: +49 177 2345 869  fax: +49 30 23 45 86 95
>   http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
> Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
> 




More information about the M3devel mailing list