From: Adam Beneschan on
On Apr 1, 1:10 pm, "Randy Brukardt" <ra...(a)rrsoftware.com> wrote:
> "Adam Beneschan" <a...(a)irvine.com> wrote in message
>
> news:f0879dc0-7498-48f7-8d44-9856316d35ce(a)s19g2000prg.googlegroups.com...
> ...
>
> > What's missing here is a way to specify a generic formal subprogram
> > that must be a primitive operation of some tagged type (possibly a
> > generic formal tagged type),
>
> No, it's not missing. That's what abstract formal subprograms are for. See
> specifically 12.6(8.4-8.5/2).

Ah ha, thank you! No, I didn't realize that's what they were for,
perhaps because "abstract" isn't a synonym for "dispatching", but it
makes sense now that you pointed me in the right direction.


> I'm not sure that helps in this case, but feel free to try. ;-).

I think it does help. If my previous example were changed to this:

generic
type Element is private;
type Iterator_Root is tagged private;
with function Get (I : in Iterator_Root) return Element
is abstract <>; -- unspeakable syntax??
... other operations
package SP_For_Class is
procedure Some_Procedure_Class (I : in Iterator_Root'Class);
end SP_For_Class;

with Some_Procedure;
package body SP_For_Class is
function Dispatching_Get (I : in Iterator_Root'Class)
return Element is
begin
return Get (I);
end Dispatching_Get;
... similarly for other operations
procedure SP_Inst is new Some_Procedure
(Element, Iterator_Root'Class,
Dispatching_Get, ...other operations);
procedure Some_Procedure_Class (I : in Iterator_Root'Class)
renames SP_Inst;
end SP_For_Class;

then the call to Get inside Dispatching_Get would be legal. Then, in
Maciej's case, if he wants a Some_Procedure instance that would work
on a class-wide type and dispatch, he could instantiate SP_For_Class
with the specific type, and then Some_Procedure_Class declared in the
instance would be the procedure he's looking for. At least I think
this would work---I haven't tried it. It's a little klunky to declare
the SP_For_Class generic, but at least it wouldn't involve any
duplicated code. And if it works, it will work without waiting for a
solution to AI05-71.

-- Adam