[J3] Why is += missing?

Van Snyder van.snyder at sbcglobal.net
Wed Sep 1 23:47:56 UTC 2021


On Wed, 2021-09-01 at 15:18 -0600, Ondřej Čertík via J3 wrote:
> Others might disagree and prefer ? over +=.

+= might appear more frequently than ? if both are available.

Of course, if you must have +=, what's to stop .AND.=, or .XYZ.= where
.XYZ. is a defined operator?

The alternatives to += are trivial. If the text of the LHS is
voluminous, an ASSOCIATE construct can amelioreate that. If ASSOCIATE
is too onerous, a statement-scope association, as I proposed in Section
2.15 of 03-258r1, can ameliorate that. Both the ASSOCIATE construct,
and the statement-scope association I proposed, are more general than
+=. They cover all of the <xyz>= cases, and others that don't involve
the LHS, and even cases that don't appear in assignment statements. For
example, in an output list, you can give an associate name to a
complicated subscript expression, and then use it several times. +=
can't do that.

Alternatives to ? are more difficult to justify.

For a conditional expression, one needs an IF construct or statement.
The consequents of an IF construct would probably be essentially
identical, except for the part(s) that would otherwise involve ?. If a
statement has N conditional expressions in it, each with only two
consequents, one  needs an IF ... ELSE IF ... ELSE IF ... ELSE ...
ENDIF  construct with 2**N branches. If there are more consequents in
the conditional expressions, the situation is much worse.

For N conditionally-present arguments one needs an IF ... ELSE IF ...
ELSE IF ... ELSE ... ENDIF  construct with 2**N branches. That
calculation was the stimulus for the kludge that a disassociated
pointer corresponding to a nonpointer optional dummy argument is
absent, and similarly for the allocated case. The only reason we have
those kludges is because we refused to do conditional expressions and
conditional arguments when I proposed them.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20210901/3651a9a9/attachment.htm>


More information about the J3 mailing list