From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,3d3f20d31be1c33a X-Google-Attributes: gid1014db,public X-Google-Thread: f43e6,2c6139ce13be9980 X-Google-Attributes: gidf43e6,public X-Google-Thread: fac41,2c6139ce13be9980 X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,2c6139ce13be9980 X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,2c6139ce13be9980 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,3d3f20d31be1c33a X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Is ADA as good for graphics programming as C? (WAS: Re: Avoiding the second historic mistake) Date: 1997/07/10 Message-ID: #1/1 X-Deja-AN: 256130402 References: <33957A33.1C31AB44@oma.com> <865898351snz@nezumi.demon.co.uk> <339ED54C.215A5F85@oma.com> <5noc8u$a8m$3@miranda.gmrc.gecm.com> <33A032AC.2D8BA85C@oma.com> <5nrn86$cvo$3@miranda.gmrc.gecm.com> <33A1CBBB.B0602EC@oma.com> <5o2uls$ku3$2@miranda.gmrc.gecm.com> <33A6ADDA.2099EEB9@oma.com> <33A7D2DE.545B@polaroid.com> <33A9338D.10BB@polaroid.com> <33B09D64.E7F99DA3@saguarosoft.com> <33B16CBB.417A@gdesystems.com> <33C4AF0E.339D@calfp.co.uk> Organization: Estormza Software Newsgroups: comp.object,comp.software-eng,comp.lang.ada,comp.lang.eiffel,comp.lang.c,comp.lang.c++ Date: 1997-07-10T00:00:00+00:00 List-Id: In article <33C4AF0E.339D@calfp.co.uk>, Nick Leaton wrote: >> Different languages have made different choices with respect to whether all >> types should be part of a common hierarchy. That Eiffel did so, and Ada >> did not, should not be construed as better, just different. > >I'm not sure about this. If you don't have a common hierarchy, then that >precludes you from using a common root. Now this is useful when we look >at container classes. It is particularly useful when you can constrain >the type that is store in a container to a particular type. I think there is confusion here between what one does versus how one does it. In Ada, you can constrain the type you use to parameterize a container class, it's just that the mechanism for doing so is different from Eiffel. For example, I can parameterize a type with any assignable type: generic type T is private; package Containers_G is type Root_Container is abstract tagged private; ... I can constrain the generic formal type so that it only allows integers: generic type T is range <>; package Containers_G is ...; I can constrain the type to only integer types that derive from integer type T (example *): generic type NT is new T; package Containers_G is ...; I can constrain the type to any type with an addition operator: generic type T is private; with function "+" (L, R : T) return T is <>; package Containers_G is ...; I can constrain the type so that it only takes tagged types (those that have type extension): generic type T is tagged private; package Containers_G is ...; I can constrain the type so that it only takes tagged types that derive from a specific tagged type T (example **): generic type NT is new T with private; package Containers_G is ...; Examples (*) and (**) are examples of "constrained genericity," which is exactly what you said would be really nice to have. So you have it an Eiffel AND Ada. So what's the problem? In Ada, you can constrain the type used to parameterize another, without all types necessarily being related via a hierarchy. That Eiffel does it differently from Ada should be construed only to mean that Eiffel does it differently from Ada, not better. In Ada, you can even do mixin inheritance without using multiple inheritance. Imagine that! -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271