[GAP] Strange OO behaviour when using private primitive subprograms

Diego Alonso Cáceres diego.alonso at upct.es
Tue Jun 5 16:32:06 CEST 2007


I forgot to say that I have used the latest release of the GAP compiler I 
downloaded last May (gnatgap-20070517). And I have checked in the Academia 
web page that it is the latest I can get. This is what 'gnatls -v' says:

	GNATLS GPL 2007 (20070405-41)
	Copyright 1997-2007, Free Software Foundation, Inc.

El Martes, 5 de Junio de 2007 14:03, Matthew Heaney escribió:
> > -----Original Message-----
> > From: gap-bounces at gnat.info [mailto:gap-bounces at gnat.info] On
> > Behalf Of Diego Alonso Cáceres
> > Sent: Tuesday, June 05, 2007 6:34 AM
> >
> > last week I was trying to find a way to make Java-like
> > protected methods using the new OO features of Ada'05 and I
> > found that the compiler behaves in a strange way. I have
> > attached a small project with all the files and I have
> > compiled them with GPS 4.0.2 (20061211) in both Linux a
> > Windows machines.
>
> When I compile main.adb I get the following errors:
>
> main.adb:15:05: no selector "Private_Op" for type "T" defined at
> p_parent.ads:2
> main.adb:23:05: no selector "Private_Op" for type "TT" defined at
> p_parent-child.ads:2
> main.adb:38:05: no selector "Private_Op" for type "T" defined at
> p_parent.ads:2
> main.adb:45:05: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
> main.adb:52:05: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
> main.adb:59:05: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
> main.adb:69:05: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
> main.adb:78:08: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
> main.adb:90:08: no selector "Private_Op" for type "T'Class" defined at
> p_parent.ads:2
>
> Compilation exited abnormally with code 1 at Tue Jun 05 11:50:38
>
>
> Is this what you were expecting?

I don't get these problems. Everything compiles ok. I have also tried with and 
without the '-gnat05' option and still compiles.

> > So, let's focus on the problem. The package P_Parent has a
> > tagged type T and two primitive operations, one defined in
> > the public part and the other in the private one. I have also
> > declared two types that inherit from T, one in a child
> > package P_Parent-Child (TT) and one in a normal package
> > P_Child (U). I was surprised I was able to do T.Private_Op
> > but not Private_Op(T). Even more, TT.Private_Op also worked
> > but U.Private_Op did not!
>
> If you are able to compile that program, then you must have an older, less
> mature version of the compiler.
>
> > This two examples are kind of confusing because they show you
> > don't get the same results using the new dot-notation and the
> > old one.
>
> I don't think you can draw any conclusions, since your compiler is almost 6
> months old.
>
> > It also shows that private primitive operations do
> > not work well, and that they are not equally inherited by all
> > child classes.
>
> They are indeed "equally inherited" -- they're just not visible.
>
> > It depends wheter the child tagged type is
> > declared in a child package or not. Any explanation about
> > this behaviour?
>
> The visibility to an operation (or anything else, really) is controlled by
> the module relationship.  A child unit has visibility to the private part
> of the parent package; non-children do not have such visibility.
>
> _______________________________________________
> GAP mailing list
> GAP at gnat.info
> /no-more-mailman.html
> To unsubscribe from this list, please contact the GAP GNAT Tracker
> administrator within your organization.


More information about the GAP mailing list