comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ripple effect
Date: 05 Sep 2006 12:23:47 -0400
Date: 2006-09-05T12:23:47-04:00	[thread overview]
Message-ID: <wccpseab7u4.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: fm5Lg.947292$084.573762@attbi_s22

"Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org> writes:

> Robert A Duff wrote:
> > Not sure about "use" but "use type" is a bad idea -- should be the
> > default.
> 
> OK. In the discussion, your language used "use" in context clauses as
> equivalent to Ada's "with" (which sounds like a good idea), and you
> didn't show any equivalent to Ada's "use". I thought I recalled you
> saying that the language didn't have one, but I guess IDRC.

I think I want something like Ada's "use".  Pascal calls it "with" (for
records, as opposed to packages).  It has nasty Beaujolais-like effects,
but that's not necessary.  One of the brilliant things Ichbiah did was
to eliminate Beaujolais effects.  Well, almost -- Ada 9X finished the
job.  And Ichbiah didn't go far enough in that regard -- I would
eliminate hiding entirely.

But I think perhaps the "use"-like thing belongs on the package, rather
than on the clients of the package, because the person who writes the
package needs to use naming conventions that make sense for use or
not-use.

I've considered calling it "open" -- it opens up the scope for
visibility.  An "open" module provides direct visibility of its contents
to clients.  And perhaps an "open" statement in addition, to be used by
clients.

> If you do have an equivalent to Ada's "use", maybe it should be called
> "see".

Perhaps.  But if it goes on the package/module, it should be an
adjective.

> > Yes.  Do you think it should be otherwise? [transitive context clauses]
> 
> It seems awkward. We're working on a project. I create package B, which
> has "with A;" on it. I thought B would need it, but I was wrong, and
> forgot to remove it. You're developing C and need to use B, so you have
> "with B;" on C. Then you realize you need to use A and write some code
> that references A. You forget to put "with A;" on C, but it compiles OK
> because B references A. Then I clean up B and remove the reference to A
> from it. Now C doesn't compile. That seems undesirable.

It does not bother me that a change to the visible part of A affects
clients, transitively.  That has to be true, in general.

My thinking is that if B uses A in a visible way, C pretty-much has to
know about A.  E.g.:

    with A;
    package B is
        procedue Mumble(X: A.T);
    end B;

If C uses B.Mumble, it most likely needs to declare objects of type A.T.
C certainly knows about type A.T!  So non-transitive with's cause a lot
of clutter -- C needs to 'with' everything it uses, plus everything
those things are (visibly) based on, transitively.  So high-level
packages tend to have so many with_clauses that nobody wants to read
them, largely defeating the purpose.

OTOH, if B uses A only for implementation, that's a different story.
Then the import of A belongs on the body of B, and C shouldn't know
about it.  (My language doesn't have private parts.)

By the way, the issue of bogus with_clauses is a real maintenance
problem -- nobody ever deletes a with_clause, so they tend to
accumulate.  This problem is easily solved.  The compiler should give an
error message.  An error that can be suppressed, so that you can
temporarily have bogus with_clauses during development.  That's
essentially what GNAT does, with appropriate warning switches.

- Bob



  parent reply	other threads:[~2006-09-05 16:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-23 22:29 Ripple effect Jeffrey R. Carter
2006-08-24  9:21 ` Maciej Sobczak
2006-08-24 23:39   ` Jeffrey R. Carter
2006-08-25  7:03     ` Maciej Sobczak
2006-08-24 18:22 ` Adam Beneschan
2006-08-24 23:40   ` Jeffrey R. Carter
2006-09-04 13:52 ` Robert A Duff
2006-09-04 15:15   ` Jeffrey R. Carter
2006-09-04 18:06     ` Robert A Duff
2006-09-05  2:33       ` Jeffrey R. Carter
2006-09-05  7:23         ` Dmitry A. Kazakov
2006-09-05 16:28           ` Robert A Duff
2006-09-05 16:23         ` Robert A Duff [this message]
2006-09-05 21:36           ` Jeffrey R. Carter
2006-09-07 18:18             ` Robert A Duff
2006-09-08 22:02               ` Jeffrey R. Carter
2006-09-06  0:10           ` Randy Brukardt
2006-09-07 18:30             ` Robert A Duff
2006-09-07 21:21               ` Simon Wright
2006-09-08  2:08               ` Randy Brukardt
2006-09-09 14:55             ` adaworks
2006-09-05 23:52         ` Randy Brukardt
2006-09-07 19:09   ` Adam Beneschan
2006-09-07 19:21     ` Ed Falis
2006-09-07 19:46       ` Larry Kilgallen
2006-09-08 13:06         ` Ed Falis
replies disabled

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