comp.lang.ada
 help / color / mirror / Atom feed
From: pattis@cs.washington.edu (Richard Pattis)
Subject: Re: Unusual "use" semantics
Date: 9 Aug 90 15:59:14 GMT	[thread overview]
Message-ID: <12744@june.cs.washington.edu> (raw)
In-Reply-To: 12435@encore.Encore.COM

In article <12435@encore.Encore.COM>, mwever@encore (Mike Wever) writes:
> i would disagree that "good programing practice prohibits the use of the
> "use" use clause". it it my understanding that the use clause was put in
> for infix operator such as "=". i would submit to this group that the
> addition of the use clause to avoid the ugly case is indeed much cleaner
> code then without. the abuse of the use clause has more to do with using it
> to avoid dotted notions for objects, functions, procedures, and or types
> with are visable from the specs of "withed" packages.
> 
> i spent a year or so looking at a 300K loc system which was written in ada.
> it was very hard to understand because of the fact that the use clause was
> used to avoid dotted notions. my humble advice is then to only use the use
> clause to make directly visable an infix operator, and make all other items
> expressly clear by using dotted notation. when i am changing a piece of
> code i often comment out the use clause and put in the dotted notions, and
> only put it back in if there is an infix operator which should be directly
> visable.

(1) We can also overload "=" by

  FUNCTION "=" (L : POSITIVE_COUNT; R : INTEGER) RETURN BOOLEAN
    RENAMES TEXTIO."=";

So we can use this mechanism selectively, to make some subprograms visible
without using USE to make all entities in a package visible.

(2) When we construct a package that overloads lots of infix operators (say a
complex number package) we can place all the operators inside a nested
package, and then USE only that nested package (not the outer one).
This allows infix notation for all the operators in the nested package, while
forcing selected names for all the other entities declared in the package.

I came on this idea (no doubt invented many times before) to solve exactly
the problem stated above, in a CS-1 book chapter I'm writing.  This was my
only example of nested packages. Does anyone have any other good examples of
nested packges that I could use in my book?

Rich Pattis

  reply	other threads:[~1990-08-09 15:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-08-08 21:21 Unusual "use" semantics Fred Hosch
1990-08-08 22:37 ` Jim Marks
1990-08-09 12:45   ` Mike Wever
1990-08-09 15:59     ` Richard Pattis [this message]
1990-08-09  7:54 ` Rik Palo
1990-08-09 14:51 ` Allan Doyle
1990-08-09 16:15 ` Kurt Olender
1990-08-10 17:44   ` Alan Kaplan
replies disabled

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