From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Amount of copying on returned constant objects
Date: Wed, 20 Jun 2007 09:34:06 +0200
Date: 2007-06-20T09:31:17+02:00 [thread overview]
Message-ID: <13ds63hyo3h7z.dllpoyf4w28p$.dlg@40tude.net> (raw)
In-Reply-To: f59huq$55d$1@jacob-sparre.dk
On Tue, 19 Jun 2007 16:33:26 -0500, Randy Brukardt wrote:
> "Alex R. Mosteo" <devnull@mailinator.com> wrote in message
> news:5dpp8pF35116bU1@mid.individual.net...
>> Randy Brukardt wrote:
> ...
>>> What really would help would be a way for the container to know when the
>>> access was destroyed, but there isn't any obvious way to do that in Ada.
>>
>> I guess then that some reference counting companion type (or maybe making
>> Cursors tagged and more heavyweight) was discarded because the distributed
>> overhead?
>
> Cursors can be tagged if the implementation so choses, but that doesn't have
> an effect on the element access problem. For that you need something that
> allows direct dereferencing, and in Ada as it stands, that can only be an
> access type.
>
> Having a companion type would work if it was impossible to separate the
> access from the reference counter. But there is no way in Ada to have a
> visible access type that cannot be assigned out of its surrounding wrapper.
> (Which is why I said that Dmitry would say that redefinition of ".all" for a
> private type could solve the problem.)
Actually it would be only a half of the solution. The access type for which
.all gets overridden is an implementation of the cursor. The public view
of, should be a derived type of Element:
--- This is far not Ada!
type Cursor is new Element with private;
-- I can do with a Cursor anything I could do with an Element
function Get (Collection : Container, What : Key) return Cursor;
-- Factory
private
type Cursor is access Element with interface Element;
-- Privately Cursor is an access type that implements the interface
-- of Element. It could be also a fat record rather than access, with
-- a reference to the container and an index within. Whatever, it
-- cannot be seen from outside.
function Is_Nice (Item : Cursor) return Boolean;
-- Implementation of Element's interface by Cursor
-- + Getter/Setter, of course
Here the referential nature of Cursor is hidden and Cursor is a full
substitute of Element
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2007-06-20 7:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-15 16:19 Amount of copying on returned constant objects Alex R. Mosteo
2007-06-15 16:32 ` Ludovic Brenta
2007-06-18 17:26 ` Alex R. Mosteo
2007-06-19 10:22 ` Alex R. Mosteo
2007-06-15 22:03 ` Georg Bauhaus
2007-06-18 17:23 ` Alex R. Mosteo
2007-06-18 17:35 ` Pascal Obry
2007-06-18 18:04 ` Alex R. Mosteo
2007-06-18 20:25 ` Randy Brukardt
2007-06-19 8:26 ` Dmitry A. Kazakov
2007-06-19 10:24 ` Alex R. Mosteo
2007-06-19 21:33 ` Randy Brukardt
2007-06-20 1:31 ` Markus E Leypold
2007-06-20 6:25 ` Georg Bauhaus
2007-06-20 13:00 ` Markus E Leypold
2007-06-20 7:34 ` Dmitry A. Kazakov [this message]
2007-06-18 18:34 ` Georg Bauhaus
2007-06-16 6:48 ` Dmitry A. Kazakov
2007-06-18 17:14 ` Alex R. Mosteo
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox