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-Thread: 103376,e93f73587e2bc1c3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!panix!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Sharing generic bodies across instantiations. Date: Tue, 03 Aug 2010 10:37:24 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <4c4e2d69$0$2378$4d3efbfe@news.sover.net> <4c4f5c28$0$2375$4d3efbfe@news.sover.net> <7da1e21f-bec7-4607-923c-0fd6cbcfc753@t10g2000yqg.googlegroups.com> <1vjqnwxhvr91j.3e8ryvkk8ezv$.dlg@40tude.net> <1e77bsd66fduw.dbrgbk4g2ce7$.dlg@40tude.net> <22db743d-ef73-40fe-886d-9730a2763eaa@c10g2000yqi.googlegroups.com> <5cljc8pc0gv0$.115t79rxo29vs$.dlg@40tude.net> <9ad8b242-fe4c-4871-8c0e-1f1ddec936c7@w31g2000yqb.googlegroups.com> <94v29hel87y$.8jvqfyw964yt.dlg@40tude.net> <14342188-c6f4-4b60-9284-8eff4f3f9ecd@k19g2000yqc.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1280846229 30725 192.74.137.71 (3 Aug 2010 14:37:09 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 3 Aug 2010 14:37:09 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:Jyg3fNH7+1PvWp5mkFrJi1091qE= Xref: g2news1.google.com comp.lang.ada:12828 Date: 2010-08-03T10:37:24-04:00 List-Id: "Randy Brukardt" writes: > You need to read about the Ada contract model for generics. (Off-hand, I > can't think of a good reference, however.) The AARM talks about it. Not exactly an "easy read". ;-) I think maybe the Ada 83 Rationale talks about it. There were some holes in the contract model in Ada 83, which were patched in Ada 95. >... Part of the Ada contract model is > that there cannot be an error caused by the actual parameters of an instance > in an instance body. Tucker Taft liked to describe the model as > "assume-the-best" in the specification and "assume-the-worst" in the generic > body. Thus there are a lot of things that are illegal in a generic body in > Ada simply because they *could* be illegal in some instance of that generic. > C++ has no such counterpart (indeed, I recall reading that Stoustrup [sp] > explicitly eliminated it from C++ templates because it was too complex). > > In addition, binding of names in the generic body always takes place at the > point of the compilation of that body. That means that most operations at > determined at that point, facilitating sharing. (This also causes the > sometimes bug of "reemergence" in generics, where a hidden predefined > operator is used instead of the user-defined one for the actual type.) C++ > uses a more macro approach to template expansion. It makes C++ templates more powerful than Ada generics. The downside is that if you're writing a reusable and widely-reused library, it's difficult to know (in C++) whether some change might break clients. The other downside is that error messages are typically incomprehensible; in Ada you don't get normally get errors in instance bodies, so they can't be incomprehensible. ;-) - Bob