(j3.2006) Why is the Passed-Object Argument Explicit?

Malcolm Cohen malcolm
Tue Feb 4 19:26:49 EST 2014


>Do you know why the Fortran standards committee did not choose to make the 
>?this? arg implicit?  (like most other OO languages)

Yes.

1. As noted in the question itself, not all other OO languages have an implicit 
"this" arg.

2. Like other OO languages, the "this" arg is implicit at the call site - it is 
only in the procedure that it is not implicit.

3. At the time, the following (already noted by others) were indeed factors in 
the decision:
(a) making "this" a reserved variable name woud be a complete nonstarter as far 
as Fortran is concerned since we do not have reserved keywords at all;
(b) it is nice to be able to call it what you like;
(c) it is desirable to be able to specify other attributes;
(d) it enables use of the same procedure for multiple types when appropriate.
I would say that (a) and (b) were more significant than (c) or (d).

4. It enables use of ordinary procedures to implement these, instead of having 
to invent some kind of new "magic" procedure with special syntax.  We already 
have enough different kinds of procedure...

5. It enables implicit object passing for a non-initial argument, giving us 
type-bound operators and assignment where the derived type in question is the 
second operand.  Yes you can define all your overloading outside the type using 
INTERFACE blocks, but then type-bound assignment is especially important for 
avoiding the accidental loss of defined assignment that is possible with 
INTERFACE ASSIGNMENT(=) and careless use of the ONLY clause on a USE statement.

6. In my opinion, the overhead of having to declare the passed-object dummy is 
totally insignificant compared with the clarity it gives.  The procedure is just 
a normal procedure following the normal rules and the passed-object dummy is 
(inside the procedure) just a normal dummy argument.  Nothing complicated to get 
confused by.

There are certainly design decisions in F2003 that I regret, but this is not one 
of them.

Cheers,
-- 
................................Malcolm Cohen, Nihon NAG, Tokyo. 




More information about the J3 mailing list