comp.lang.ada
 help / color / mirror / Atom feed
* Trouble with renaming types
@ 2001-05-08 15:37 Bob McChesney
  2001-05-08 15:45 ` Bob McChesney
  2001-05-09 13:18 ` Stephen Leake
  0 siblings, 2 replies; 8+ messages in thread
From: Bob McChesney @ 2001-05-08 15:37 UTC (permalink / raw)


Can anyone help me with this problem I have please?

I'm instantiating a generic package Set_Class from within another package. I
instantiate the package as WordSet, and this means a resulting type that I
need to use is WordSet.Set. However, I want to be able to reference this
type under another name from outside the package (I want to call it
Dictionary).

I think I'm supposed to just use a subtype order (subtype Dictionary is
WordSet.Set), however I'm keeping the instantiation of the package private,
which means I can't do this unless I put the subtype order after the
instantiation (which would place it inside the private area and it doesn't
like that).

So can anyone tell me a way of renaming a private type, inside a package?
That would be really good.

So far the only way it's worked is to take everything out of private but
this is not how I need it.

Any help would be much appreciated!

Thanks,
Bob





^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Trouble with renaming types
@ 2001-05-09  4:59 Christoph Grein
  2001-05-09 15:15 ` Bob McChesney
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Grein @ 2001-05-09  4:59 UTC (permalink / raw)
  To: comp.lang.ada

Bob, I'm not sure what you're about; your text is too brief and marred with 
errors:

>  WordSet(Dictionary, Word) I get the compilation error:

I gather you mean

  WordSet.Add (Dictionary, Word);

The problem is here that you qualify Add with the wrong prefix. Dictionary is 
not defined in WordSet but in some other parent (let's also call it Parent), and 
you must use the parent name as prefix:

   Parent.Add (Dictionary, Word);

See the following example as further illustration:

generic
  type Formal is private;
package Gen is
  type Stuff is private;
  procedure Primitive (X: in Stuff);
private
  type Stuff is record
    Comp: Formal;
  end record;
end Gen;
---------
with Gen;
package Inst is new Gen (Formal => Integer);  -- want to rename Inst.Stuff
----------
with Inst;
package What_I_want is          -- kind of renaming
  type Goal is new Inst.Stuff;  -- implicitly inherits Primitive operations
end What_I_want;
-----------------
with What_I_want;
procedure Main is
  X: What_I_want.Goal;
begin
  What_I_want.Primitive (X);
end Main;
  
Christoph





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

end of thread, other threads:[~2001-05-09 15:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-08 15:37 Trouble with renaming types Bob McChesney
2001-05-08 15:45 ` Bob McChesney
2001-05-08 16:45   ` Mark
2001-05-08 17:12     ` Bob McChesney
2001-05-09 13:18 ` Stephen Leake
2001-05-09 15:22   ` Bob McChesney
  -- strict thread matches above, loose matches on Subject: below --
2001-05-09  4:59 Christoph Grein
2001-05-09 15:15 ` Bob McChesney

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