(j3.2006) Fortran 2003 Catch 22?

Tom Clune Thomas.L.Clune
Thu Mar 21 07:44:36 EDT 2013


On Mar 21, 2013, at 4:01 AM, Malcolm Cohen <malcolm at nag-j.co.jp> wrote:

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

Oops - sorry about that.  Hastily simplified version of the real code.   


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

I added (non-deferred) type-bound set/get procedures to the Parent class.  They can have access even though the component is private.

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

Hmm.   An expert with the appropriate qualifications indicated that they thought this was a 2008 extension.   When it worked with gfortran, I assumed that was the explanation.   That probably ends the matter.  I'm content with set/get methods as a workaround for a compiler bug in my primary compiler.



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

Thanks.  The compiler message seemed so sure of itself.  :-)

Cheers,

- Tom

> 
> Cheers,
> -- 
> ................................Malcolm Cohen, Nihon NAG, Tokyo. 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Thomas Clune, Ph. D. 					<Thomas.L.Clune at nasa.gov>
Chief, Software Systems Support Office		Code 610.3
NASA GSFC								301-286-4635
MS 610.8 B33-C128						<http://ssso.gsfc.nasa.gov>
Greenbelt, MD 20771





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20130321/51ce7377/attachment.html 



More information about the J3 mailing list