comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: GNAT - return by anonymous access
Date: Mon, 19 Dec 2011 16:14:34 -0800 (PST)
Date: 2011-12-19T16:14:34-08:00	[thread overview]
Message-ID: <b896b012-1f49-494c-a585-3d37a7c0965a@q9g2000yqe.googlegroups.com> (raw)
In-Reply-To: jcoidj$lpr$1@munin.nbi.dk

On Dec 19, 5:46 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> "Simon Belmont" <sbelmont...@gmail.com> wrote in message
>
> news:784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com...
>
>
>
> > This ostensibly simple program prints strange results...
> ...
> >   type test_type (p_obj : access Integer) is limited null record;
> ...
> >   function get return test_type is
> >   begin
> >      return test_type'(p_obj => new Integer'(42));
> >   end get;
>
> You are creating a coextension here. The *language rules* for coextensions
> are full of bugs; we're fixing them virtually every ARG meeting. There is
> little hope for a compiler to get these right in the face of that, beyond
> which doing so is quite expensive.
>
> IMHO, any use of an allocator for an anonymous access type is asking for
> trouble. There is no way to free the memory for such things, and the
> lifetime can easily be extended in various ways, so if the compiler tries
> using a properly local pool for the allocator you end up with a dangling
> poiner. Moreover, they appear to promise something that they cannot deliver
> (heap-based allocation).
>
> Ada 2012 has a restriction No_Anonymous_Allocators; I recommend that all Ada
> programs include and obey this restriction. (Janus/Ada does this by default,
> because we never attempted to use the local pools that supposedly are
> required, and it is better to reject a program rather than implement it
> "wrong".)
>
>                                                     Randy.

Hm, so then are local pools useless? Or do they have their place?
I read some of the rational[e/ization] for them and it seems
reasonable, but I've not actually used them.



  reply	other threads:[~2011-12-20  0:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-17 19:17 GNAT - return by anonymous access Simon Belmont
2011-12-17 19:51 ` Simon Wright
2011-12-18  9:08 ` Georg Bauhaus
2011-12-19 23:46 ` Randy Brukardt
2011-12-20  0:14   ` Shark8 [this message]
2011-12-20 23:18     ` Randy Brukardt
2011-12-21  0:44       ` Simon Belmont
2011-12-21  7:29         ` AdaMagica
2011-12-21 11:05           ` Georg Bauhaus
2011-12-21 11:43             ` AdaMagica
2011-12-21 12:05               ` Georg Bauhaus
2011-12-22  0:33                 ` Randy Brukardt
2011-12-22  0:33           ` Simon Belmont
2011-12-22  7:11             ` Adam Beneschan
2011-12-22 22:11               ` Simon Belmont
2011-12-23  0:56                 ` Randy Brukardt
2011-12-23 13:20                   ` Simon Belmont
2011-12-27 23:51                     ` Randy Brukardt
2011-12-20 23:53 ` anon
replies disabled

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