comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Re: Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG)
Date: Sat, 1 Oct 1994 01:24:40 GMT
Date: 1994-10-01T01:24:40+00:00	[thread overview]
Message-ID: <Cwyzx4.H3K@irvine.com> (raw)
In-Reply-To: Magnus.Kempe@di.epfl.ch's message of 29 Sep 1994 13:10:03 GMT

Magnus.Kempe@di.epfl.ch (Magnus Kempe) writes:

> John is still not satisfied that Ada 9X has a clean, elegant solution
> to his problem (two abstractions, Employee and Office, have a recursive
> dependency--how to model/implement that?).

I'd like to chime in and say I'm not satisfied either.  First, the
disclaimers: I'm just starting to learn about OO concepts and Ada 9X,
so I may not know entirely what I'm talking about.  I certainly don't
yet understand the meaning of all the new 9X syntaxes presented in the
examples.  Certainly, some of my ideas are influenced by what little I
know about Eiffel.  Also, I'm by no means an expert at language
design.

However, the solution shown feels like a "workaround", not a clean,
elegant solution.  I guess it could be called a clean, elegant
workaround.  My reasoning is as follows:

If the dependencies went only one way (an Employee contains a
reference to an Office, or vice versa), the implementation would be
straightforward.  Because there are mutual dependencies, though, a new
package Company has to be added.  This means that the package Company
is there "just to get the Ada language to do what you want", not to
represent any concept or abstraction that has anything to do with the
application.  The Company package doesn't add anything to another
programmer's understanding of how the program works--and it may in
fact be a hindrance, since it has a name that could mislead one into
thinking that it actually has some relevance.  Perhaps it would be
better to name it Aybnuiyuiwrfnkb or something.

Similarly, the example uses inheritance (type Employee is new
Employee_Parent is inheritance, right?).  As I understand it,
inheritance's primary purpose is to model "IS-A" or "IS-A-KIND-OF"
relationships between object types (I believe it's sometimes used
purely for code reuse, although that seems like a misuse of the
concept to me).  Here, inheritance doesn't really model anything--it's
just something that got set up in order to get things to work.  Like
the Company package, the use of inheritance here doesn't add anything
to one's understanding of the program.

I assume that the examples given work correctly.  I assume also that
they satisfy the really important requirement--namely, that packages
other than Employee, including Office, have access to everything the
Employee package wishes to put in its interface and to nothing else
having to do with Employees (and similarly for Offices).  Thus, this
is certainly an acceptable workaround for the problem.  But "clean"
and "elegant"?  Maybe I'm being too much of a purist, but I have
trouble characterizing something that requires adding this much code
that has no meaning to someone reading the program, as elegant.  It
seems more like a flaw in 9X that things have to be done this way.
And based on my experience writing large Ada 83 programs, my gut
instinct is that this is the sort of flaw that will be cursed by many
9X users down the line.  I also realize that if we tried to make Ada
9X absolutely perfect, it wouldn't be Ada 9X any more but something
like Ada 23.  :-)

What I think John wants (and I concur) is some way for package
specifications to use accesses to types in other packages that haven't
been compiled yet--sort of like a forward declaration that crosses
package boundaries.  Perhaps something like this could be added to 
Ada 0X or whatever the next revision of the language would be.

    with ...;         -- other stuff
    without Office;   -- "without" means that we're referring to a
                      -- package that hasn't been compiled yet 
    package Employee is
       ...
    private
       type Object is tagged record
          ... -- various components involving that "other stuff"
          Its_Occupied_Office : Office.Pointer;
              -- here we're promising that when Office is compiled,
              -- there will be an ACCESS type named Pointer.  This
              -- will be verified at link time.  
       end record;
    end Employee;

Oh well, just my 2 cents . . .

                                -- Adam

(P.S. John, how about we get together and start our own church?  :-)


--
The above views are my own and do not necessarily represent those of
Irvine Compiler Corp.



  parent reply	other threads:[~1994-10-01  1:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-27 16:52 Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) John Volan
1994-09-27 18:48 ` Mark A Biggar
1994-09-29  1:46   ` John Volan
1994-09-29 13:57     ` Tucker Taft
1994-09-29 17:20       ` Bjarne Stroustrup <9758-26353> 0112760
1994-09-30  1:38         ` Tucker Taft
1994-09-30 12:33           ` Bjarne Stroustrup <9758-26353> 0112760
1994-09-29 18:37       ` John Volan
1994-09-29 19:34         ` David Weller
1994-09-30 22:13           ` John Volan
1994-10-02  3:31             ` Andrew Lees
1994-09-30  1:47         ` Tucker Taft
1994-09-30 13:30           ` John Volan
1994-09-29 18:10     ` R. William Beckwith
1994-10-03  0:33     ` Cyrille Comar
1994-09-28 14:01 ` Norman H. Cohen
1994-09-29  2:12   ` John Volan
1994-09-29 14:01     ` Tucker Taft
1994-09-29 18:37     ` Norman H. Cohen
1994-09-29  9:48   ` Magnus Kempe
1994-09-29 13:10     ` Magnus Kempe
1994-09-29 18:05       ` Tucker Taft
1994-09-30 10:20         ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? Magnus Kempe
1994-09-30 13:22           ` Tucker Taft
1994-10-01  1:24       ` Adam Beneschan [this message]
1994-10-01 12:01         ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Magnus Kempe
1994-10-01 18:43         ` Mark A Biggar
1994-10-02 16:41         ` John Volan
1994-10-02 23:33           ` Matt Kennel
1994-10-03  8:07           ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? Magnus Kempe
1994-10-03 12:14           ` Mut. Recurs. in Ada9X w/o Breaking Encaps.? (LONG) Robert I. Eachus
1994-10-04  2:12             ` R. William Beckwith
1994-10-04 16:00             ` John Volan
1994-10-05 11:42               ` Robert I. Eachus
1994-10-05 21:09               ` Matt Kennel
1994-10-03 20:29           ` Harry Koehnemann
1994-09-29 13:35     ` John Volan
1994-09-30 20:27       ` Norman H. Cohen
1994-10-01  1:47         ` John Volan
1994-10-01 20:44           ` Tucker Taft
1994-10-03 11:29           ` Robert I. Eachus
1994-09-30 22:46       ` Matt Kennel
1994-10-01  2:11         ` John Volan
replies disabled

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