(j3.2006) Is 7.2.1.2p1(1) necessary?

Malcolm Cohen malcolm
Thu Mar 12 20:20:46 EDT 2015


>> >Would it be enough
>> >to require that if it is not allocatable, variable and expr shall have
>> >the same dynamic type?
>>
>> Not compile-time checkable.
>
>If we made everything compile-time checkable, nobody would use Fortran.

Since we did make the object-oriented stuff type-safe, i.e. compile-time 
checkable, then it seems that nobody is using Fortran.

>This is yet another of the unhelpful "helpful" restrictions about which
>I wrote yesterday.

It's not a programming style restriction any more than a seat belt is a fashion 
accessory for car users.

>  It's purported benefit can be gotten easily --

Contrariwise.  Programs in other languages written with non-type-safe 
polymorphism are typically littered with type errors, and these are really hard 
to track down.  It would be a disbenefit to our users to provide such an 
error-prone feature, as it would significantly increase the cost of using 
polymorphism safely.

>Its harm is greater than its
>benefit:  Assignment to elements of polymorphic arrays is messy.

Direct assignment to an element of an array whose type is 
unknown-at-compile-time is inherently messy.

Could we design a type-safe assignment for this case?  Yes we could.  Some new 
syntax would be needed, but it's certainly not impossible to do.

Is it worth it?  That is a difficult question.  Obviously it's too late for 
F2015 anyway, but even for the next revision there are umpteen features 
competing for both committee and compiler vendor resources, and although this in 
itself is perhaps not terribly big, it does not look terribly high priority to 
me.  But that is a discussion for another day.

As Tom Clune remarked, oftimes a method (type-bound procedure) provides the best 
solution for times like this.  I agree with his comments.

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




More information about the J3 mailing list