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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-18 04:31:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-036-225.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Sat, 18 Jan 2003 13:31:52 +0100 Organization: At home Message-ID: References: <1041908422.928308@master.nyc.kbcfp.com> <1041997309.165001@master.nyc.kbcfp.com> <1042086217.253468@master.nyc.kbcfp.com> <1042477504.547640@master.nyc.kbcfp.com> <1042651417.215661@master.nyc.kbcfp.com> <1042743579.1165@master.nyc.kbcfp.com> <1042824191.538184@master.nyc.kbcfp.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-036-225.arcor-ip.net (145.254.36.225) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1042893073 24707700 145.254.36.225 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:33172 Date: 2003-01-18T13:31:52+01:00 List-Id: Hyman Rosen wrote: > Dmitry A. Kazakov wrote: >> Not occasionaly, but when they are statically known. > > There is absolutely no difference with generics, > > which also "occasionally" work in this case. > > There is certainly a difference. With generics, the type > propogates through the code and can't be lost. > With dispatching, the compiler has to be able to deduce > that class wide objects and pointers are actually of a > specific type. That may not always be possible, especially > where containers are concerned. If not possible, then it is not a case where generics may be applied. My point is, anywhere generics work, the specific type can be tacked down. >> we use them because there is nothing better. > > Well, in my opinion, they *are* better, but I guess > that's just a matter of taste. If they are better, then there should be a rationale for that. So far, there are only two arguments: 1. Efficiency [which is arguable and very often not an issue in a large system] 2. They can something, that other gears cannot [what if they could?] Compare this with gotos. They are extremely efficient and they do can [make a maintenance nightmare out of any program] >> Seems that you are summoning the ghost of Pascal-strings. (:-)) > > Leave them resting in peace, they are useless! > > They have their place. And in Pascal, there were no generics, > so you would have to rewrite your code for each different size. > Gnereics do that for you, and sometimes that may be exactly what > you want. > >> But because you cannot specify the set, you are very limited in which >> operation you can define. For instance, you cannot have an iterator of >> the set, you cannot have subsets, pointers, containers and many other >> things which make ADT so useful. This is the price of text substitution. > > No, that is the price of using Ada generics. In C++, because of > specialization, you can have all of those things. Specialization > means that you can have entirely different code for a generic > instantiation based on the parameters; in Ada you cannot do this. This changes nothing: template class Y ...; how a specialization could help to create a container for Y. Note missing <> after Y. There is simply no such thing as Y. There is only a bunch of instances of Y, which are absolutely *unrelated*! > Andrei Alexandrescu's _Modern C++ Design_ is the best exposition > of these kind of techniques. The attitude in this kind of > programming is that using a specifc type instead of a generic > parameter is a lot like using a magic number in the code. This statement will retain its meaning if you replace "generic parameter" with "class-wide". However, maybe not "modern", but rather *careful* design requires a precise consideration when a class-wide/generic and when a specific type is appropriate. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de