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,1cf653444208df72 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-14 01:29:36 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!uni-erlangen.de!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: dmitry@elros.cbb-automation.de (Dmitry A. Kazakov) Newsgroups: comp.lang.ada Subject: Re: ada vs. cpp Date: Wed, 14 Nov 2001 09:29:33 GMT Message-ID: <3bf2340a.160923875@News.CIS.DFN.DE> References: <9pgr68$7pu1@news.cis.okstate.edu> <3bbd6287.346843109@news.cis.dfn.de> <3bcbfda2.7486093@news.cis.dfn.de> <3bf0e265.74480421@News.CIS.DFN.DE> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) X-Trace: fu-berlin.de 1005730174 39740030 212.79.194.111 (16 [77047]) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:16491 Date: 2001-11-14T09:29:33+00:00 List-Id: On Tue, 13 Nov 2001 16:05:41 GMT, Ted Dennison wrote: >In article <3bf0e265.74480421@News.CIS.DFN.DE>, Dmitry A. Kazakov says... >>template class String {...}; >> >>Here the string bounds identify the type. Which has a nasty >>consequence that String<1,10> and String<1,80> are two different >>types. > >It should be noted that this is a *theoretical* example Dmitry is presenting. >C++'s "string" class is *not* defined this way. It is rather a single >instantiation of another template, and thus all objects of this class *are* the >same type. Yes. It was just an example of strings with bounds as a part of the type. Another thing is that there is no other way (I believe) to do it if stack allocation is a requirement. >Another thing I noticed with C++ templates is that instantiations that use the >same parameters appear to actually *be* the same object, unlike how Ada generics >work. That actually would help alleviate this problem a bit more than if you had >the same problem in Ada. This is the problem of generics per se. They are inherently harmful. I like to view dispatching polymorphism in OO as an attempt to get rid of generics [and still have generic programming]. That C++ uses "by-value matching" solves nothing, though the errors it may induce are very hard to track down. So I think Ada is in a better position here. Regards, Dmitry Kazakov