comp.lang.ada
 help / color / mirror / Atom feed
* Dot notation in Ada 2005
@ 2006-05-19 10:14 Philippe Tarroux
  2006-05-20 12:16 ` Martin Carlisle
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Tarroux @ 2006-05-19 10:14 UTC (permalink / raw)


I am testing some features of the new Ada 2005 version. Here a simple 
problem that seems to me rather a gnat bug than a limitation of the 
norm. With the code:

------
package Objs is

  type Point is tagged null record;

end Objs;

------
package Objs.ext_objs is

  type New_Point is new Point With private;
  function X (P : New_Point) return Integer;

private
  type New_Point is new Point with record
     X1, Y1 : Integer := 0;
  end record;
end Objs.ext_objs;

------
package body Objs.Ext_Objs is

  function X (P : New_Point) return Integer is
  begin
     return P.X1;
  end X;

  procedure Test ( A : Integer; Y : Integer) is
  begin
     null;
  end Test;

  procedure Draw (A : Integer; P : New_Point) is
  begin
     Test (A, P.X);  -- PROBLEM HERE
  end Draw;

end Objs.Ext_Objs;

i get a compilation error ("no selector X for private type P") when P.X 
is not the first argument of the function Test.

It seems to me a rather strange behavior.

Some explanation?

Philippe Tarroux




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-19 10:14 Dot notation in Ada 2005 Philippe Tarroux
@ 2006-05-20 12:16 ` Martin Carlisle
  2006-05-22  6:50   ` Philippe Tarroux
  0 siblings, 1 reply; 7+ messages in thread
From: Martin Carlisle @ 2006-05-20 12:16 UTC (permalink / raw)


Your forgot the -gnat05 flag.  See below:

C:\d\temp>gnatmake -g objs-ext_objs
gcc -c -g objs-ext_objs.adb
objs-ext_objs.adb:21:16: no selector "X" for type "New_Point" defined
at objs-ex
t_objs.ads:12
gnatmake: "objs-ext_objs.adb" compilation error

C:\d\temp>gnatmake -g -gnat05 objs-ext_objs
gcc -c -g -gnat05 objs-ext_objs.adb
gcc -c -g -gnat05 objs.ads

c:\d\temp>

--Martin Carlisle




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-20 12:16 ` Martin Carlisle
@ 2006-05-22  6:50   ` Philippe Tarroux
  2006-05-22  8:19     ` Marc Enzmann
  2006-05-23 15:02     ` Martin Carlisle
  0 siblings, 2 replies; 7+ messages in thread
From: Philippe Tarroux @ 2006-05-22  6:50 UTC (permalink / raw)


Martin Carlisle a �crit :

>Your forgot the -gnat05 flag.  See below:
>
>C:\d\temp>gnatmake -g objs-ext_objs
>gcc -c -g objs-ext_objs.adb
>objs-ext_objs.adb:21:16: no selector "X" for type "New_Point" defined
>at objs-ex
>t_objs.ads:12
>gnatmake: "objs-ext_objs.adb" compilation error
>
>C:\d\temp>gnatmake -g -gnat05 objs-ext_objs
>gcc -c -g -gnat05 objs-ext_objs.adb
>gcc -c -g -gnat05 objs.ads
>
>c:\d\temp>
>
>--Martin Carlisle
>  
>
Unfortunately not:

gnatmake -u -c -u -PD:/users/philippe/src/ada/tests/objs/objs_test.gpr 
objs-ext_objs.adb -d
gcc -c -gnat05 -I- -gnatA 
D:\users\philippe\src\ada\tests\objs\objs-ext_objs.adb
objs-ext_objs.adb:16:16: no selector "X" for type "New_Point" defined at 
objs-ext_objs.ads:9
gnatmake: "d:\users\philippe\src\ada\tests\objs\objs-ext_objs.adb" 
compilation error

What compiler do you use?

Philippe Tarroux



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-22  6:50   ` Philippe Tarroux
@ 2006-05-22  8:19     ` Marc Enzmann
  2006-05-22 10:33       ` christoph.grein
  2006-05-23 15:02     ` Martin Carlisle
  1 sibling, 1 reply; 7+ messages in thread
From: Marc Enzmann @ 2006-05-22  8:19 UTC (permalink / raw)


Hm, somewhat familiar. Something like

   type My_Private_Class is private;
   ...
   procedure Do_Something (Argument : in out My_Private_Class);
   ...
private
   type My_Private_Class is tagged record
      ...
   end record;
   ...

can be called by
   ...
   An_Argument : My_Private_Class;
   ...
   Do_Something (An_Argument);
   ...

but not by
   ...
   An_Argument.Do_Something;

However, if My_Private_Class is not declared as private, then anything
goes....

What am I missing ???
(BTW: using gcc version 3.4.5 20050524 (prerelease) for GNAT GPL 2005
under Mac OS 10.4)




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-22  8:19     ` Marc Enzmann
@ 2006-05-22 10:33       ` christoph.grein
  2006-05-22 11:09         ` Marc Enzmann
  0 siblings, 1 reply; 7+ messages in thread
From: christoph.grein @ 2006-05-22 10:33 UTC (permalink / raw)


My_Private_Class is not visibly tagged. AFAICS, dot notation is allowed
only for objects of types that are visibly tagged at that place (Ada
2005 only of course).




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-22 10:33       ` christoph.grein
@ 2006-05-22 11:09         ` Marc Enzmann
  0 siblings, 0 replies; 7+ messages in thread
From: Marc Enzmann @ 2006-05-22 11:09 UTC (permalink / raw)


Upps !  Just replace:
   ...
   type My_Private_Class is private;
   ...

with
   ...
   type My_Private_Class is tagged private;
   ...

ooohhhkay !  Thanks for the lighting-fast response !




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Dot notation in Ada 2005
  2006-05-22  6:50   ` Philippe Tarroux
  2006-05-22  8:19     ` Marc Enzmann
@ 2006-05-23 15:02     ` Martin Carlisle
  1 sibling, 0 replies; 7+ messages in thread
From: Martin Carlisle @ 2006-05-23 15:02 UTC (permalink / raw)


GNATMAKE Pro 5.05w (20060218-34)
Copyright 1995-2006, Free Software Foundation, Inc.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-05-23 15:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-19 10:14 Dot notation in Ada 2005 Philippe Tarroux
2006-05-20 12:16 ` Martin Carlisle
2006-05-22  6:50   ` Philippe Tarroux
2006-05-22  8:19     ` Marc Enzmann
2006-05-22 10:33       ` christoph.grein
2006-05-22 11:09         ` Marc Enzmann
2006-05-23 15:02     ` Martin Carlisle

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