Re: operation on module arguments
- From: gottoomanyaccounts@xxxxxxxxx
- Date: 21 Sep 2006 16:57:57 -0700
gottoomanyaccounts@xxxxxxxxx wrote:
Maybe I didn't describe very clearly. The relation of c to a and b is
of course supplied by me in the module which defines a, b, and c. If I
want c=a+b, then it is c=a+b, if I want c=a**b, then it should be
c=a**b. But the fact I understand is, even if I defined the relation in
the module, such as
module foo
real :: a, b, c
contains
subroutine getc
c = a + b
end subroutine getc
end module foo
Then in the main program, when a or b is modified, I still need to
explicitly
call getc
to update c. What I want is how I can write a module foo such that in
the main program, when a or b is modified, c is updated automatically,
so I can get rid of "call getc".
The original movitation is that, I have three variables a, b, and c.
The variables a and b are initially read from an external file, and get
changed later on in the main program, but the variable c is so closely
related to a and b, and it plays the same pole as a and b anywhere
else. Thus it is natural to declare a, b, and c in a module and their
relation in this module.
If the cocept of "module as a black box" really applies, then there
should be a mechanism to update c upon a and b just inside their host
module. If I have to manually update c=a+b outside the module, then I
won't bother to define c in module foo, instead I can declare it in the
main program, but this makes the main program less elegant because c is
so close to a and b and I really want put it the same place as a and
b............
I will just add a little bit redundant information below my post.
way to do what I want. But the logic to have this feature in theFrom Richard Maine and other people, I understand now there is no easy
language is pretty reasonable, so I was not too greedy, was I ? :)
When "use module" appears in any program unit, compiler knows it at
compilation time. Then during execution time, whenever variables
defined in the module that has been used here are modified, the rest of
the variables defined in that same module should get updated
automatically, upon the relation also defined in the same module, if
that relation exists. Otherwise why we bother to "use module"? By "use"
it, we really want to use all information in there.
Does all of this even make sense to implement in the language? How many
people would appreciate this feature? :P
.
- Follow-Ups:
- Re: operation on module arguments
- From: Brooks Moses
- Re: operation on module arguments
- References:
- operation on module arguments
- From: gottoomanyaccounts
- Re: operation on module arguments
- From: dpb
- Re: operation on module arguments
- From: gottoomanyaccounts
- Re: operation on module arguments
- From: Paul van Delst
- Re: operation on module arguments
- From: gottoomanyaccounts
- operation on module arguments
- Prev by Date: Re: operation on module arguments
- Next by Date: Re: operation on module arguments
- Previous by thread: Re: operation on module arguments
- Next by thread: Re: operation on module arguments
- Index(es):
Relevant Pages
|