comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Possible GNAT problem with aliased parameters.
Date: Sat, 19 Oct 2013 07:30:05 -0700 (PDT)
Date: 2013-10-19T07:30:05-07:00	[thread overview]
Message-ID: <f7ead12a-b08a-4829-8122-74a57c4e658f@googlegroups.com> (raw)
In-Reply-To: <0bb058fa-df1b-4092-a6f9-47d12a5f5791@googlegroups.com>

On Saturday, October 19, 2013 1:48:58 AM UTC-4, Shark8 wrote:
> now I'm trying to figure a way to do it

The only way would be to hack it together with access discriminants:

type Maze (n : access Maze'Class;
           s : access Maze'Class;
           e : access Maze'Class;
           w : access Maze'Class) is tagged null record; 
        
function Create (North, South, East, West : aliased in out Maze'Class:= None) return Maze is
begin
   if Just_North then
      return Maze'(n => North'Access, null, null, null);
   elsif North_And_South then
      return Maze'(n => North'Access, South'Access, null, null);
   
   -- continue a bunch more times for all possibilities
   
   end if;

end Create;
   
This is a shame, because the aliased parameter/access discriminant method works so well for simple composition of one object, and extending it to arrays of objects would eliminate what is essentially the last unnecessary use of access types (I bemoaned the inability to pass around arrays of local access types awhile back in another thread, and this is another good example of why).

-sb


  parent reply	other threads:[~2013-10-19 14:30 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 [this message]
2013-10-19 21:17         ` Shark8
2013-10-20  6:29           ` Shark8
2013-10-20 15:33             ` sbelmont700
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