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: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: donh@syd.csa.com.au (Don Harrison) Subject: Re: Eiffel and Java + Ada dispatching Date: 1996/11/15 Message-ID: #1/1 X-Deja-AN: 196604420 sender: news@syd.csa.com.au x-nntp-posting-host: dev11 references: organization: CSC Australia, Sydney reply-to: donh@syd.csa.com.au newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1996-11-15T00:00:00+00:00 List-Id: Robert I. Eachus writes: : In Ada, the default for generics is that you get the "predefined" :operations for the class. But if you explicitly pass the operation as :a generic formal, you can override the standard definition. No :surprise there either. Okay. If it made sense, I think I would prefer to encapsulate behaviour of related operations into a type and define descendants covering the variants. Then the parent type bundled with its operations can be used as a formal generic parameter. That way, you simplify the generic interface. Don't know whether this fits at all. :The suprise in the construct I demonstrated is :that it is possible to define generics that are sensitive to the :environment where they are instantiated. : : And yes, it is a very useful feature, and should be used very :carefully. I have written several Ada 83 libraries where generics :have use this feature extensively, and have as many as thirty formal :parameters. Since the packages are intended to be useful, they also :are designed so that most of the generic formals have default values, :so the instantiations only need a few lines. If you were writing this now in Ada95, would you be able to reduce the complexity by using OO stuff? : But it is a high (and almost lanaguage independent) talent to :observe the principle of least surprise. Indeed. :) : > If the non-overloading versions are exponentially larger, maybe : > the originals were a bit dodgy anyway. :) In saying this, I didn't realise you were talking about Ada83. It makes more sense in that context. : No, but the most extreme case I know of was real portmanteau code. :Generic instantiations with other generic instantiations as :parameters, about four levels deep. Nasty stuff! :But any other way of writing the :code would have required millions of lines of code. The several :thousand generic instantiations weren't easy to debug and test, but :much much better than any million line monstrosity would have been. :Just don't use the powerful features for the easy jobs, save them for :when and where they are needed. I'll interpret 'powerful' to mean 'esoteric'. :) : > IMHO, overloading should have no semantic impact. It should merely be : > 'syntactic sugar' as Jean-Marc suggested. : : Nice dream, but...the fact that horses are a good way to commute :shouldn't lead to the outlawing of jet planes for intercontinental :travel. However, you do need to make sure that the airplane pilot :knows how to fly. ;-) Yes, and thankfully they make planes *easier* to fly these days. :) Jon should know something about that. Don. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Don Harrison donh@syd.csa.com.au