Steve Schlaifer wrote:
>
> In message <[log in to unmask]>, [log in to unmask] writ
> es:
> > Because many programmers expect short circuiting behavior for .AND., leading
> > to erroneous code that usually works, and because the current syntax for
> > specifying short circuiting, i.e.,
> >
> > IF (K .GT. 0) THEN
> > IF (X(K) .GT. 0.) THEN
> > . . .
> >
> > can lead to duplicated code if an ELSE branch is required, I have sometimes
> > wished for more direct way to express short circuiting behavior in Fortran.
>
> Is there something unacceptable about:
>
> LOGICAL LFLAG
> ...
> LFLAG = K .GT. 0
> IF (LFLAG) LFLAG = X(K) .GT. 0
> IF (LFLAG) THEN
> ...
> ELSE
> ...
> ENDIF
In the same spirit, what is wrong with this?:
LFLAG = K .GT. 0
IF( LFLAG .AND. X( merge( K, something_valid, LFLAG ) ) ) THEN
...
ELSE
...
ENDIF
Something like the proposed ".ANDTHEN." might be useful in more
esoteric cases, but this case is really not that hard to handle.
-- Roger Glover
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|