[J3] Instead of += etc
Vipul Parekh
parekhvs at gmail.com
Thu Nov 1 10:43:17 EDT 2018
On Wed, Oct 31, 2018 at 7:29 PM Van Snyder via J3
<j3 at mailman.j3-fortran.org> wrote:
>
> ..
>
> x(3*i+1) = x(3*i+1) + 42 * b(i)
>
> that might have been hoped to have been written
>
> x(3*i+1) += 42 * b(i)
>
> could be written
>
> v @ x(3*i+1) = v + 42 * b(i)
>
> If one had instead
>
> x(3*i+1) = x(3*i+1) * 42 + b(i)
>
> .. with a
> "pronoun" it could be written
>
> v @ x(3*i+1) = v * 42 + b(i)
>
Is the matter really one of verbosity? Because the language already
offers ASSOCIATE construct with essentially the same facility for the
2 cases shown above, albeit with additional keystrokes for the
programmer in simple situations like single instructions:
associate( v => x(3*i+1) ) ; v = v + 42*b(i) ; end associate
and
associate( v => x(3*i+1) ) ; v = v*42 + b(i) ; end associate
A *more Fortran-like* improvement for the cases shown in Van's email
can be an approach similar to the (now unfortunately obsolescent)
FORALL feature where, say, for a *single* operation, an ASSOCIATE
*statement* can be introduced:
associate( v => x(3*i+1) ) v = v + 42*b(i)
associate( v => x(3*i+1) ) v = v*42 + b(i)
Regards,
Vipul Parekh
More information about the J3
mailing list