comp.lang.ada
 help / color / mirror / Atom feed
* Use of generic child formal package
@ 1995-02-24 22:01 Ed Falis
  1995-02-28 20:35 ` Tucker Taft
  1995-03-08  0:12 ` Jack Beidler
  0 siblings, 2 replies; 4+ messages in thread
From: Ed Falis @ 1995-02-24 22:01 UTC (permalink / raw)


Hopefully, I'm not garbling the lingo too much.

I'd like to provide an instance of a generic child unit as a formal package
actual parameter to another generic.  To wit:

generic
   -- parent's formals
package parent is ... ; end parent;

generic
   -- child's formals
package parent.child is ...; end parent.child;


with parent;
generic
   -- client formals
package client is 

   package parent_instance is new parent(...);

end client;


-- Here's the hitch:
with parent.child;
generic

   -- ??:
   with parent_instance.child is new parent.child (...);
package client.child is ...;


Gnat 2.02 doesn't like the syntax for the formal package parameter: the selected
name notation is rejected. I've tried a few other ways of declaring the formal
package, without success.


So, is it legal, or is it GNAT?

What I'm trying to do is to use multiple child units for distinct generic
implementations of generic component, binding the implementation at the
time of instantiating client.child, which will present an interface to its
own clients.

- Ed


C
So, is it legal, or is it G
C
C
C
So, is it legal?  What I'm trying to do is

   



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

* Re: Use of generic child formal package
  1995-02-24 22:01 Use of generic child formal package Ed Falis
@ 1995-02-28 20:35 ` Tucker Taft
  1995-03-02  2:48   ` Robert Dewar
  1995-03-08  0:12 ` Jack Beidler
  1 sibling, 1 reply; 4+ messages in thread
From: Tucker Taft @ 1995-02-28 20:35 UTC (permalink / raw)


Ed Falis (falis@east.alsys.com) wrote:

: I'd like to provide an instance of a generic child unit as a formal package
: actual parameter to another generic.  To wit:

: generic
:    -- parent's formals
: package parent is ... ; end parent;

: generic
:    -- child's formals
: package parent.child is ...; end parent.child;


: with parent;
: generic
:    -- client formals
: package client is 

:    package parent_instance is new parent(...);

: end client;


: -- Here's the hitch:
: with parent.child;
: generic

:    -- ??:
:    with parent_instance.child is new parent.child (...);
: package client.child is ...;


: Gnat 2.02 doesn't like the syntax for the formal package parameter: the selected
: name notation is rejected. I've tried a few other ways of declaring the formal
: package, without success.
: So, is it legal, or is it GNAT?

The rules for children of generic packages changed in the final months
before the standard was released.  I don't know whether GNAT has 
implemented the final semantics.  However, your usage above is not
correct.  With the final formulation for children of generics,
the effect of a with clause for a child of a generic is to make
a corresponding generic subpackage of the same name appear in
every instance of the parent.  

In other words, when you mention a child of a generic 
in a with clause, it is as though the parent unit had 
*always* included the child as a generic subpackage,
so that any instances of the parent would hence include a 
corresponding generic subpackage.  

Given the above rules, what you should write (though
no guarantees that GNAT will understand it yet):

   with Parent.Child;
   generic
       with package Child_Instance is new Client.Parent_Instance.Child(<>);
   package Client.Child is ...

: What I'm trying to do is to use multiple child units for distinct generic
: implementations of generic component, binding the implementation at the
: time of instantiating client.child, which will present an interface to its
: own clients.

: - Ed

-Tucker Taft   stt@inmet.com
Intermetrics, Inc.



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

* Re: Use of generic child formal package
  1995-02-28 20:35 ` Tucker Taft
@ 1995-03-02  2:48   ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1995-03-02  2:48 UTC (permalink / raw)


GNAT does implement the final semantics for gene3ric children, let us know
if you encounter a result that does not work!




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

* Re: Use of generic child formal package
  1995-02-24 22:01 Use of generic child formal package Ed Falis
  1995-02-28 20:35 ` Tucker Taft
@ 1995-03-08  0:12 ` Jack Beidler
  1 sibling, 0 replies; 4+ messages in thread
From: Jack Beidler @ 1995-03-08  0:12 UTC (permalink / raw)


In article <D4IyJB.5C2@thomsoft.com>, falis@east.alsys.com (Ed Falis) writes:
|> Hopefully, I'm not garbling the lingo too much.
|> 
|> I'd like to provide an instance of a generic child unit as a formal package
|> actual parameter to another generic.  To wit:
|> 
|> generic
|>    -- parent's formals
|> package parent is ... ; end parent;
|> 
|> generic
|>    -- child's formals
|> package parent.child is ...; end parent.child;
|> 
|> 
|> with parent;
|> generic
|>    -- client formals
|> package client is 
|> 
|>    package parent_instance is new parent(...);
|> 
|> end client;
|> 
|> 
|> -- Here's the hitch:
|> with parent.child;
|> generic
|> 
|>    -- ??:
|>    with parent_instance.child is new parent.child (...);
|> package client.child is ...;
|> 
Try the following:

   with parent.child;
   package client is ...

     package My_Parent is new parent (...);
     package My_Child is new parent.child;
                               -- generics parms for child instantiation
                               -- only if the child had extra generic parms

      ...
   end client;

-- 
+----------------------------------------+------------------------+
|John (Jack) Beidler                    ++   beidler@cs.uofs.edu  |
|  Professor, Computing Sciences Dept. ++                         |
|  University of Scranton             ++  (717) 941-7446 (voice)  |
| Scranton, PA 18510                 ++     (717) 941-4250 (FAX)  |
|      WWW site:  http://gopher.cs.uofs.edu/CS/cs.home.html       |
+------------------------------------+----------------------------+



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

end of thread, other threads:[~1995-03-08  0:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-02-24 22:01 Use of generic child formal package Ed Falis
1995-02-28 20:35 ` Tucker Taft
1995-03-02  2:48   ` Robert Dewar
1995-03-08  0:12 ` Jack Beidler

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