comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Possible GNAT problem with aliased parameters.
Date: Sun, 20 Oct 2013 08:33:15 -0700 (PDT)
Date: 2013-10-20T08:33:15-07:00	[thread overview]
Message-ID: <7ce0c2bc-7720-4a90-a31e-e723a9e47d4b@googlegroups.com> (raw)
In-Reply-To: <2f2f46da-e6c2-4e0c-a5d2-3859975b67c9@googlegroups.com>

As long as you are onto the heap anyway, why not just make the client create the array (with items on the heap) save a reference to that, and avoid all the headaches?

type Paths is array (Positive range <>) of Maze_Ptr;

type Maze (p : access constant Paths) is ...

function Create (x : aliased Paths) is
begin
   return Maze'(p => x'access);
end Create;

The use case I would like is essentially this, with some magic feature that lets you satisfy the accessibility check for local values since the code is obviously not creating dangling pointers.  After all, you can pass pointers safely by themselves (access parameters) and nested within a record (access discriminant), so there ought to be some mechanism that allows you to pass them around safely within an array, if for no other reason that consistency.

-sb


  reply	other threads:[~2013-10-20 15:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18 16:01 Possible GNAT problem with aliased parameters Shark8
2013-10-18 16:51 ` sbelmont700
2013-10-19  1:59   ` Randy Brukardt
2013-10-19  5:48     ` Shark8
2013-10-19  7:48       ` Dmitry A. Kazakov
2013-10-19 14:30       ` sbelmont700
2013-10-19 21:17         ` Shark8
2013-10-20  6:29           ` Shark8
2013-10-20 15:33             ` sbelmont700 [this message]
2013-10-21  0:29               ` Shark8
2013-10-21  0:55                 ` sbelmont700
replies disabled

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