comp.lang.ada
 help / color / mirror / Atom feed
From: "Lucretia" <lucretia9@lycos.co.uk>
Subject: Re: Private primitive operations available to entire package hierarchy. Can it be done?
Date: 2 Aug 2005 08:55:46 -0700
Date: 2005-08-02T08:55:46-07:00	[thread overview]
Message-ID: <1122998146.914353.174110@g44g2000cwa.googlegroups.com> (raw)
In-Reply-To: <OeOdneQx2-z953TfRVn-vw@megapath.net>

<quote>
If you use access types in the parameters, then the users of your
interface
will have to either:

* use an allocator (new) to create objects. In that case, they'll have
to
use Unchecked_Deallocation to get rid of them. That puts a lot of
effort on
the user that they may not need the power of (often stack allocation is
just
fine for objects); or
</quote>

Well this can be hidden away inside a "Create" subprogram as per
GtkAda, and as you have to create this kind of "constructor" for Ada
types anyway, I don't see the problem?

e.g. I currently have a New_Frame which will do any construction
necessary for this type, basically it'll call the C constructor
function which calls "new wxFrame(...)" and returns the pointer back to
Ada which stores it inside wxObject in the wx.Base.Object.Object_Type
as a System.Address.

If I then derive a new frame type (My_Frame), I should also create a
New_My_Frame primitive which calls New_Frame first on the object, then
do any other construction necessary for My_Frame.

<quote>
* declare objects with the ugly "aliased" syntax, and worse, have to
use the
'Unchecked_Access attribute in most calls. Which means a lot of extra
typing
(and more importantly, reading) that has nothing to do with their
program.
</quote>

Well, I have Limited_Controlled as my root tagged type and I still have
to use aliased, so that blatantly doesn't work, unless I'm missing
something.

<quote>
Moreover, if you use access types in this way, you're preventing the
users
from using an Ada.Containers container to do their memory management.
They'd
have to put access values into the container, and do their own memory
management on those values -- pretty much defeating the purpose of a
container.
</quote>

Because the containers have their own access types inside the packages,
right? So, you're saying I should do the following in each of my
packages:

type Some_Type is new Some_Base_Type with private;
type Some_Access is access all Some_Type;
type Some_View is access constant Some_Type;

<quote>
If you need to use it longer, then you have to make sure that you have
a way to destroy the access value if the object gets finalized while
you are still holding onto the access value. Claw uses controlled types
for this; when an object is finalized, the object
is removed from all lists and other objects that it is in (obviously,
that means making sure that the object keeps track of every place that
it is linked).
</quote>

So, you get hold of the access of every type constructed and keep a
reference counted list of them?

With the way you have to start the wxWidgets library up, it's more than
fiddly. I've not been able to get reference counting working reliably.
Also getting the app to finalize last is particularly difficult but I
haven't played with it for a while.

Thanks,
Luke.




  reply	other threads:[~2005-08-02 15:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-07 16:06 Private primitive operations available to entire package hierarchy. Can it be done? Lucretia
2005-07-07 16:17 ` OT: Joke Adrien Plisson
2005-07-07 16:24   ` Matthew Heaney
2005-07-07 19:10 ` Private primitive operations available to entire package hierarchy. Can it be done? Randy Brukardt
2005-07-13 15:40   ` Lucretia
2005-07-19 23:19     ` Randy Brukardt
2005-07-20 18:14       ` Lucretia
2005-07-21  3:10         ` Randy Brukardt
2005-07-25 18:14           ` Lucretia
2005-07-25 23:58             ` Randy Brukardt
2005-07-27 17:36               ` Lucretia
2005-07-27 21:28                 ` Randy Brukardt
2005-07-28 10:09                   ` Lucretia
2005-07-29  0:40                     ` Randy Brukardt
2005-08-02 15:55                       ` Lucretia [this message]
2005-08-03 18:26                         ` Lucretia
2005-08-03 20:04                           ` Randy Brukardt
2005-08-03 20:03                         ` Randy Brukardt
2005-08-08 18:04                           ` Lucretia
2005-08-08 20:47                             ` Randy Brukardt
replies disabled

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