[J3] Question not just for HPC

Malcolm Cohen malcolm at nag-j.co.jp
Thu Oct 17 22:36:41 EDT 2019


> So is there an inconsistency?

 

The inconsistency is that pointer assignment should not have been described as variable definition context in the first place, because it does cause “definition” of any actual object, it merely alters some pointer association.

 

This can be seen if you have more than one level of pointer component. For example, in the case where X, X%P, and X%P%Q are all pointers,

   X%P%Q => something

does not change the definition status of X in any way (nor, in fact, that of X%P),

   X%P => something

does not change the definition status of X either, but can cause the definition status of X%P and X%P%Q to change,

  X => something else

certainly changes the definition status of X, and can cause the definition status of X%P and X%P%Q to change, but none of the actual targets are at all affected in any way, it’s just that X is now associated with something else.

 

That is, the “can cause” ones are all red herrings. Using Y, Y%P and Y%P%Q to refer to the targets as they were immediately before the pointer assignment,

  X%P => something

although it changes the definition status of X%P and possibly X%P%Q, Y%P and Y%P%Q are completely unchanged by this operation. That is, it is just that X%P is now associated with a different target, nothing in the targets changed! Except for the target of X itself, but the definition status of X does not depend on the association status of its pointer components.

 

The whole thing was a mess, and IMNSHO in F2018 it is still rather a mess, but less of a mess than it was.

 

OTOH do we have a spare week or three to rewrite all this stuff so it works better? Of course we don’t. To be fair, the description mostly works well enough in most cases, so there is not much motivation is rewrite from the ground up.

 

>It looks to me as if the compilers that rejected the statement x%q => p were correct for F08.

 

That is a fair point.

 

OTOH, if there is more than one level of pointer, even in F2008 it wouldn’t be a definition context. That is, if X%P%LOCK is a lock, and P and LOCK are pointers, then even in F2008 X => Y is not a variable definition context for a type with a lock subobject.

 

I don’t really want to write a full example using multiple levels of pointer though, because setting up the associations becomes trickier, so it would take me some time to craft, and would be very hard to follow; certainly it would not be a “good” example. But I don’t think it’s impossible. Of course I could be wrong on that, but anyway now we are in the F2018 era so that’s the one we need to worry about. And the simple example is fine for F2018.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20191018/f7ec8759/attachment.html>


More information about the J3 mailing list