[M3devel] A bizarre language quirk

Rodney M. Bates rodney_bates at lcwb.coop
Sat Mar 24 19:11:20 CET 2018


There is a related problem with trying to construct ragged arrays using constructors:

; TYPE O = ARRAY OF INTEGER
; TYPE OO = ARRAY OF O

; CONST Ragged1 = OO { O { 3 , 7 }
                      , O { 11 }
                      }


I find nothing in the language to prohibit this, despite the fact that it is not in
the value set of multi-dimensional arrays as defined.  The compiler quietly fills
out Ragged1[1,1] with zero, or maybe it's really random.

Several other combinations crash the compiler in CG, including making the second O
longer than the first and providing an O that does not have static element count.


On 03/21/2018 02:57 PM, Henning Thielemann wrote:
>
> On Wed, 21 Mar 2018, Rodney M. Bates wrote:
>
>> Modula3, 2.6.3 (Designators), concerning subscripting says:
>>
>> An expression of the form a[i_1, ..., i_n] is shorthand for a[i_1]...[i_n].
>
> I think I wrote earlier about this shorthand ...
>
> I found the following problem:
>
> ARRAY OF ARRAY OF Something
>
> is syntactically not quite a 2D-array since as it is written it suggests that the sub-arrays may have different sizes.
>
> This has practical consequences. It would be no problem to have a 0-by-n array. But Modula-3 fails to determine the size of the second dimension of a 0-by-n array, because LAST(a[0]) is a range violation in the first dimension.
> _______________________________________________
> M3devel mailing list
> M3devel at elegosoft.com
> https://m3lists.elegosoft.com/mailman/listinfo/m3devel
>

-- 
Rodney Bates
rodney.m.bates at acm.org


More information about the M3devel mailing list