(j3.2006) Chaining type-bound procedure references

Damian Rouson sourcery
Wed Apr 30 17:29:39 EDT 2014

On Apr 30, 2014, at 4:06 PM, Bader, Reinhold <Reinhold.Bader at lrz.de> wrote:

I have often thought of asking for the same feature Tom is suggesting.

> associate (this => obj % method1())
>   val = this % method2()
> end associate

I like this as a temporary workaround but would prefer the capability Tom is suggesting because my most common use case is where I invoke method1() and method2() through type-bound generic operators.  Doing it in two steps destroys the syntax I?m trying to achieve, independent of whether two two steps involve an assignment or simply an associate block.  

> The only drawback is that deep nesting of ASSOCIATE blocks may arise.

In the context of a complicated expression involving lots of type-bound operators, the deep nesting would really make the code a lot less expressive and clear.    Also, the operator syntax makes it immediately obvious that none of the procedures modifies its arguments because Fortran requires operator arguments to have the "intent(in)? attribute.  Furthermore, in the use case that is of most interest to me, the code is parallel with multiple images evaluating the same expression on different data.   Because I make all of my operators pure, I look at the resulting expression and immediately know that every step in its evaluation can safely execute asynchronously. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20140430/449150c5/attachment.html 

More information about the J3 mailing list