[J3] syntax for conditional expressions

Malcolm Cohen malcolm at nag-j.co.jp
Mon Oct 12 21:44:47 EDT 2020


Hi folks,

 

I have posted Robert’s suggestion to the bulletin board so that people can have the discussion there instead of by email. (I have no problems with email discussions, but the board is probably better, we already have started discussing it there, and it’s better not to have it half in one place and half in the other.)

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Robert Corbett via J3
Sent: Tuesday, October 13, 2020 10:12 AM
To: J3 List <j3 at j3-fortran.org>
Cc: Robert Corbett <rpcorbett at att.net>
Subject: [J3] syntax for conditional expressions

 

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)

 

 

Disclaimer

The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. Please see our Privacy Notice <https://www.nag.co.uk/content/privacy-notice>  for information on how we process personal data and for details of how to stop or limit communications from us.

This e-mail has been scanned for all viruses and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business.

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


More information about the J3 mailing list