From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Opaque Types (was Elimination of "use" clauses)
Date: 1999/07/20
Date: 1999-07-20T00:00:00+00:00 [thread overview]
Message-ID: <pnQplRp0#GA.155@newstoo.hiwaay.net> (raw)
In-Reply-To: 7n0hr7$180@dfw-ixnews21.ix.netcom.com
Richard D Riehle <laoXhai@ix.netcom.com> wrote in message
news:7n0hr7$180@dfw-ixnews21.ix.netcom.com...
> In article <FF2ECA.76@stuyts.nl>,
> jerry@jvdsys.stuyts.nl wrote:
>
> >I am unfamiliar with the term 'opaque type', perhaps because I never
looked
> >at Modula-3. Can you explain what it means ?
>
<large snip>
> The second Ada example is designed as an
> "opaque type".
>
> generic
> type StackElementType is private;
> Max : Positive := 100;
> package Stack is
> type Stack_Type is limited private;
> -- declarations for push, pop, etc.
> private
> type Stack_Data;
> type Stack is access all Stack_Data;
> end Stack;
>
> where there is no information about the structure of the stack,
> even in the private part. The details of the stack are deferred
> to the package body. For example,
>
> package body Stack is
> type Stack_Array is array(1..Max) of StackElementType;
> subtype Stack_Index is range 0..Max;
> type Stack_Item is record
> Top : Stack_Index := 0;
> Data : Stack_Array;
> end record;
> -- implement push, pop, etc.
> end Stack;
>
Didn't you mean something more like the following?
(The type declared in the body is not a completion of the
incomplete type Stack declared in the private part).
generic
type StackElementType is private;
Max : Positive := 100;
package Stack is
type Stack_Type is limited private;
-- declarations for push, pop, etc.
private
type Stack_Item;
type Stack_Type is access all Stack_Item;
end Stack;
package body Stack is
type Stack_Array is array(1..Max) of StackElementType;
subtype Stack_Index is Integer range 0 .. Max;
type Stack_Item is record
Top : Stack_Index := 0;
Data : Stack_Array;
end record;
-- implement push, pop, etc.
end Stack;
That asked, I now have another question, or two, viz.:
1. Is the value of an opaque type worth giving up the
flexibility of a discriminated type wherein the
stack size does not need to be a formal parameter
of the generic package, or have I missed a way to
have a discriminated opaque type?
2. In a similar vein, it seems that opaque controlled
types are not possible. Is this true.
Perhaps a more general question is -- is there really
any value in making a limited private type opaque? If so,
what is that advantage?
David C. Hoos, Sr.
next prev parent reply other threads:[~1999-07-20 0:00 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-01 0:00 Elimination of "use" clauses Dr. Neil C. Audsley
1999-07-01 0:00 ` czgrr
1999-07-01 0:00 ` Ted Dennison
1999-07-02 0:00 ` czgrr
1999-07-02 0:00 ` Ted Dennison
1999-07-01 0:00 ` Samuel T. Harris
1999-07-01 0:00 ` Joe Wisniewski
1999-07-02 0:00 ` Robert Dewar
1999-07-02 0:00 ` Ted Dennison
1999-07-02 0:00 ` Ed Falis
1999-07-02 0:00 ` Robert Dewar
[not found] ` <7ltus1$ah1@dfw-ixnews19.ix.netcom.com>
1999-07-13 0:00 ` Robert A Duff
1999-07-18 0:00 ` Richard D Riehle
1999-07-18 0:00 ` Dale Stanbrough
1999-07-20 0:00 ` David Kristola
1999-07-20 0:00 ` Richard D Riehle
1999-07-19 0:00 ` Brian Rogoff
1999-07-20 0:00 ` Robert Dewar
1999-07-20 0:00 ` Brian Rogoff
1999-07-21 0:00 ` Robert Dewar
1999-07-21 0:00 ` Brian Rogoff
1999-07-22 0:00 ` Robert Dewar
1999-07-22 0:00 ` Brian Rogoff
1999-07-22 0:00 ` Robert Dewar
1999-07-22 0:00 ` Brian Rogoff
1999-07-21 0:00 ` Ted Dennison
1999-07-21 0:00 ` Robert A Duff
1999-07-21 0:00 ` Robert Dewar
1999-07-21 0:00 ` Robert A Duff
1999-07-21 0:00 ` Michael F. Yoder
1999-07-21 0:00 ` Robert A Duff
1999-07-23 0:00 ` Tucker Taft
1999-08-03 0:00 ` Richard D Riehle
1999-07-18 0:00 ` jerry
1999-07-19 0:00 ` Vladimir Olensky
1999-07-20 0:00 ` Richard D Riehle
1999-07-20 0:00 ` jerry
1999-07-20 0:00 ` David C. Hoos, Sr. [this message]
1999-07-19 0:00 ` Ted Dennison
1999-07-19 0:00 ` Tucker Taft
1999-07-19 0:00 ` Ted Dennison
1999-07-02 0:00 ` Stephen Leake
1999-07-02 0:00 ` Ed Falis
1999-07-03 0:00 ` Joe Wisniewski
1999-07-03 0:00 ` Keith Thompson
1999-07-03 0:00 ` Ed Falis
1999-07-13 0:00 ` Peter Amey
1999-07-02 0:00 ` Samuel T. Harris
1999-07-02 0:00 ` Robert Dewar
[not found] ` <7ltl2q$mog$1@nnrp1.deja.com>
1999-07-08 0:00 ` Michael F. Yoder
1999-07-09 0:00 ` Richard D Riehle
1999-07-09 0:00 ` Marin David Condic
1999-07-09 0:00 ` Michael F. Yoder
1999-07-09 0:00 ` Robert Dewar
1999-07-09 0:00 ` Michael F. Yoder
1999-07-14 0:00 ` Tucker Taft
1999-07-09 0:00 ` Dale Stanbrough
1999-07-12 0:00 ` Robert Dewar
1999-07-12 0:00 ` Ted Dennison
1999-07-10 0:00 ` Simon Wright
1999-07-12 0:00 ` Robert Dewar
1999-07-08 0:00 ` R. Tim Coslet
1999-07-09 0:00 ` Robert Dewar
1999-07-09 0:00 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox