comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Dowie <martin@re.mo.ve.thedowies.com>
Subject: Re: Object-Oriented style question
Date: Sun, 08 Jan 2012 14:32:29 -0600
Date: 2012-01-08T14:32:29-06:00	[thread overview]
Message-ID: <1867838491347747324.347214martin-re.mo.ve.thedowies.com@news.btinternet.com> (raw)
In-Reply-To: wccfwfqi8gn.fsf@shell01.TheWorld.com

Robert A Duff <bobduff@shell01.TheWorld.com> wrote:
> Georg Bauhaus <rm-host.bauhaus@maps.futureapps.de> writes:
> 
>>    function Info (Item : in T) return Value;
> 
> This is the right way to do it.  Don't use access types when
> you don't need to.  That goes double for anonymous access
> types, and triple for cases involving run-time accessibility
> checks, as the cases below do.
> 
> I can't think of any good reason to use access parameters
> in Ada.  Note: "access parameter" does not mean "parameter of
> an access type", it means "parameter of an ANONYMOUS access type".
> 
> The "in" is just noise; I suggest you leave it out.
> 
>>    function Info_1 (Item_Doubly_Indirect : access T) return Value;
>>    function Info_2 (Item_Doubly_Indirect : access constant T) return Value;
>>    function Info_3 (Item_Doubly_Indirect : not null access constant T) return Value;
> 
> All of the above exclude null.  That is, "not null" is implicit
> for Info_1 and Info_2.  Calling any of these three with "null"
> will raise Constraint_Error.  That's necessary, because they're
> dispatching on a Tag, and if the actual is null, there is no tag.
> 
> So Info_2 and Info_3 have identical semantics.
> 
> - Bob

Presumably when you need to store a reference to an object, you'd then pass
in a 'aliased in out' and take an '(Unchecked_)Access? This is how I map a
UML association to Ada.

-- Martin

-- 
-- Sent from my iPad



  reply	other threads:[~2012-01-08 20:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 12:45 Object-Oriented style question Georg Bauhaus
2012-01-08 12:52 ` Simon Wright
2012-01-08 13:25   ` Dmitry A. Kazakov
2012-01-08 14:18 ` Robert A Duff
2012-01-08 20:32   ` Martin Dowie [this message]
2012-01-08 20:52     ` Robert A Duff
2012-01-09 22:34   ` Adam Beneschan
2012-01-09 23:21     ` Robert A Duff
2012-01-10  8:34     ` Dmitry A. Kazakov
2012-01-09  8:55 ` Maciej Sobczak
2012-01-09 23:58   ` Georg Bauhaus
2012-01-10  8:47     ` Maciej Sobczak
2012-01-10 10:27       ` Dmitry A. Kazakov
2012-01-10 12:27       ` Georg Bauhaus
2012-01-11  8:54         ` Maciej Sobczak
2012-01-10 21:26       ` Randy Brukardt
2012-02-08 12:23 ` Yannick Duchêne (Hibou57)
2012-02-08 12:39 ` Yannick Duchêne (Hibou57)
replies disabled

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