(j3.2006) Is 7.2.1.2p1(1) necessary?
Van Snyder
Van.Snyder
Thu Mar 12 16:10:53 EDT 2015
On Thu, 2015-03-12 at 13:03 -0700, Van Snyder wrote:
> Malcolm Cohen malcolm at nag-j.co.jp Wed Mar 11 22:44:07 MDT 2015 wrote:
>
> >7.2.1.2p1(1) says "if the variable is polymorphic it shall be
> >allocatable and not a coarray."
>
> Yes, this is necessary.
>
> >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.
> >So checking the
> >dynamic types, and raising an error condition if they're different,
> >isn't any more difficult that what's required now.
>
> The whole point is to avoid raising error conditions since that crashes the
> program!
If one knows for sure that the expression and the variable have the same
dynamic type, there wouldn't be a crash.
Otherwise, make the variable allocatable.
Without relaxing 7.2.1.2p1(1), how does one assign to an element of a
polymorphic array? It seems that at least one level of SELECT TYPE is
necessary.
This is yet another of the unhelpful "helpful" restrictions about which
I wrote yesterday. It's purported benefit can be gotten easily --
simply make the variable allocatable. Its harm is greater than its
benefit: Assignment to elements of polymorphic arrays is messy.
More information about the J3
mailing list