David Rasmussen wrote in news:3D2C3A69.8070207 @yahoo.com: > Jean-Pierre Rosen wrote: > > "David Rasmussen" a �crit dans le message > > news: 3D2C2FF9.4020300@yahoo.com... > > > >> Secondly, where is with and use typically used, and what is the > >> difference between them? > >> > > > > A with clause means that a compilation unit needs the services from > > another *compilation unit* (i.e. a package, subprogram or generic > > which is separately compiled). > > > > A use clause factors out a *package*, i.e. you don't have to repeat > > the package name in front of every element. Since a package can (but > > needs not) be a compilation unit, there are cases where both clauses > > can be applied, but they are really orthogonals. > > > > So with corresponds roughly to an #include of some header file that > defines prototypes etc. for some other compilation unit in C++, and use > corresponds roughly to "using namespace Whatever", assuming that the > things included were in a seperate namespace? > > "with" and only appear at the top of a unit. Where can "use" appear? > > /David > You are quite correct here to associate the Ada "use" clause with the C++ "using namespace" using-directive. You are also reasonably correct regarding the "with" clause, but I would qualify the C++ equivalent a bit further. I would say the Ada "with" clause more closely corresponds to a #include of some header file that defines a namespace containing function prototypes and/or other declarations. The Ada "with" clause should appear in what would be the C++ global scope if C++ were limited to a single class, namespace, or function per translation unit. The Ada "use" clause can appear in what would be the C++ global scope or in the C++ block scope. One final note would be that the Ada "use" clause is only valid for packages. It cannot be used for a "with"ed subpgrogram or generic unit. If the generic unit is a package, the "use" clause can be issued after the instantiation. For example: with Some_Generic_Package; procedure Main is package Instance is new Some_Generic_Package( ... ); use Instance; begin -- Main null; end Main; This shows the "with" clause pulling a generic package (a C++ template unit) into the Main procedure's context, instantiating the package in the declarative region, and then making the contents of the new package directly visible via a "use" clause (in a C++ block scope). Hope that helps! -- Regards, Jeffrey D. Cherry Senior IV&V Analyst Northrop Grumman Information Technology