From: Paul F. D. <di...@dl...> - 2004-09-28 14:03:09
|
Marco Antoniotti wrote: > > On Sep 27, 2004, at 10:31 PM, Paul F. Dietz wrote: > >> Marco Antoniotti wrote: >> >>> The above should always generate an error as (VECTOR NIL) is not a >>> valid type specifier. >> >> >> It's not? :) > > > I took it back yesterday, but I have been having nightmares about it > tonight (I should get a life, shouldn't I ? :) ) > > I checked with LW (which I find usually very good at compliance) and it > gives an error. > > The reasoning why (ARRAY NIL) , hence (VECTOR NIL) should not be valid > type specifiers is because they would violate the disjointness > requirement on the array type hierarchy. Since NIL is the bottom of the > type hierarchy, all disjointness requirements break down there. I.e. > > REAL----+------- FLOAT--------------+--------NIL > +------- RATIONAL--------+ > > where I depicted the "disjoint" relation, which is fine. > > However, for compound types (I know there are tons of Ph.D. theses on > the subject: I am not an expert) if we allowed (ARRAY NIL) to be a valid > type specifier, then we should allow the following > > ARRAY -----+---- (ARRAY CHARACTER) ------+---- (ARRAY NIL) -------- NIL > +---- (ARRAY T) ------------------------+ > > which would be incorrect as we would "rejoin" the ARRAY hierarchy above > NIL, while this is expressively forbidden in the ARRAY and VECTOR > definitions (CLHS 15.2: System Class ARRAY and System Class VECTOR.) > > Since the CLHS is weak on typing issues, and I do not recall any place > where (ARRAY NIL) is explicitly forbidden, I would say that disallowing > it is ok and it is a fair work around the CLHS incompleteness (or > inconsistencies :) ) > > Please correct me if you think this is bogus. I think this is bogus. :) I think you are imagining that if T1 is a subtype of T2, then (array T1) must be a subtype of (array T2). That's not the case. (array nil) is a type of arrays into which nothing can be stored. This doesn't violate disjointness any more than the existence of (array bit) and (array t) would (with bit being a subtype of t). (array nil) would be *disjoint* from the other array types. BTW, consider what (upgraded-array-element-type nil) must be. The requirements on upgraded-array-element-type (see the CLHS) require this to be type-equivalent to nil (this follows from the fact that nil is a subtype of bit and character, and those are fixpoints of u-a-e-t, therefore their intersection must be as well.) Paul |