Re: Fortran 2003: Procedures in assignments
- From: Reinhold Bader <Bader@xxxxxx>
- Date: Thu, 07 Dec 2006 17:54:47 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
How about
this%bar = other%foo()
(note the braces)?
Regards
nospam.mehmet@xxxxxxxxx wrote:
Hi,
Hope this question isn't too basic, but a search didn't seem to come up
with anything. Maybe I searched for the wrong thing?
I am trying to get to grips with some of the object oriented
programming
features of Fortran 2003. I am using the NAG compiler version 5.1(282)
which offers some support using to -f2003 flag. I'm working on a
x86_64 running Linux.
I was trying to make a method to copy one object into another. Using
the
following code:
module example_class
type my_class
integer :: bar
contains
procedure :: foo
procedure :: copy
end type my_class
contains
integer function foo(this)
class(my_class), intent(in) :: this
foo = this%bar
end function foo
subroutine copy(this,other)
class(my_class), intent(out) :: this
class(my_class), intent(in) :: other
this%bar = other%foo !This lines doesn't work
end subroutine copy
end module example_class
The third line from the end creates the following compiling error:
"Expression in assignment statement is a procedure"
When I change this line to:
this%bar = foo(other)
then the program compiles. As I understand it the two lines should
mean exactly the same thing! If it makes any difference I've learned
all I know about Fortran 2003 from Metcalf et. al's Fortran 95/2003
Explained book. Could the problem be because the compiler doesn't fully
support the 2003 standard yet?
I find the other%foo method more intuitive and easier to understand
especially if there are a few arguments being passed into the method.
What concept have I missed?
Thank you,
mehmet
------------------
To contact me use:
m dot r dot karatay -at- domain as above
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFeEdWFVLhKuD7VgsRAj6oAKDIFGy8JigZIdkoY1YaN55naCrquwCfeP1A
8jAFBwbH1logX/19KY4Y9cE=
=AQ6n
-----END PGP SIGNATURE-----
.
- References:
- Fortran 2003: Procedures in assignments
- From: nospam . mehmet
- Fortran 2003: Procedures in assignments
- Prev by Date: Re: Can Java program evoke and run a FORTRAN program directly?
- Next by Date: Re: Fortran 2003: Procedures in assignments
- Previous by thread: Fortran 2003: Procedures in assignments
- Next by thread: Re: Fortran 2003: Procedures in assignments
- Index(es):
Relevant Pages
|
|