From: Maxim Reznik on
Hi, all

I'm trying to understand how prefixed calls work in Ada 2005. Here is
an example:

package pref_view is
type Tg is tagged null record;
procedure X (Item : Tg; Count : Integer);

Object : Tg;

procedure Y (Count : Integer) renames Object.X;

generic
with procedure Y (Count : Integer);
package Gen is
end;

package Inst is new Gen (Object.X);
end;

ARM 4.1.3 (9.2/2): The selected_component denotes a view of this
subprogram that omits the first formal parameter. This view is called
a prefixed view of the subprogram...

Can I rename this view as new subprogram or use it as an actual
parameter in instantiation?
If NOT, why?

Thanks
--
Maxim Reznik

From: Georg Bauhaus on
Maxim Reznik schrieb:
> Hi, all
>
> I'm trying to understand how prefixed calls work in Ada 2005. Here is
> an example:
>
> package pref_view is
> type Tg is tagged null record;
> procedure X (Item : Tg; Count : Integer);
>
> Object : Tg;
>
> procedure Y (Count : Integer) renames Object.X;

Should the result be a procedure that is always invoked with
Object, and only with Object? This will be currying, right?
From: Maxim Reznik on
On 6 ÄÅË, 20:00, Georg Bauhaus <rm.tsoh+bauh...(a)maps.futureapps.de>
wrote:
> > procedure Y (Count : Integer) renames Object.X;
>
> Should the result be a procedure that is always invoked with
> Object, and only with Object? This will be currying, right?

I think it could be like

procedure Y (Count : Integer) is
begin
X (Object, Count);
end;

But the question is ARM intend such usage of prefixed view or deny it?
From: Randy Brukardt on
"Maxim Reznik" <reznikmm(a)gmail.com> wrote in message
news:8727544b-2f4f-4817-bb2e-20d4d104ae5d(a)w34g2000hsg.googlegroups.com...
....
> ARM 4.1.3 (9.2/2): The selected_component denotes a view of this
> subprogram that omits the first formal parameter. This view is called
> a prefixed view of the subprogram...
>
> Can I rename this view as new subprogram or use it as an actual
> parameter in instantiation?
> If NOT, why?

Yes, you can rename a prefixed view and use it as an actual. Indeed, I
recently wrote an ACATS test to check this (it will be part of the upcoming
ACATS 3.0). You can't use a prefixed view in places where the calling
convention has to match (such as the prefix of 'Access) because it is
considered intrinsic.

Existing compilers didn't do very well with the ACATS test, so I wouldn't
expect this to work with the compiler you have. But it probably will in the
future releases, because *everyone* runs the ACATS, so no one will fail to
be aware of the requirement.

Randy.


 | 
Pages: 1
Prev: Exceptions
Next: Exceptions, part 2