[kepler-dev] Re: zero-length arrays

Tobin Fricke tobin at splorg.org
Wed Aug 11 22:52:21 PDT 2004


On Wed, 11 Aug 2004, Bertram Ludaescher wrote:

> But I fear there might be a completely different reason for their
> special non-handling of empty arrays...

A closer look at the code leads me to believe that it's because the type
of an array is always inferred from the type of its 0th element.

It seems that that could be fixed by storing the type information in an
additional field.

But that reveals what's wrong with the "{}" syntax for an empty array --
there's no way to infer the type of the array.  tricky!

Still, that seems surmountable.

It looks (from comments in the source) like ArrayTokens are supposed to
have a type that is determined by the least upper bound of their
components, but because the code generator doesn't understand 'least upper
bound', the current implementation of arrays requires that all of the
elements have the same type exactly.  (Otherwise you could have a
heterogeneous array, whose type would be elevated to {general}.)

An empty array created from "{}" could have type "{general}", and an empty
array created from subarray operations, or repeat(0,"foo"), could have
more specific types, and appending something to zero-length array could
have the type recomputed on the resulting array (neglecting the
non-element and its possibly 'general') type... eh?

...

Tobin



More information about the Kepler-dev mailing list