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,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Fri, 15 Oct 2004 13:56:03 +0200 Message-ID: <1q7hilgv3yu3a$.1t931ae5tgr06.dlg@40tude.net> References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> <1hl2mizeb27ku$.1f0asrbmb05mi.dlg@40tude.net> <7siml3c62lev$.usczt2y2l19c$.dlg@40tude.net> <15fk5715wm38q.3ie9r3bq8yuz$.dlg@40tude.net> <1ob4dexep087b$.ul8fb1ebgeok.dlg@40tude.net> <1dzt37oj3dnah.bwalpmfvyxd3$.dlg@40tude.net> <1k2m0s9456ba7$.t0euzv9ux97l$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 16uSVnIYqbQ/sZUUyyzBsQsetW2KW3C57XfOpKkUzK8dl7tWQ= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:5256 Date: 2004-10-15T13:56:03+02:00 List-Id: On Fri, 15 Oct 2004 11:25:03 +0200, Robert Kawulak wrote: >>>> In C++ it is checked upon inlining. In Ada it is checked upon >>>> instantiation. With my proposal it will be checked when you create a >>>> wrapper. The only difference is in the place and time. >>> >>> What do you mean by 'inlining' here? C++ templates are also >>> instantiated, either explicitly or implicitly (in a place you use it). >> >> I prefer "inline" because C++ instantiation may fail due to errors in the >> template body. That is because C++ templates are in fact macros. When and >> if, C++ will switch to a contract model, then I will call it >> instantiation. > > Still I don't get it - what's wrong in that "C++ instantiation may fail > due to errors in the template body"? Why shouldn't it fail? (Actually > compilation may fail even when there's no instantiation, because templates > bodies are always parsed, templates are not only ^C^V or #define as you say > ;-) #define is also parsed! In compiled languages "parsed" is far less than "compiled" and the results of these two actions are much different too. The margin is not absolute of course, but parsed template body is closer to parsed #define body than to a compiled true body. > And what would this "contract model" change? Nota bene, you can have > contracts with templates - if you use some inappropriate type as template's > parameter, it won't compile, Neither a macro expansion of #define would. Contracts are 1) imposed on both sides, 2) checked *prior* the contracting parties engage each other. > and you can strenghten contracts using > boost::concept_check and boost::type_traits mentioned before in this > discussion. It is still not a contract. You consider only the case when the macro/template parameter does not fulfill the requirements of the macro/template body, and ones of the expansion context. As long as these requirements are not formulated, but are a subject of investigation of the body (=implementation), it is not a contract. What if the *implementation* does not fulfill the contract, while the parameter does? How can you judge without explicit contract specification? And finally, when you manage to have true contracts for templates. What would be the gain? Your templates with contracts would be just like Ada generics. As a meta-language they would have types (=classes of parameters) but no user-defined ones (no ADT). Sorry, but it is early 70s of programming languages! Why do we need a meta-language with no ADT, for a language with ADT? There should be damn good reason for that, or? (Turing does not count! (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de