(j3.2006) Fortran 2003 Catch 22?

Malcolm Cohen malcolm
Thu Mar 21 04:01:06 EDT 2013


(1) The abstract base class, Parent, has a private data component, which will 
matter in a moment.

The posted code has it public.

If it's private, and there is no way of setting it, I am puzzled as to its 
utility.

>  The extended class, Child, adds in an allocatable polymorphic component.   I 
> would like to have a "constructor" for Child that returns an instance, but 
> there is a problem with assignment of objects of type Child.   Default 
> assignment is illegal because of the polymorphic component (until F2008).

What makes you think that?  F2003 explicitly says of allocatable components in 
intrinsic assignment
  "the corresponding component of variable is allocated with the same dynamic 
type and type parameters as the component of expr"
so clearly we not only intended for polymorphics to work, we actually wrote down 
that it works!

>   So instead I have a type-bound ASSIGNMENT(=) that handles the polymorphic 
> allocation manually.  Unfortunately, I cannot correctly copy the private 
> component in the parent because the parent is itself abstract.  I also tried 
> adding a type-bound assignment(=) procedure to the parent class, but the 
> compiler gave a similar plausible error message that this was not allowed.

Either the compiler is wrong, or your code was wrong.  From your description I 
don't see any difficulty with adhering to F2003 (the trivial sample I put 
together worked).

As far as I can tell, you seem to be struggling with compiler bugs and/or coding 
errors, not with standard deficiencies...

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




More information about the J3 mailing list