comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Gem 39 - compiler specific?
Date: Fri, 4 Sep 2009 05:07:47 -0700 (PDT)
Date: 2009-09-04T05:07:47-07:00	[thread overview]
Message-ID: <dded24f9-f083-4fcc-b0f9-a76554055fca@37g2000yqm.googlegroups.com> (raw)
In-Reply-To: 1udpwiw4u1cj5$.ff4ssnbb90vn$.dlg@40tude.net

On 4 Wrz, 09:29, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:

> Do we need that semantics (reinterpret bit pattern as another type)? It is
> difficult to invent a case where an access value would be obtained from a
> bit patterns. It is never needed, IMO.

Hint: interfacing with other languages (notably C and C++) with
libraries that have some callback or object map functionality.

I have done it very recently and I used
System.Address_To_Access_Conversions. The access values to genuine Ada
objects (even of class-wide types) are converted to addresses and
handed to the C++ component, which at some later point in time calls
back into Ada providing the previously stored address that Ada
converts to the original access value.

A very important part of this business is that the C++ component
*never* uses the given address in any other way than to remember it.
It is just a "cookie".

This is an example of scenario where access values are obtained from
what is essentially a bit pattern. The conversions are from access to
address and then from address to access and both are performed by the
Ada code within a single compilation unit. As far as I understand it
is safe, AARM-wise.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



  reply	other threads:[~2009-09-04 12:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 20:38 Gem 39 - compiler specific? Maciej Sobczak
2009-09-02 23:20 ` Randy Brukardt
2009-09-03  7:26   ` Dmitry A. Kazakov
2009-09-03 15:26     ` Adam Beneschan
2009-09-03 16:38       ` Dmitry A. Kazakov
2009-09-03 17:27         ` Adam Beneschan
2009-09-03 20:26           ` Dmitry A. Kazakov
2009-09-03 22:06             ` Randy Brukardt
2009-09-04  7:29               ` Dmitry A. Kazakov
2009-09-04 12:07                 ` Maciej Sobczak [this message]
2009-09-04 13:06                   ` Dmitry A. Kazakov
2009-09-04 17:18                     ` Dmitry A. Kazakov
2009-09-04 20:34                     ` Maciej Sobczak
2009-09-04 22:41                   ` sjw
2009-09-05 20:45                     ` Maciej Sobczak
2009-09-06  6:54                       ` sjw
2009-09-03 21:58           ` Randy Brukardt
2009-09-04 17:26           ` Robert A Duff
2009-09-03 21:53     ` Randy Brukardt
2009-09-03  0:12 ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox