Re: Fortran 2003: Procedures in assignments



-----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-----
.



Relevant Pages

  • Fortran 2003: Procedures in assignments
    ... features of Fortran 2003. ... procedure:: foo ... Could the problem be because the compiler doesn't fully ... m dot r dot karatay -at- domain as above ...
    (comp.lang.fortran)
  • Re: What happened to HP Pascal Project...?
    ... You'd need some library support, though, which had to be written by someone. ... I was thinking about a FORTRAN front end for HPGCC, ... Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org ... that a compiler could translate all languages to ARM ML... ...
    (comp.sys.hp48)
  • Re: BIND(C) EXPORT / IMPORT of Fortran variables
    ... the symbols has to have the same name than the C compiler would give ... to "foo". ... Just like Fortran names often get an underscore appended or get ...
    (comp.lang.fortran)
  • Re: a case for multiple inheritance
    ... and overrides the write functions to change ... the compiler would optimize it so that the double function call would be ... private new void Foo ... The cast not much ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: a case for multiple inheritance
    ... the compiler would optimize it so that the double function call would be ... private new void Foo ... The cast not much ... This means that if method A1 overrides ...
    (microsoft.public.dotnet.languages.csharp)