comp.lang.ada
 help / color / mirror / Atom feed
* Instantiating private types with discriminants?
@ 2006-05-09 13:17 rick H
  2006-05-09 13:45 ` Georg Bauhaus
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: rick H @ 2006-05-09 13:17 UTC (permalink / raw)



Hello,

I'm slowly learning Ada for my own amusement, and I've ground to a halt
trying to understand something.  If some kind sole could explain it to
me, I'd be very grateful.

I've defined two types, each with a descriminant, and each with its own
access type.  One of the type's implementations is, however, private:

package Discrim is
   type Type_A (Param : Integer := 100) is null record;
   type Type_A_Ptr is access Type_A;

   --  same as above, but implementation now private...
   type Type_B (Param : Integer := 100) is private;
   type Type_B_Ptr is access Type_B;
private
   type Type_B (Param : Integer := 100) is null record;
end Discrim;


When I use "new" on two variables declared as Type_A_Ptr and Type_B_Ptr,
one requires a type conversion for the discriminant, whereas the other
requires a qualified expression:

with Discrim; use Discrim;
procedure Use_Discrim is
   A : Type_A_Ptr;                   --  public  implementation
   B : Type_B_Ptr;                   --  private implementation
begin
   A := new Type_A'(Param => 100);   --  qualified expression
   B := new Type_B (Param => 123);   --  type conversion
end Use_Discrim;

So, my question to the experts is: Why does "privatising" a type's
details change the way that you "new" instantiations of it?

Thanks very much,
Rick



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

end of thread, other threads:[~2006-05-12 18:25 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 13:17 Instantiating private types with discriminants? rick H
2006-05-09 13:45 ` Georg Bauhaus
2006-05-09 14:06   ` rick H
2006-05-09 13:56 ` Ludovic Brenta
2006-05-09 14:24   ` rick H
2006-05-09 19:48     ` Ludovic Brenta
2006-05-09 14:05 ` Dmitry A. Kazakov
2006-05-09 14:48 ` rick H
2006-05-09 15:20   ` Jerry Petrey
2006-05-09 15:42     ` rick H
2006-05-09 15:53   ` Avoiding use Ada.Tags (was Re: Instantiating private types with discriminants?) Alex R. Mosteo
2006-05-09 16:01   ` Instantiating private types with discriminants? Dmitry A. Kazakov
2006-05-10  7:42     ` rick H
2006-05-10  9:09       ` Ludovic Brenta
2006-05-10 11:49         ` Georg Bauhaus
2006-05-10 13:44         ` rick H
2006-05-10 14:21           ` Ludovic Brenta
2006-05-10 15:10             ` rick H
2006-05-10 15:45               ` Ludovic Brenta
2006-05-10 14:41           ` Dmitry A. Kazakov
2006-05-10 15:34             ` rick H
2006-05-10 19:01               ` Georg Bauhaus
2006-05-10 19:05                 ` Ludovic Brenta
2006-05-10 21:52                   ` Rick H
2006-05-11  1:17                     ` Jeffrey R. Carter
2006-05-11  7:44                     ` Dmitry A. Kazakov
2006-05-11  8:27                       ` rick H
2006-05-11 10:28                         ` Dmitry A. Kazakov
2006-05-11 15:59                           ` Robert A Duff
2006-05-12  7:37                             ` Dmitry A. Kazakov
2006-05-12  9:24                               ` Georg Bauhaus
2006-05-12 12:40                                 ` Dmitry A. Kazakov
2006-05-12 18:25                                   ` Randy Brukardt
2006-05-09 19:57   ` "Use" and "=" for Tags (was: Re: Instantiating private types with discriminants?) Jeffrey R. Carter

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