Subject: Re: Forall

From: John Merlin <[email-masked]>
Date: Fri, 26 Jun 92 17:39:02 BST

> Chuck says:
>
> > From: John Merlin <[email-masked]>
> >
> > ...
> > This seems to be a case for allowing conditional expressions (as in C)
> > in forall-assignments, which is really what you want to express 
> > in the above example.  (I proposed this once before in the context of
> > alignment and distribution directives).  Using these, the above example
> > without stmts S2 and S4 could be written:
> 
> I agree that this would be a better language design (well, I'd use a
> less terse syntax than C).  However, we are trying to make minimal
> changes to Fortran. 

But at least it would lessen the culture shock if and when you introduce 
HPF bindings for C:-)

> > ...
> > If you introduce the conditional expressions for this case, then
> > the other case, where you want S3 to use the *new* values computed by
> > S1, can be expressed with the IF construct using its normal meaning:
> > 
> >  	FORALL ( I = 1 : N )
> >  	  IF ( A(I) < EPS ) THEN		! S0
> >  	    A(I) = 0.0				! S1
> >  	  ELSE
> >  	    A(I) = (A(I-1) + A(I+1)) / 2	! S3
> >  	  END IF
> >  	END FORALL
> > 
> > Then you don't need to introduce a scalar WHERE construct within
> > FORALL for this case, which I also think should be avoided on the
> > same grounds as above.
> 
> The problem is, I'm unconvinced that this *is* the "normal" meaning of
> IF.  My intuition says that reversing the sense of the condition and
> exchanging the THEN and ELSE branches shouldn't change the meaning of
> the IF; that's not true with the semantics here.

(and Rex Page makes the same point).  Yes, I take your point.  
Basically I'm uncomfortable with the above example whatever the semantics 
(which is why I was tempted to suggest conditional expressions in the 
first place, as a more obvious way of expressing one possible meaning 
of the above, in a way that appears compatible with forall-assignemnts).

Really I'm inclined to think that each instance (iteration?) of the IF 
construct should be data independent, otherwise the result should be 
undefined (and perhaps not standard conforming).  Also, there should be 
only one statement in each branch of the IF.  

In fact, my support for IF constructs in FORALL is only at the level 
of 'maybe'.  Sorry I couldn't be of more assistance!

                            John.