[net.lang.ada] USE statement and style

larry@JPL-VLSI.ARPA (08/05/86)

[23 lines]

My Ada programming style is still evolving, so I don't claim this as the last 
word on using the USE statement.

The danger of using it is that two subprograms will have the same name and
you'll call the wrong one.  This is mitigated somewhat by the requirement Ada
imposes that the subprogram signature (the types and ordering of parameters)
as well as the subprogram name match in both caller and callee.  Still, the 
bigger the project the likelier it is that one subprogram will shadow another.

So I try to limit the scope of any USE statement as much as possible, putting
it as far inside the scope of a program as I can.  I also try to use only one
USE statement for a particular scope, deciding which program library will give
me the most economical name space.  Another rule of thumb is to use it for
program libraries with names which are less likely to be duplicated.  I
consider this to be the case for the I/O libraries, which are used so much that 
most people know not to re-use the names from them.

Some people suggest you not use the USE statement at all.  This is the safest
suggestion, but I prefer not to go to that extreme.  (Their suggestion does
have the additional merit that fully qualified subprogram names tell you what
library they're from.  When you have to work on a complex system it's a real
advantage to be able to trace down through several layers of calls to find out 
what a program really does.)
                                         Larry @ jpl-vlsi