Print

Print


Hi all.

I have a query regarding the FORALL construct, and specifically
non-determinism.

The previous FORALL thread briefly touched on many-to-one
assignments, but never went far enough to answer my query.

For example, given:

        INTEGER A(2), B(2)
        ...
        FORALL (i=1:2, j=1:2)
                A(i) = B(j)
        END FORALL

According to the standard the active index set is:
{ (i=1, j=1), (i=1, j=2), (i=2, j=1), (i=2, j=2) }, and the
body statement(s) must be executed for all indexes in the index
set.

This means that the above FORALL construct is equivalent to the
parallel (simultaneous) assignments:
        A(1) = B(1)
        A(1) = B(2)
        A(2) = B(1)
        A(2) = B(2)

I know that in other places in the standard, such as array
assignment, non-determinism is prohibited, but this is not an
array assignment: each assignment in the given example is
treated as though it were scalar.

The overall result, though, is a non-deterministic FORALL
construct, which I can't find prohibited in the standard.

Am I missing something, or it this as intended?

All replies gratefully received!

Niki