[Gd-hackers] [Gd-chatter] r11101 - trunk/src/d2c/runtime/dylan/tests
Eric Gouriou
eric.gouriou at pobox.com
Sun Dec 31 21:58:12 CET 2006
On Dec 30, 2006, at 19:27 , Peter S. Housel wrote:
> On Tue, 2006-12-26 at 08:39 +0100, agent at gwydiondylan.org wrote:
>> Author: agent
>> Date: Tue Dec 26 08:39:29 2006
>> New Revision: 11101
>>
>> Modified:
>> trunk/src/d2c/runtime/dylan/tests/collections.dylan
>> Log:
>> Job: gd
>> Corrected invalid test. Test did ensure that element(..., default:
>> x) errors
>> if x is of the wrong element type. According to DRM, the
>> restriction on
>> return value of element() doesn't apply if default: is supplied,
>> so it should
>> not error.
>
> Where do you get that? As I read it, the DRM doesn't explicitly say
> whether or not default: values that aren't instances of the
> collection's
> element type are permitted. For performance reasons, it seems
> perfectly
> reasonable that a particular element() method would declare a
> particular
> return type, and that the default: value would be subject to the
> declared type restriction.
This would forbid code like element(index-not-present, #f) for limited
collections on types that do not include #f
(or element(index-not-present, #()), etc.). I believe it is fairly
common
idiom to use a default value which cannot be part of the collection
itself,
instead of relying on conditions to catch an invalid/not-present index.
element() may need to be treated specially by the compiler as
returning'
type-union(element-type-of-collection(coll), singleton(default-value))
(I hope you'll get my meaning, my Dylan is very rusty).
Eric
--
Eric Gouriou
eric.gouriou at pobox.com
More information about the hackers
mailing list