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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: f43e6,b87849933931bc93 X-Google-Attributes: gidf43e6,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: donh@syd.csa.com.au (Don Harrison) Subject: Re: OO, C++, and something much better! Date: 1997/01/09 Message-ID: #1/1 X-Deja-AN: 208617522 sender: news@syd.csa.com.au x-nntp-posting-host: dev50 references: organization: CSC Australia, Sydney reply-to: donh@syd.csa.com.au newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng Date: 1997-01-09T00:00:00+00:00 List-Id: Jon S Anthony writes: :In article <32D2E6C8.13728473@eiffel.com> Bertrand Meyer writes: : :Wow. The big folk are coming out. :) :> - Unconstrained genericity, to declare a class :> as e.g. LIST [G], where G represents an arbitrary :> type, so that you can then use LIST [SOME_TYPE] regardless :> of what SOME_TYPE is. : :This is in Ada95: :generic : type G is private; :package List is... Yes. :> - Constrained genericity, as in e.g. :> SORTED_LIST [G -> COMPARABLE], to require that :> some operations be applicable to all actual :> generic parameters. The rule is that :> SORTED_LIST [SOME_TYPE] is permitted if and only :> if SOME_TYPE inherits, directly or indirectly from :> COMPARABLE. : :This too is in Ada95: : :generic : type G is new Comparable with private; :package Sorted_List is ... : :Same instantiation constraints as in the Eiffel case... Yes. However, I'm not sure whether you lose some of the power of combining genericity with inheritance through Ada's module-type distinction. Since genericity in Ada is essentially module-based and inheritance is type-based, I suspect you may lose something here. :> - True static typing (with no cast a la C++). : :Yes, this is in Ada95 too. No. Ada offers type casting in a couple of ways: 1) UNCHECKED_CONVERSION and 2) Address representation clauses (overlays). Eiffel, by contrast, has no such thing in the standard language. That isn't to say it isn't needed for some things (and is why some vendors do provide type conversion between basic types and bits, for example). I have been trying to think of a safe way of doing this sort of thing but thus far haven't thought of any. :) :In fact it is better in Ada95 since it :does not have system validity problems. Perhaps not the same kind of problems. But it's dead easy to write 'system invalid' Ada which will result in runtime errors. For example, by using the value of a parent type where a subrange value is required. [...] :> it possible to apply objects of type G a wide range of operations :> applicable to all objects: equality comparison (redefinable :> in any class as long as it satisfies the original assertions), :> copying, cloning, even (in the latest version of ELKS) hash :> coding. : :Here is where you actually get some more flexibility with Ada as you :can parameterize your generic (either the constrained or unconstrained :type) with more than just types. You can specify complete signatures :including operations and/or packages as well. What's more, these can :have constraints on them as well. Yes. However, these kinds of formal parameters are only needed in Ada because it distinguishes between module and type. Eiffel's unification of module and type obviates the need for them. :) Eiffel's genericity mechanism is also simpler because it is a *pure* OOPL compared to hybrid Ada. :Of course, it doesn't have real :assertions, so I suppose this is kind of a wash... Don. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Don Harrison donh@syd.csa.com.au