Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Limited collections and type-for-copy

0 views
Skip to first unread message

agen...@gmail.com

unread,
Apr 27, 2008, 8:40:57 PM4/27/08
to hac...@opendylan.org
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 superclasses 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?

cgay

unread,
May 11, 2008, 1:32:52 AM5/11/08
to
On Apr 27, 8:40 pm, agentm...@gmail.com wrote:
> 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.
>
...

For the record, this was also posted to the hackers list at
opendylan.org and that's where followups were posted.

0 new messages