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!news3.google.com!proxad.net!feeder1-2.proxad.net!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Sharing generic bodies across instantiations. Date: Mon, 2 Aug 2010 22:02:39 -0500 Organization: Jacob Sparre Andersen 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: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1280804566 7456 69.95.181.76 (3 Aug 2010 03:02:46 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 3 Aug 2010 03:02:46 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5843 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-RFC2646: Format=Flowed; Original Xref: g2news1.google.com comp.lang.ada:12818 Date: 2010-08-02T22:02:39-05:00 List-Id: "Maciej Sobczak" wrote in message news:14342188-c6f4-4b60-9284-8eff4f3f9ecd@k19g2000yqc.googlegroups.com... ... > 2. How does this affect the amount of late binding and why is there > less of it than with C++ templates? You need to read about the Ada contract model for generics. (Off-hand, I can't think of a good reference, however.) 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. Randy. P.S. When Dmitry talks about "macros", he means the general concept of macro processing. You seem to think he's talking about C macros, which is a specific instance of macro processing. It is pretty likely that some form of macro processing will be used to implement templates (and Ada generics in most compilers), but that has nothing whatsoever to do with the C preprocessor.