Dick Hendrickson <
dick.hen...@att.net> wrote:
> On 6/13/14, 3:27 PM, Lichtenberg wrote:
> > How about
> >
> > ...
> > integer :: N
> > real :: A(N),B(N),x
> > ...
> > x = maxval(A(A<0 | B<0)) ?
> >
> OK, I see what you're getting at now. You confused me at first by
> talking abut WHERE. I think of WHERE as a masked assignment statement.
> But
>
> x = maxval(A, A<0 .OR. B<0)
>
> is reasonably close to what you have above. I think all of the
> reduction functions have an optional mask argument.
>
> > I disagree on A(B)-=1 being ambiguous if B is a logical mask array.
>
> What I actually said was "is mildly ambiguous to the code reader". How
> does the reader know that B is logical and not integer? Sure, they
> should read the declarations and remember than, but ....
I might also imagine that people used to some nonstandard Fortran
features might be further confused by it, as might the compilers that
implement those features. In particular, compilers with DEC heritage
often get a bit "sloppy" (my term for it) about intermixing integers and
logicals. So some people and compilers might essentially cast the
logical array to an integer one, which would then mean something, but
something different from the proposal here.
Yes, its a nonstandard feature, and I'm not sure of the details of its
application to this case anyway, but I'd bet on it confusing at least
some readers.
Heck, my first thought on seeing a noninteger used as an array index
would be that it looked like an associative array (which people have
also asked for in Fortran and which seems to me to have a lot bigger
impact than just looking a little better to some people).
I'd also be concerned about the impact on diagnosing errors. That's one
of the things I don't like about the DEC extension mentioned above; some
simple errors in coding turn into code that compiles but does the wrong
thing.
So I guess I'm seeing a claim that some readers used to the notation in
matlab might find it a little more clear, while others might find it
confusing. Seems to me like a wash at best. One might debate which camp
would be more numerous, but I don't see that the benefit is clear enough
to have much chance.
--
Richard Maine
email: last name at domain . net
domain: summer-triangle