From: Pierre Asselin on 13 Mar 2006 12:23 Richard Edgar <rge21(a)pas.rochester.edu> wrote: > Just don't forget about removing things from the ONLY list when you > delete the _last_ reference to them in the current scoping unit. Oooooh, good one. After a few rounds of code deletions I would want to clean up my ONLY clauses. Comment out the USE statement, compile and grab the error messages, restore just enough of the USE, ONLY to silence them all. Not much different from an IMPLICIT NONE cleanup after removing variables, really. Fortunately (?) the laws of software bloat ensure that additions outnumber deletions. > I wouldn't say that ONLY should never be used, but the more I think > about it, the more of a hassle it seems to be in a good number of cases. Sure it's a hassle. The question is does it pay off. The only way to know is to try it both ways and see. I think the explicit listing of dependencies is a good thing, but I concede it may not amount to much. More important to me is the self-documentation aspect: upon encountering whazzatvariable while reading the code, I only have to search back a few screens to find its declaration, or find the module that declares it. -- pa at panix dot com
From: James Giles on 13 Mar 2006 14:46 Pierre Asselin wrote: .... > Not much different from an IMPLICIT NONE [...] Most things about module use issues are not much different than IMPLICIT NONE. All the arguments against the ONLY clause sound very much like the arguments against IMPLICIT NONE earlier on. -- J. Giles "I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies." -- C. A. R. Hoare
From: Walt Brainerd on 13 Mar 2006 19:09 James Giles wrote: > Pierre Asselin wrote: > ... > >>Not much different from an IMPLICIT NONE [...] > > > Most things about module use issues are not much different > than IMPLICIT NONE. All the arguments against the ONLY > clause sound very much like the arguments against IMPLICIT > NONE earlier on. > I agree in general, but when I tried to force myself to do it, one of the first examples was a substantial module with new types and *many* operator and assignment extensions. I found listing them much more painful than just listing a bunch of variable names. -- Walt Brainerd +1-877-355-6640 (voice & fax) The Fortran Company +1-520-760-1397 (outside USA) 6025 N. Wilmot Road walt(a)fortran.com Tucson, AZ 85750 USA http://www.fortran.com
From: beliavsky on 13 Mar 2006 20:13 Richard Edgar wrote: > James Giles wrote: > > The argument that people don't use ONLY because it's > > too much trouble sound almost identical to the complaints > > about IMPLICIT NONE. I still think everything visible > > in a given scope should be declared there. For module > > entities, all you have to declare is where they came from. > > The ONLY clause declares the entities, and the corresponding > > USE says where thay came from. That's hardly much of > > a hardship. > > Just don't forget about removing things from the ONLY list when you > delete the _last_ reference to them in the current scoping unit. If I forget, g95 reminds me if the options -Wunused-module-vars -Wunused-module-procs are used.
From: Paul Van Delst on 13 Mar 2006 20:25
Walt Brainerd wrote: > James Giles wrote: > >> Pierre Asselin wrote: >> ... >> >>> Not much different from an IMPLICIT NONE [...] >> >> >> >> Most things about module use issues are not much different >> than IMPLICIT NONE. All the arguments against the ONLY >> clause sound very much like the arguments against IMPLICIT >> NONE earlier on. >> > I agree in general, but when I tried to force myself > to do it, one of the first examples was a substantial > module with new types and *many* operator and assignment > extensions. I found listing them much more painful than > just listing a bunch of variable names. (James: be kind to me. I'm not stating my personal dogma here, just thinking aloud. :o) I don't really think it's like an implicit none since the entities in question aren't "in" the module in question. With implicit none you declare variables etc in the file in which they are, well, declared. With USE, ONLY: you have "declare" the imported entities in every file that uses that module. Like I mentioned before, for the situation where there are many developers (e.g. 5-10+) working on various aspects of the same code I think there's a threshold beyond which it becomes onerous to list all the required imported stuff from a USEd module via an ONLY. Then again, maybe that's a good thing? Would it encourage people to write code that is broken down into smaller subsets of functionality rather than tossing a whole bunch of stuff into one monster(ish) module? And even then, will that spread the ONLY "declarations" /down/ the heirarchy or /across/ more, smaller modules cheers, paulv -- Paul van Delst CIMSS @ NOAA/NCEP/EMC |