On Aug 31, 11:33am, [log in to unmask] wrote:
> Subject: Re: Start the Wish List (Was: Re: Confused about intent of INTENT
> Is this really the case? Consider:
...
> !!! with READONLY:
...
> sub = j * i
...
> !!! without READONLY -- "get" function needed:
...
> sub = j * i_get()
...
>
> My guess is that many compilers will be faster with the first
> form.
>
> Yes, I'd agree. But these are not the same code.
Of course not -- but the second is what you have to do without
READONLY, unless you want to make your PRIVATE data PUBLIC, which
is not, in general, acceptable.
...
> Note that some compilers might generate equivalent code for these cases, at
> least with suffcient optimization enabled.
...
Yes; then again, some might not.
Just to bring this down to real code for a moment, I *do* use "get"
functions in F90 modules for PRIVATE variables, and I *would* use
READONLY instead, were it available.
For example, in code implementing hash tables and associative arrays,
I have functions that return various requested characteristics of
a given hash table -- such as its size, number of entries, etc. Now,
you really don't want to make this data PUBLIC, do you? The debugging
nightmare that would ensue if user code altered these values is scary
just to contemplate.
I've not benchmarked the "get" code; maybe the calls are optimized
away by your compiler -- I'm not certain.
When you write an application, you should assume that the user is
an idjit. When you write a MODULE, you should assume the same
about the USEr. READONLY would allow some things to be done more
efficiently (at least with some compilers) without having to
compromise this cynical view of the world -- which is clearly
quite precious to me :-).
-P.
--
**************** "Cultured people are the scum that floats ****************
*************** on the deep river of production" (Churchill) **************
*Peter Shenkin; Chemistry, Columbia U.; [log in to unmask] (212)854-5143*
*MacroModel WWW page: http://www.columbia.edu/cu/chemistry/mmod/mmod.html *
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|