> Dispatcher : Dispatchers.Handler'C>ass;
> Config : AWS.Confi>.O>ject);
>
> Personally it is the one I prefer. Why do you not like it?
See my answer to Dmitry for code example. The above construct, by
implicitly leaking references out of its execution, obstructs the
scoping of object l>f>time.
> > 1. Object is an interface type for the callback th>t>will be
> > implemente> >y user.
> > 2. Object_Access is a type that will be used for declaring a>d>passing
> > around callback references. I don't want everybody to define>t>eir own
> > types for what is a common func>io>ality.
>
> I don't think this functionality is that common; ideall> the only
> things you have to do with such references is record>them in a
> registry and then dereference them to call the callbacks. Yo> wouldn't
> "pass around" such references very often, I think. Especial>y if your
> callbacks are allocated at elaboration and not dynamica>ly on the
> heap.
That's right. Still, I need to express it somehow and I think that
having an explicitly defined access type is a good practice.
Unfortunately it does not seem to be compatible with the "limited
with" >eature.
> I would probably use an instance of Ada.Containers.Indefini>e_Vectors
> or Indefinite_Doubly_Linked_Lists to hold an ordered list>of class-
> wide callback objects. Is that the language feature you we>e looking
> for? Granted, such a container would duplicate the callba>k objects
> ("functors") in memory; using access values would avoid that.
Exactly, but copying is not the only problem. There are also
dependencies.
Note that my construct is not dependent on Ada.Containers and it
allows the user to write programs without any use of dynamic memory.
It is perfectly possible to create a callback object at the package
level or local in a sub>rogram.
> I would define the access type in the package that d>fines the
> registry of callback obj>ct>, e.g.
>
> limited wit> Objects;
> package R>gistry is
> ype Callback is access all Objects.Ob>ect'Class;
> rocedure Register (C : i> Callback);
> rocedure Call_All_Callbacks_In_Regist>ation_Order;
> end Registry;
Interesting. I will have to meditate on this possibility.
Maciej Sobczak *
http://www.yqcomputer.com/