comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ripple effect
Date: Thu, 7 Sep 2006 21:08:07 -0500
Date: 2006-09-07T21:08:07-05:00	[thread overview]
Message-ID: <3bCdnYlbgrOyTZ3YnZ2dnUVZ_tadnZ2d@megapath.net> (raw)
In-Reply-To: wccodtr4jhx.fsf@shell01.TheWorld.com

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
news:wccodtr4jhx.fsf@shell01.TheWorld.com...
> "Randy Brukardt" <randy@rrsoftware.com> writes:
>
> > I guess I disagree -- simply knowing about a type doesn't require
objects to
> > be created.
>
> True.  But if you know about a type, why are you not allowed to create
> objects, or parameters, or do anything else that requires its name?

Knowing about a type is a completely separate issue from knowing its name.
That's required here simply because the syntax of declarations requires
giving the name, not because you actually intend to use that name for
anything.

...
> >... (If the object comes from somewhere else -- a common case, such
> > as when an access to it is passed in -- no with is needed).
>
> I'm not sure I understand.  Can you give a realistic example?

Well, a relistic example would be large and take a long time to create. What
I'm thinking about is cases where you have a private type that is simply
passed through a routine to another layer. I find this sort of thing common
in some designs (it depends on how the low-level types are encapsulated).
So, if you have a routine something like:

     procedure Foo (Obj : in Something; Other_Data : in Integer) is
     begin
           if Other_Data < 0 then
               X.Flob (Obj);
           else
               X.Flub (Obj, Other_Data);
           end if;
     end Foo;

Assume that the parameters of Flob and Flub are classwide (and Something is
tagged). In this case, no other information is needed, and it isn't
necessary to "with" the place where X.Flob's parameter is declared, and drag
all kinds of stuff you're not going to use into visibility. This is quite
common, except that the need to repeat the name of the type in the
subprogram declarations often causes an otherwise unnecessary dependency.
"Limited with" can break that in some cases.

...
> > Huh? I often check for unused with clauses in my programs - by hand, and
> > generally not because of compiler warnings (although we get those, too).
I
> > often try to eliminate things that are used only once. I guess I'd agree
> > more if you said "rarely" as opposed to "ever".
>
> OK, "rarely" then.  It's hard to do that sort of thing by hand.
> It's not just unused with_clauses that accumulate during maintenance,
> but all kinds of other unused things (use clauses, variables, etc).

Unused withs are easy to do by hand if you rarely use 'use' clauses: simply
use your editor to show all occurrences of the name of the unit. If there is
no hit other than the with clause itself, its unused. If there is only a use
clause, (and no other uses), I'll comment out the use clause and see what
happens in a recompile (and add comments if it turns out to be needed so I
don't do it next time).

I generally don't bother eliminating other unused things, although the
technique is the same. Well, I'll do variables if cut-and-paste operations
are potentially creating a lot of them. (Janus/Ada does not have any unused
warnings other than for with clauses; it's almost one-pass design makes that
very hard).

                        Randy.





  parent reply	other threads:[~2006-09-08  2:08 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
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 [this message]
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