[J3] Instead of += etc

Van Snyder Van.Snyder at jpl.nasa.gov
Wed Oct 31 19:28:02 EDT 2018


C-like "operators" such as += are occasionally proposed.  Of course, if
one wants +=, one also wants -=, *= and /=, but /= is already .NE.

In section 2.15 of 03-258r1, I proposed a more general facility, called
a "pronoun" therein.

The idea was to allow to put a name followed by a special character, "@"
in the proposal, to give a name to something within an expression (or an
entire expression).  The example in section 2.15 of 03-258r1 was to
allow to replace

  a(3*i+1) = b(3*i+1)

by

  a ( s @ (3*i+1) ) = b(s)

In the description of pronouns used to identify actual arguments, it
should be made clear that the identified entity, not its value, is the
actual argument.  Beyond that, something such as

  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)
  
a += or *= operator cannot be used to simplify things, but with a
"pronoun" it could be written

  v @ x(3*i+1) = v * 42 + b(i)

Of course, a statement could include definitions of several pronouns,
which have statement scope, and a statement could not define a
particular pronoun more than once.




More information about the J3 mailing list