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: 103376,b0ad1d51e4ffa82b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: access types Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <3b3itu0t79zl$.czig4w8nzdmp.dlg@40tude.net> <1ms47w0p7qd6m$.780b4ot5v1q1.dlg@40tude.net> Date: Mon, 2 Jul 2007 10:06:28 +0200 Message-ID: NNTP-Posting-Date: 02 Jul 2007 10:03:19 CEST NNTP-Posting-Host: 299402f7.newsspool2.arcor-online.net X-Trace: DXC=hI@RUSH7OIe:i=48;n?Z:`A9EHlD;3Ycb4Fo<]lROoRa8kFo3GkFOF5Vgfk X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16379 Date: 2007-07-02T10:03:19+02:00 List-Id: On Sun, 01 Jul 2007 20:12:23 -0400, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> On Sun, 01 Jul 2007 10:57:17 -0400, Robert A Duff wrote: >> >>> Access-to-classwide should normally use "all". >>> In fact, you won't go too far wrong if you always say "all" >>> for all named access-to-variable types. >> >> I appreciate storage pools too much to agree with that. There are so many >> interesting things we can do with pools, multiple inheritance for example! >> (:-)) > > OK, I'll bite. ;-) > > How do you do multiple inheritance with pools? Normally one would emulate MI with a mix-in: type M (Base1 : access B1; Base2 : access B2) is new B3 with private; The idea is to allocate M in a user pool. The pool would route Allocate and Deallocate to the standard pool, but doing that Allocate would also reserve some space for the instances of B1 and B2 in front of the object. M becomes a pointer. Discriminants can eventually be removed if there is a way to determine the addresses of B1 and B2 from a pointer (address) to B3. This is of course a poor man's MI. But it works nicely for some things. For example I used it for multiple doubly-linked lists of anything. An object can stay in as many lists one could wish. For each list a record with Prev and Next pointers is added when the object gets allocated in the pool. Items of lists are accessed via plain access type, no further redirection needed, no problem with unconstrained arrays as list items. Write "new Thing", and the work is done. > Anyway, "all" does not stop you from using pools. In some cases it does. access all T is sort of doubly-dispatching. One of its classes is T'Class, another is Root_Storage_Pool'Class. The problem is that the second class is not available. We cannot define new primitive operations which would dispatch on the pointer according to the specific pool. Only Allocate and Deallocate would. >> I could never understand why explicit conversion is not allowed for >> pointers from the same pool. > > Well, that might make sense, but we never thought of that. > "Pool specific" is somewhat of a misnomer. It really just > means "Ada 83-style access type". They fit nicely into Ada's OO model, as I described above. Maybe it was an unexpected by-product. Which shows the strength of Ada's fundamentals. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de