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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a3f460aaba1863e2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g44g2000cwa.googlegroups.com!not-for-mail From: "Lucretia" Newsgroups: comp.lang.ada Subject: Re: Private primitive operations available to entire package hierarchy. Can it be done? Date: 2 Aug 2005 08:55:46 -0700 Organization: http://groups.google.com Message-ID: <1122998146.914353.174110@g44g2000cwa.googlegroups.com> References: <1120752411.808598.292980@g49g2000cwa.googlegroups.com> <1121269243.013754.57720@g14g2000cwa.googlegroups.com> <1121883276.400592.326630@o13g2000cwo.googlegroups.com> <1122315253.757948.150350@z14g2000cwz.googlegroups.com> <8_ydncLVTeRn5njfRVn-jA@megapath.net> <1122485760.918191.274380@f14g2000cwb.googlegroups.com> <1122545378.984920.272260@g47g2000cwa.googlegroups.com> NNTP-Posting-Host: 194.74.199.42 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1122998152 12385 127.0.0.1 (2 Aug 2005 15:55:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Aug 2005 15:55:52 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: g44g2000cwa.googlegroups.com; posting-host=194.74.199.42; posting-account=G-J9fgwAAADgpzBiEyy5tO4f8MX5fbpw Xref: g2news1.google.com comp.lang.ada:3903 Date: 2005-08-02T08:55:46-07:00 List-Id: 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 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. * 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. 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. 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. 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; 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). 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.