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,a9026b81108642ee X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Address of an object 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: <382nx7mt637x$.6hjqgb4zxzss.dlg@40tude.net> <1158363114.393740.59040@h48g2000cwc.googlegroups.com> <1i3ne95psolai.abl9eureg5t9$.dlg@40tude.net> Date: Mon, 18 Sep 2006 14:09:14 +0200 Message-ID: NNTP-Posting-Date: 18 Sep 2006 14:09:14 CEST NNTP-Posting-Host: 7774461b.newsspool2.arcor-online.net X-Trace: DXC=bPV3^Q6i08ZcHPTNZh_e7QA9EHlD;3YcR4Fo<]lROoRQ4nDHegD_]RUHl@TZEW1;`[DNcfSJ;bb[UFCTGGVUmh?TN\HXHJ4e80^W`\lkbPFlnP X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6630 Date: 2006-09-18T14:09:14+02:00 List-Id: On Mon, 18 Sep 2006 06:29:24 -0400, Stephen Leake wrote: > "Dmitry A. Kazakov" writes: > >> Let P be a pointer to X. Then what I need is the address A, which the pool >> P'Storage_Pool returned when X was allocated there. This is the same >> address the pool will receive upon freeing X. >> >> ---------- >> The problem behind. What I need is to be able to add some dopes to the >> objects allocated in *my* pool. new T calls to the pool's Allocate, but the >> address it returns gets mangled by the compiler, when converted to the >> pointer P [for example, when T is String]. So, having P I cannot get at my >> dope. Its address should be >> >> A = P.all'Address - Offs >> >> where Offs is known, alas, to the compiler only. The compiler must know >> that, otherwise it couldn't pass that to Deallocate. > > So you want access to some compiler-dependent information; clearly the > method will be compiler-dependent, since it isn't defined by the language. No, I don't want to access it. I only want my information. > What are you going to do with the "dopes" you add? They won't be > visible from Ada. That's exactly the goal, because what I want is to extend types in a way Ada does not support. I wanted to add something to a type without quarreling with Ada, which mistakenly [OK, that was a political decision] does not support MI. It was corrected in Ada 2005 but only for pure interfaces, while I need implementations. There is a vast number of cases where it might be useful. It seemed quite easy, thank to user-defined pools. Well, actually it is spoiled a bit with pointers and generics, but that's another story. The idea is as follows: 1. You define a pool which eventually takes its memory from some another pool. 2. When something is allocated in the pool, you just add necessary data to the allocated object in front of the allocated memory block 3. The interface to this is a generic package, which provides a pointer type to the objects in the pool. [Unfortunately, the type of the pointer's pool cannot be made opaque, but that is a minor language problem.] 4. New operations are defined on the pointer type. It is clean and portable design, because all the functionality is hidden behind the pointer type. It does not break the type allocated in the pool in any way. The only unexpected problem with this is that the compiler mangles pointers and there seems to be no way to influence or learn how it does this. I would suggest to introduce a new attribute X'Pool_Address which should return the address, Unchecked_Deallocation would pass to Deallocate, but... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de