[q-lang-users] Multiple supertypes for Q?
Brought to you by:
agraef
From: John C. <co...@cc...> - 2006-07-15 04:25:29
|
Multiple supertypes would seem to be fairly cheap and easy to add to Q. Declaring "type Bar : Foo" just means that the constructors of Bar will match a variable with a Foo type guard. If we further declare "type Baz : Foo", that further adds the constructors of Baz to what X:Foo will match. So there seems to be no obvious reason why "type Toto : Tata, Titi, Tutu" shouldn't add Toto's constructors to the constructors matching X:Tata, X:Titi, and X:Tutu. This may be very expensive in the implementation for reasons I don't know about, but if experience with Java interfaces and C abstract classes is correct, it will not be used often but will be indispensable in some cases. Here are a few ideas for new built-in types assuming #1 is adopted, borrowed from built-in Haskell type classes: Eq: for types on which = is defined; Ord: for types (including enums) on which < etc. are defined; Ix: for types on which ! is defined. -- John Cowan co...@cc... http://ccil.org/~cowan Original line from The Warrior's Apprentice by Lois McMaster Bujold: "Only on Barrayar would pulling a loaded needler start a stampede toward one." English-to-Russian-to-English mangling thereof: "Only on Barrayar you risk to lose support instead of finding it when you threat with the charged weapon." |