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,FREEMAIL_FROM autolearn=ham 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-17 09:25:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uunet!sea.uu.net!sac.uu.net!ash.uu.net!spool0902.news.uu.net!not-for-mail Date: Fri, 17 Jan 2003 12:23:11 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3b) Gecko/20030116 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. 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> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1042824191.538184@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1042824197 20826 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:33143 Date: 2003-01-17T12:23:11-05:00 List-Id: 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. > 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. > 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. 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.