Dick,
> At 04:55 PM 8/19/98 +0100, Dr W.W. Schulz wrote:
<SNIP>
> >but it failed on these:
> >
> >Imagine1 F (WWS)
> Speaking for Imagine1 (but not Salford) our compiler is "correct" in the
> sense that it is doing what we wanted it to do, but "incorrect" in the
> sense that we wanted it to be too restrictive.
Yes, failure was not quite the right word. F is picky which can be a pain
sometimes but it has its paybacks later on and I haven't seen a bug in F yet
though I have coded several thousand lines of quite some variety.
I also agree with and appreciate many features of F, I use the free version
for development at home and I know the F code will run under any f90 compiler
(or at least it should).
> The problem is that the F90 definition of USE is so flexible. In the
> following example
>
> module one
> real, public :: a,b
> end module one
>
> module two
> real, public :: b
> end module two
>
> program main
> use one, only : y => a
> use one, only : z => a
> use one
> use two
>
> The question is, how many ways can you refer to a? and how many to b?
>
> Our belief is that the F90 answer to both questions is silly (or at least
> surprising) and so we put in lots of restrictions on the use statement.
> It looks like we have too many. It seems natural to want to overload a
> function from several modules and we should have allowed this.
>
> We'll try to fine tune the rules for the next version. Fortunately we
> can relax the restriction without invalidating any existing F code.
That would be most welcome. And yes, F is in a much better position than
Fortran. The desing stages of Fortran don't seem to pay not enough
attention to this problem; USE <module> is but one example. Implicit
save is another one. Etc.
One possible rule for "use <module>" that comes to my mind immediately
is that a qualified use statement, as in
use <module>, only: <list>
or
use <module>, <new>=><old>
cannot be followed by an unqualified use statement for the same module,
and any qualification can be given only once and overrides any previous
name which then becomes unavailable. Applied to your example:
use one, only : y => a
use one, only : z => a ! illegal
use one ! illegal after qualified only
use two
while
use one
use one, only: y => a ! a is only accessible through y
would be an allowed order of statements.
One thing I cannot quite understand is why the Fortran 90 committee
didn't use the Ada (or similar) mechanisms that require module
variables and procedures to be qualified by module-name:
use one ! as above
...
x = one%a +one%b
One could add extra syntax to allow to drop this requirement (see Ada).
That would get rid of many problems.
Cheers,
WWS
-----------------------------------------------------------------------
| Werner W Schulz |
| Dept of Chemistry email: [log in to unmask] |
| University of Cambridge Phone: (+44) (0)1223 336 502 |
| Lensfield Road Secretary: 1223 336 338 |
| Cambridge CB2 1EW Fax: 1223 336 536 |
| United Kingdom WWW: |
-----------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|