[J3] syntax for conditional expressions

Robert Corbett rpcorbett at att.net
Mon Oct 12 21:12:19 EDT 2020


I am not happy with either of the proposed
syntactic forms of conditional expressions.
The verbose form is far too verbose.  The
line noise form is still too verbose, and
it uses characters I prefer to leave unused. 

I propose the following syntactic form

   <cond-expr> is ( predicate -> consequent
                    [ : predicate -> consequent ] ...
                      : alternative )

where the predicates are scalar logical expressions
and the consequents and alternative are compatible
expressions.

The semantics map to the semantics in the specs
paper as follows

      ( predicate -> consequent
        [ : predicate -> consequent ] ...
          : alternative )

maps to

      if (predicate) then (consequent)
      [ elif (predicate) then (consequent) ] ...
      else (alternative) endif

Example:

      ( present(a) -> a : present(b) -> b : 0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20201013/3ff24368/attachment-0001.htm>


More information about the J3 mailing list