(j3.2006) Materials for 199

Van Snyder Van.Snyder
Mon Sep 24 19:45:25 EDT 2012


On Mon, 2012-09-24 at 22:15 +0200, Tobias Burnus wrote:
> I sometimes missed ANDTHEN and ORELSE, but that seems to be a
> recurring suggestions, where the exact ordering and details seem to be
> difficult. (Cf. e.g. J3/04-410r1.)

What Dick suggested in 04-410r1 for the ANDTHEN and ORELSE functions is
known in the functional programming community as "lazy evaluation."

A different way to achieve what Dick suggested in 04-410r1 is to allow
that several intrinsic functions can have lazy evaluation.

Lazy evaluation could be specified by changing some functions'
definitions, new function names, an attribute of the INTRINSIC
statement, an argument that requires a constant expression as an actual
argument, ....

Using the scheme Dick advocated, i.e., evaluating arguments in the order
they appear, MERGE would have been useful if only the arguments had been
presented in the order (MASK, TSOURCE, FSOURCE).

Better would be to specify, for each intrinsic function that is allowed
to have lazy evaluation, how and in what order the arguments are
evaluated.  For example, for ALL or ANY, it would be array element
order.  For MERGE it would be MASK, then TSOURCE if (where) MASK is
true, else FSOURCE if (where) MASK is false.  Lazy elemental MERGE in
specification expressions might not make sense -- but see 04-196.





More information about the J3 mailing list