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.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,27b7b39155b8a0d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-10 08:17:48 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Generics not overloadable Date: 10 Dec 2001 11:15:55 -0500 Organization: NASA Goddard Space Flight Center Message-ID: References: <5ee5b646.0111281941.2620b70a@posting.google.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1008001118 895 128.183.220.71 (10 Dec 2001 16:18:38 GMT) X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov NNTP-Posting-Date: 10 Dec 2001 16:18:38 GMT User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Xref: archiver1.google.com comp.lang.ada:17679 Date: 2001-12-10T16:18:38+00:00 List-Id: "Mark Lundquist" writes: > "Robert Dewar" wrote in message > news:5ee5b646.0111281941.2620b70a@posting.google.com... > > Ted Dennison wrote in message > news:... > > > > > It annoyed me too when I discovered it > > > > I find it hard to believe that it would be easy to come > > up with an example where it would help the reader to > > name two visible generic units with the same name. > > Why should it make a difference whether they are generic? The principle is > the same. As for examples, just about anything will do, but here's one > (self-explanatory, I trust)... I'll weigh in with Robert here; I find this abhorrent :). > generic with procedure Action (On : Item); procedure Apply (Over > : Collection); > > generic > with procedure Action (On : Item; Continue : out Boolean); > procedure Apply (Over : Collection); > > generic > with procedure Action (On : Item); > procedure Apply (Start, Finish : in Iterator); > > generic > with procedure Action (On : Item; Continue : out Boolean); > procedure Apply (Start, Finish : in Iterator); > > The user should not have to remember a different fiddly specialized name for > each variant. It's much more natural, and easier on the user, if each can > be called simply "Apply". This seems true, until you get to the instantiations. Taking your approach, all three would be identical, assuming appropriately overloaded procedures 'My_Action': procedure My_Apply is new Apply (Action => My_Action); procedure My_Apply is new Apply (Action => My_Action); procedure My_Apply is new Apply (Action => My_Action); Obviously, the compiler has no chance to sort this out. But the argument is that it is bad for the reader. Suppose we forgot one of these (assuming there were some way to make it legal). Later, when we try to call the missing My_Apply, the compiler says "no procedure matching My_Apply is visible". So we come back to here and say "Yes it is!". Too confusing. This is better: procedure My_Apply is new Apply_Over_Boolean (My_Action); procedure My_Apply is new Apply_Start_Finish (My_Action); procedure My_Apply is new Apply_Start_Finish_Boolean (My_Action); Now both the compiler and the reader can sort things out. > > > > > > Indeed, far too often overloading in Ada is misused to save the > > bother of thinking of different names. > > Maybe so, but not by me :-). I take naming too seriously, if anything :-). > Incidentally, I realized the reason for the language rule that makes it > impossible to overload generics. I'm not sure you have; did you consider trying to instantiate your example? -- -- Stephe