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-Thread: a07f3367d7,39579ad87542da0e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.75.133 with SMTP id c5mr1637004wiw.2.1368583165587; Tue, 14 May 2013 18:59:25 -0700 (PDT) Path: p18ni110061wiv.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newspeer1.nac.net!news.astraweb.com!border2.newsrouter.astraweb.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!newsflash.concordia.ca!News.Dal.Ca!citadel.nobulus.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Wed, 8 May 2013 09:57:39 +0200 Organization: cbb software GmbH Message-ID: <1xlzfj8qy1zey$.up1s1v3syagv.dlg@40tude.net> References: <1luaso698dpcc$.rrv8385qwl92.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-05-08T09:57:39+02:00 List-Id: On Tue, 7 May 2013 15:27:58 -0500, Jacob Sparre Andersen news wrote: > "Dmitry A. Kazakov" wrote in message > news:1luaso698dpcc$.rrv8385qwl92.dlg@40tude.net... >>> On Mon, 6 May 2013 20:09:46 -0500, Randy Brukardt wrote: >>> >>>>The idea of indexing a numeric type is silly, >>> >>> Not at all, consider Unit type declared modular because it has to be used >>> as a discriminant. At the same time Unit is a composite of powers for mass, >>> time, current, temperature etc. One would like to have it indexed (viewed >>> as an array or as a record). > > It might make sense to view it as a record (a capability not in Ada 2012), > but it makes little sense to view it as an array (a list of identical > components indexed by a potentially *computed* index). The index could be enumeration. > There are a lot of > abuses of arrays out there that would be much better written as records. Yes, but the point is that whether array or record interface there could be reasons for the programmer to add that interface to any type he wished. It is not the language business to dictate me if I may index or "dismember" anything. >> Another problem is that you cannot make everything Controlled without MD. >> Because otherwise you will permanently run into problems with primitive >> operations of multiple types, multi-methods etc. > > Say what? Making everything controlled simply means that every type has a > Finalize operation. Dispatching *within* a Finalize operation is usually a > disaster (you don't want to redispatch as you might be finalizing the parent > part of some child type), so what that has to do with MD is beyond my > comprehension. That is a different issue. I meant that if A and B are controlled/tagged you will have troubles in using them as parameters of same subprogram. Even two parameters of same type is a problem already. Only MD can resolve that. Regarding dispatching Finalize, the thing is broken. The only model of destruction I know, which would allow dispatching is having class-wide destructors called prior to specific destructors. You would be able to dispatch from the former. And, yes, re-dispatch is a great evil and should never be in the language in first place. At least class-wide view conversions in Finalize should be made illegal. But that is too late. Though Finalize is irrelevant anyway because if constructors/destructors will ever added to the language that will not happen on the basis of primitive operations. So Finalize could be left as is. > I suppose you might get into trouble if you mistakenly try to declare > multiple tagged types in a package, but that's always a bad idea and should > be avoidable in almost all cases (possibly with careful use of limited > with). I don't see why is it a bad idea to have related types declared in one package. On the contrary it is a good idea to group related things in a way making it easer to use. I am glad that Ada does not tie types to packages. > If you really need multiple types in a package, you have too much > coupling between "objects" (in an OO sense), and coupling is always > something to be minimized. Declaration scope is not automatically coupling. But otherwise, yes, index type is coupled to the array type. Sometimes decoupling is a bad idea because it leads to weaker typing. E.g. if you wanted to decouple array index you would end up indexing all arrays by one integer type. Welcome to C. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de