comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Error: "non-local pointer cannot point to a local object"
Date: Wed, 12 Sep 2018 17:22:55 +0200
Date: 2018-09-12T17:22:55+02:00	[thread overview]
Message-ID: <pnbb0e$180g$1@gioia.aioe.org> (raw)
In-Reply-To: 9a44824f-2897-48f0-92b1-3e9528147ef6@googlegroups.com

On 2018-09-12 16:47, NiGHTS wrote:
> On Wednesday, September 12, 2018 at 3:26:46 AM UTC-4, Dmitry A. Kazakov wrote:
> 
>> What goal? It looks like a bad design. Copying pointers to integers is
>> asking for trouble.
> 
> The integer was chosen to simplify the example. In the actual application it is a tree container, where there is a single thread that is expected to manipulate various contexts of the same tree, thus multiple working records for the same tree.

Why do you need copying? By-reference semantics does not match copying 
(= by-value).

>> BTW, if you used Ada.Finalization.Controlled, as you likely should, and
>> derived one record from another then default copying before Adjust would
>> copy pointer too. What would happen with access info, I have no idea,
>> probably copied as-is. (Yet another reason not to use anonymous access
>> types inside records unless for Rosen's trick or access-to-constant)
>>
> While my example does not show Ada.Finalization.Controlled in use, my application's record indeed is derived from this object. Still, I am not sure how overriding Adjust would be applied to my example. Would you show me a quick and dirty example of how this would be done?

Before Adjust is called an exact copy of the controlled source object is 
made. This naturally applies to its access components as well. Thus you 
probably need not to override Adjust at all.

[ As I said I don't know what happens with the accessibility checks. 
Where assignment of plain records fail, would assignment of controlled 
ones fail as well, if Adjust is null? ]

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


      reply	other threads:[~2018-09-12 15:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 22:20 Error: "non-local pointer cannot point to a local object" NiGHTS
2018-09-12  1:49 ` Brad Moore
2018-09-12 14:41   ` NiGHTS
2018-09-12  6:05 ` rakusu_klein
2018-09-12 14:42   ` NiGHTS
2018-09-12  7:26 ` Dmitry A. Kazakov
2018-09-12 14:47   ` NiGHTS
2018-09-12 15:22     ` Dmitry A. Kazakov [this message]
replies disabled

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