comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Object.Operation and child package
Date: Wed, 25 Jun 2008 20:40:44 +0200
Date: 2008-06-25T20:40:44+02:00	[thread overview]
Message-ID: <87vdzx9x3n.fsf@ludovic-brenta.org> (raw)
In-Reply-To: d98793ee-dd4c-4fb0-89f9-9068b5d33d0d@a70g2000hsh.googlegroups.com

pascal.malaise@gmail.com writes:

> Hi Ada05 experts,
>
> Is it normal to reject compilation of Object.Operation notation when
> operation is in a child package:
>
> package Pack is
>   type Typ is tagged null record;
>   procedure Proc1 (Var : in Typ);
> end Pack;
>
> package Pack.Sub is
>   procedure Proc2 (Var : in Typ);
> end Pack.Sub;
>
> with Pack.Sub;
> procedure Proc is
>   Obj : Pack.Typ;
> begin
>   Obj.Proc1;
>   Obj.Proc2;
> end Proc;
>
> The second call does not compile (with gnat):
> proc.adb:6:04: no selector "Proc2" for type "Typ" defined at pack.ads:
> 3

Yes, this is normal because Proc2 is not a primitive operation of Typ
(or, in other words, it is not a method of Typ).  A primitive
operation, by definition, is declared in the same package as its type.

So, in this situation, the only way to call Proc2 is with the
traditional notation:

   Pack.Sub.Proc2 (Obj);

-- 
Ludovic Brenta.



  reply	other threads:[~2008-06-25 18:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 17:41 Object.Operation and child package pascal.malaise
2008-06-25 18:40 ` Ludovic Brenta [this message]
2008-06-25 19:03   ` Adam Beneschan
2008-06-26  5:56     ` pascal.malaise
2008-06-25 18:51 ` Jeffrey R. Carter
replies disabled

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