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!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: Thu, 7 Oct 2004 10:24:43 +0200 Message-ID: <63z609r5z0h9.180f2ao5xdqg9$.dlg@40tude.net> References: <41547dae$0$91007$39cecf19@news.twtelecom.net> <1g2d9xmnita9f.5ecju0eftkqw$.dlg@40tude.net> <87u4rkhddelw$.1uuoqhfyd2eay$.dlg@40tude.net> <6zobtdp3ckqx.plmvz5og15id.dlg@40tude.net> <2n0j0jfe6sex.2bcfi09ss44w$.dlg@40tude.net> <1xc5ofa4jkd2x.ejgxx5gcwy4l$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de ZqcPJwQo8BEAEySpz8UiygwDiKilmY5erPg5c9Chtb2WYmeuc= User-Agent: 40tude_Dialog/2.0.12.1 Xref: g2news1.google.com comp.lang.ada:4855 Date: 2004-10-07T10:24:43+02:00 List-Id: On Wed, 6 Oct 2004 19:28:31 +0200, Robert Kawulak wrote: >> This "same interface" is not a language object. It is a fiction, which >> cannot be described in language terms independently on its implementation. >> So you physically unable to program in terms of this interface. It simply >> does not exist. > > It's not a fiction, it's a kind of agreement. The language doesn't see > this interface directly, but you can use it. And if you try to violate it in > a place where conformance to this interface is crucial, your program won't > compile. Yes. For *you*, it is not a fiction, because you know its semantics. The problem is how you communicate your personal percept of semantics to other people. It is what a language all about... >> What can you do with vector<>? Operator[] defined on it is >> not a function. It is a template function. > > Function template, you mean ;-) R-r-right! (:-)) >> You cannot call it outside of >> another template. That template must in turn have the vector's element >> type as a parameter etc. > > So what? You just make a template instead of a function and the job is > done. In all the places you call this template function, a compiler > generates appropriate function from your template looking at the type of > it's arguments, and that's it. But this is what I meant. Templates constitute a meta-language. That is inherently bad, provided there is a way to solve the problem within the native language (maintaining a reasonable level of expressiveness). This argument will stand even if templates became run-time things, which are not, making the solution even worse. BTW, Stepanov's point against OO and dynamic polymorphism was that he could not do generic programming with it. I believe he was wrong. >>> so it's easy to write a code that copes with vectors of >>> elements of different types. >> >> Really? Write code which reads from the stream a type X (from some >> defined, but large set of types) and then returns empty vector. > > Of course this can be done (Turing complete... ;-), but this is a very > different kind of problem, isn't it? It's just like reading a type X and > returning an object of type X. Yes. The problem is that 1) it happens at run-time, 2) you have to name the result type. > I don't think this would be much simpler if > std::vector<> was implemented as runtime-polymorphic, not using generics. Of > course there's the need to create a runtime-polymorphic wrapper class for > std::vector<>, but the problem of choosing the appropriate type from a large > set given this type's name as a string is the same in both cases. Besides > can you do this better in Ada than in C++? Yes, the infrastructure is ready. Ada has S'Class'Input attribute (ARM 13.13.2) which represents a factory pattern. Basically it reads the type tag from stream and then dispatches to an appropriate constructor, which is *guaranteed* to exist. The result is a class-wide object. Unfortunately it works only with tagged types, which do not include "true" arrays. But nothing prevents us from making arrays tagged, if I only could convince Ada community that this is necessary (:-)). > (Or it wasn't your point to > compare C++ with Ada in this respect, just to compare runtime vs. static > polymorphism?) Both. >> Stepanov? (:-)) > > Could you give some references (links, book titles...)? http://www.sgi.com/tech/stl/drdobbs-interview.html http://c2.com/cgi/wiki?GenericProgramming > I became curious (but it doesn't mean you've already convinced me ;-). You are not the only one, whom I cannot convince... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de