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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,86b85dca70d5fd7a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-31 19:01:59 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!hub.org!hub.org!newsfeed.mesh.ad.jp!sjc-peer.news.verio.net!news.verio.net!sjc-read.news.verio.net.POSTED!not-for-mail Newsgroups: comp.lang.ada From: Brian Rogoff Subject: Re: Ada '0x generics brain-fartz (long) In-Reply-To: <92c85f$qir$1@nnrp1.deja.com> Message-ID: References: <92c85f$qir$1@nnrp1.deja.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Mon, 01 Jan 2001 03:00:39 GMT NNTP-Posting-Host: 206.184.139.136 X-Complaints-To: abuse@verio.net X-Trace: sjc-read.news.verio.net 978318039 206.184.139.136 (Mon, 01 Jan 2001 03:00:39 GMT) NNTP-Posting-Date: Mon, 01 Jan 2001 03:00:39 GMT Organization: Verio Xref: supernews.google.com comp.lang.ada:3503 Date: 2001-01-01T03:00:39+00:00 List-Id: On Wed, 27 Dec 2000 mark_lundquist@my-deja.com wrote: > There haven't been too many times when I've wanted Ada95 to do > something more or different than it already does. Ha! Dullard. ;-) (Really, no offense intended!) > So I humbly submit an idea... actually two ideas... for improvements to > Ada. Although as essentially convenience features they border > on "unncessary", to my limited brain they seem like the might be > workable, and they don't seem "bizarre" -- that is, they seem like they > fall within the "spirit" of Ada rather than doing violence to it. > > CAVEAT EMPTOR: This is totally half-baked cerebroflatulence. It may be > crap! I've had similar desires myself when recoding the C++ STL in Ada 95. Not quite the same as yours though. > OK, idea #1: "generic specialization". The thought is that you could > have a construct that could bind some (but not necessarily all) actual > parameters to formals in the manner of an instantiation. This > construct creates a new generic, which can then be instantiated in the > normal way (or, of course, further specialized). What I've usually pined for is the "dual" of that feature, a kind of signature inheritance where I could extend a signature package with more features by naming the parent signature and the new features. But I can see why you'd want specialization too. [...snip...] > OK, here is the much shorter Idea Number Two: anonymous instantiation. > No windy discussion required here, you can figure it out from an > example: > > -- Normal Ada95... > -- > generic > package Gen is > > end Gen; > > -- Still normal... > -- > generic > package Template is new Gen (<>); > package Eric is > > end Eric; > > -- An anonymous instantiation! > -- > package Gen_Eric is > new Eric (Template => new Gen (); > > The purpose is to lower syntactic overhead and increase clarity, when > you're building chains of generic instantiations where the only purpose > of some instantiations is to serve as actuals to generic formal > packages (in particular with the "signature package" idiom, but by no > means just in that case). For this kind of thing I'd prefer automatic generic instantiation, similar to what C++ does. There was an article about this in Tri-Ada 91 and a PhD thesis from one of the authors (Shen) but no implementation I know of. This would make Ada far more powerful, giving it a kind of parametric polymorphism. Currently, generics do not give parametric polymorphism but only a very crude approximation. I doubt we'll ever see this in any version of Ada so if you really desire this you'll have to wait for Generic Java or better yet use a modern statically typed functional programming language like Ocaml, Haskell, Clean, or Mercury. -- Brian