comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: subprogram must not be deeper than access type
Date: Mon, 26 Sep 2011 16:29:47 +0200
Date: 2011-09-26T16:29:47+02:00	[thread overview]
Message-ID: <4e808c5b$0$6622$9b4e6d93@newsspool2.arcor-online.net> (raw)
In-Reply-To: <slrnj80ieh.i18.lithiumcat@sigil.instinctive.eu>

On 26.09.11 11:45, Natasha Kerensikova wrote:

>> Also, whenever an anonymous type
>> seems to solve a design problem,
>> something might be in bad shape
>> at a higher level.
> 
> Actually I wonder whether there is a design problem at all.

Just a design choice.

In general, I should think that if an author too quickly arrives
at pointers, some C heritage shows. I can really picture the
structs and function pointers, I think :-)

If you have an object of

  type String_Accumulator_Linked_List (Builder : Accumulator_Builder)
     is new String_Accumulator_Stack with private;

then the Builder component is fixed. Fine. Presumably, the operations
of String_Accumulator_Linked_List call Builder as necessary.
So Builder has to be in scope where they do that.

For making Builder visible, an access discriminant pointing
to a function is a possible choice;
there are more ways of making a function visible, not necessarily worse
or better, but they may save some trouble or be of different efficiency,
or clarity.
One is scoping.  Another is instantiation of a suitable generic,
one that declares a simpler String_Accumulator_Linked_List.

At the other end, a factory like Accumulator_Builder might (or might not)
deserve a type of its own. The implementation of the operations of
String_Accumulator_Linked_List would again be able to request
new accumulators from the factory, but this time through operations
of this factory type, adjusted, modified, varied, as needed.  For example,
a task could supply the list with new accumulators from some
foreign pool, and could shape the accumulators as requested.
(The shapes being configured when setting up the factory, or
while it is operating already.)

I'd make a factory object a by-reference type if copying is
a concern, and try to avoid indirection without need.
One way to do away with a pointer to the factory is to
have the core algorithm subprogram take a factory parameter:


   procedure Do_Stuff
     (Factory : Accumulator_Builder; ...)

The invisible difference here is that Accumulator_Builder
would not have to be a pointer.


> Having read the Rationale 2005, I understand now that naming an access
> type is far from being equivalent to text replacement. A slightly less
> readable program text is a small price to pay for the extra safety.

As I understand it, anonymous pointers (a) enable references to nested
subprograms in ways just not possible before their introduction,
and (b) circumvent problems with conversions-to-named and with
implementation techniques. So there wouldn't be an argument about safety,
or is there?




  parent reply	other threads:[~2011-09-26 14:29 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-25  9:02 subprogram must not be deeper than access type Natasha Kerensikova
2011-09-25 14:04 ` Oliver Kleinke
2011-09-26  9:35   ` Natasha Kerensikova
2011-10-03 23:30   ` Yannick Duchêne (Hibou57)
2011-10-03 23:39     ` Adam Beneschan
2011-10-04  0:52       ` Yannick Duchêne (Hibou57)
2011-10-04  1:48         ` Yannick Duchêne (Hibou57)
2011-09-25 14:23 ` Robert A Duff
2011-09-25 15:03 ` georg bauhaus
2011-09-26  9:45   ` Natasha Kerensikova
2011-09-26 13:43     ` Robert A Duff
2011-09-26 14:20       ` Dmitry A. Kazakov
2011-09-26 16:15         ` Robert A Duff
2011-09-26 19:30           ` Dmitry A. Kazakov
2011-09-27  0:41             ` Robert A Duff
2011-09-27  8:58               ` Dmitry A. Kazakov
2011-10-04  4:19               ` Yannick Duchêne (Hibou57)
2011-09-27  5:50             ` J-P. Rosen
2011-09-27  7:52               ` Dmitry A. Kazakov
2011-10-04  4:26                 ` Yannick Duchêne (Hibou57)
2011-10-04  7:58                   ` Dmitry A. Kazakov
2011-10-04 15:10                     ` Georg Bauhaus
2011-10-04 15:34                       ` Dmitry A. Kazakov
2011-10-04 15:49                         ` Yannick Duchêne (Hibou57)
2011-10-04 16:04                           ` Dmitry A. Kazakov
2011-10-04 15:44                       ` Yannick Duchêne (Hibou57)
2011-10-04 16:05                         ` Georg Bauhaus
2011-10-04 16:47                           ` Yannick Duchêne (Hibou57)
2011-10-04 15:41                     ` Yannick Duchêne (Hibou57)
2011-09-26 18:59       ` Jeffrey Carter
2011-09-27  0:35         ` Robert A Duff
2011-10-04  4:30         ` Yannick Duchêne (Hibou57)
2011-10-04 18:40           ` Jeffrey Carter
2011-09-26 14:29     ` Georg Bauhaus [this message]
2011-09-26 15:31       ` Georg Bauhaus
2011-10-04  4:35       ` Yannick Duchêne (Hibou57)
2011-10-04  4:13     ` Yannick Duchêne (Hibou57)
2011-09-25 17:16 ` Jeffrey Carter
2011-09-25 21:53   ` Robert A Duff
2011-09-26  9:25     ` Georg Bauhaus
2011-09-26 23:00     ` Randy Brukardt
2011-09-27  0:34       ` Robert A Duff
replies disabled

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