Looking over the unit tests for Gwydion Dylan, I see that none of map,
etc, work with limited collections. This is probably because type-for-
copy returns limited collection types and those functions don't know
how to instantiate limited collection types properly.
limited() returns a <limited-collection>. A <limited-collection> isn't
actually a collection -- none of its supercl***** is <collection>.
Instead, it is basically a limited collection specifier. make on
<limited-collection> calls make-limited-collection to instantiate the
actual collection.
The actual collection (which inherits from <limited-collection-mixin>)
has an additional init-keyword, collection-type:, beyond what the base
collection class (<simple-vector> or whatever) has.
type-for-copy doesn't treat <limited-collection-mixin> collections any
differently from other collections, so calling type-for-copy returns
the subclass of <limited-collection-mixin>. But when map tries to
instantiate that type, it fails, because that type has the extra init-
keyword parameter.
Now, I see two solutions. First, make map, etc. aware of limited
collection types and how to instantiate them. Second, make type-for-
copy on <limited-collection-mixin> return <limited-collection> instead
of the type of an actual collection.
The problem with solution number two is that the DRM specifies that
type-for-copy on a limited type must return a subtype of the base
collection class, and <limited-collection> isn't a subtype of any
collection class. I suppose we could implement instance? and subtype?
to treat <limited-collection> as if it were a subtype of its base
collection class (since that will presumably satisfy whatever
necessity led the DRM to include that stipulation), but I don't know
if that will screw up the runtime's own bookkeeping.
Opinions? Brilliant solutions?


|