comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: packet type ?
Date: 2000/01/18
Date: 2000-01-18T00:00:00+00:00	[thread overview]
Message-ID: <Pine.BSF.4.21.0001180812530.1439-100000@shell5.ba.best.com> (raw)
In-Reply-To: 38845EBD.6F90845D@icn.siemens.de

On Tue, 18 Jan 2000, Alfred Hilscher wrote:
> Ted Dennison wrote:
> > 
> > > question is obsolete. What I'm looking for is something like a
> > "packege
> > > type" (similar to "task type"). What I want do is something like this:
> > 
> > > Any suggestions how to do this ?
> > 
> > That's what generics with package formal parameters are for.
> 
> 
> I think thats not quite the same. Taking the example below, how would
> you do this with generics ?
> 
> 
> package type stack is
>   push (item : in ...);
>   pop  (item : out ...)
> end stack
> 
> procedure application is
>   User_stack : stack;
>   Supervisor_stack : stack;
>   Interrupt_stack : stack;
> 
>   Any_Stack : access Stack;
> begin
>  ...
>   Any_Stack := new Stack; -- how do this  ???
>  ...
> end application;

Packages are not first class entities in Ada. They cannot be assigned to
variables or passed as function arguments. The closest you get is as
T.E.D. suggested, by using generic formal package parameters which give
you a small language for combining the packages.

What is there that you wished to do with first class packages that you
couldn't do equally nicely with plain old ADTs, maybe even using tagged
types to be fancy :-). The stack example is easily programmed that way.

-- Brian






  parent reply	other threads:[~2000-01-18  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-14  0:00 packet type ? Alfred Hilscher
2000-01-14  0:00 ` Ted Dennison
2000-01-18  0:00   ` Alfred Hilscher
2000-01-18  0:00     ` Ted Dennison
2000-01-18  0:00     ` Brian Rogoff [this message]
2000-01-19  0:00     ` Anders Gidenstam
2000-01-19  0:00       ` Brian Rogoff
2000-01-20  0:00         ` Andy S
2000-01-20  0:00           ` Brian Rogoff
2000-01-20  0:00           ` Tucker Taft
replies disabled

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