comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: Extended revelation
Date: 2000/02/01
Date: 2000-02-01T04:44:57+00:00	[thread overview]
Message-ID: <875oc9$lk5$1@nntp3.atl.mindspring.net> (raw)
In-Reply-To: 87446a$h6u$1@nnrp1.deja.com

In article <87446a$h6u$1@nnrp1.deja.com>,
	Jean-Marc Bourguet <bourguet@my-deja.com> wrote:


>I think indeed you have not understood what I want to do. What I really
>want is something like modula-3 partial revelation: one package
>providing multiples interface. In Ada95, a package has two interfaces,
>one for the general public, one for his children. What I want is
>multiple public interfaces. Until now, using child package has
>permetted me to do this cleanly and here is the first example I come
>with where I do not find a clean solution in Ada.

You are correct about the excellent approach of Modula-3 in support
of what some would call opaque types, a foundation mechanism
for revelation. This can be done in Ada, but in a more awkward manner 
than in Modula-3.  

  package P1 is
    type T1 is tagged private;
    -- other public declarations
  private
    type Data;
    type T1 is access Data;
  end P1;

  package body P1 is
    type Data is record ... end record;
    -- more declarations
  end P1;

This is quite similar to the style used in Modula-2, if you remember
that far back.  It is similar to, but not as expressive as, the
revelation mechanism in Modula-3.

Sometimes we might want to make the private type extensible.  

  package P2 is
    type T2 is tagged private;  -- usually an abstract type
    -- other declarations
  private
    type Data;
    type Pointer is access Data;
    type T2 is tagged record
       X : Pointer;
    end record;
  end P2;

This provides extensible inheritance while encapsulating all information
about the Data in the implementing code. The package body will be coded
to reflect the actual data.  One benefit of this is the ability to 
acquire the data descriptions, at the implementation level, from some
entirely different package, even a private child unit in the same
hierarchy.  In this respect, Ada has some benefits over Modula-3 in
spite of its awkwardness vis a vis designing an opaque type.  

This goes back, again, to the issue of expressibility versus 
expressiveness. Modula-3 is much more expressive of opaque types 
than Ada.  Ada is slightly more expressive of modular composition and
independence than Modula-3.  There is no perfect programming language. 

There is an upside, in expressiveness, to revelation.  There is a 
downside in the branded reference mechanism required to support
opaque types and revelation.  Often, in Modula-3, an error is not 
discovered until link time.  In Ada, every type mismatch will
be caught at compile time.  This may be one of those things that
is seldom a problem, but it does become significant in a large
scale software system consisting of lots of modules.  

Richard Riehle
richard@adaworks.com




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

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-31  0:00 Extended revelation Jean-Marc Bourguet
2000-01-31  0:00 ` Jean-Marc Bourguet
2000-01-31  0:00   ` Matthew Heaney
2000-01-31  0:00     ` Vladimir Olensky
2000-02-01  0:00   ` Richard D Riehle [this message]
2000-01-31  0:00 ` Matthew Heaney
2000-01-31  0:00 ` Mark Lundquist
replies disabled

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