From f8e4edc5e963c8579c2f205bb2f1189eec162b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 15:05:18 -0600 Subject: [PATCH 01/13] Initial draft of cond. expr. intrinsic paper --- proposals/conditional_expressions/cond.txt | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 proposals/conditional_expressions/cond.txt diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt new file mode 100644 index 0000000..9ea267c --- /dev/null +++ b/proposals/conditional_expressions/cond.txt @@ -0,0 +1,30 @@ +To: J3 J3/XXX +From: Ondrej Certik +Subject: Conditional expressions using intrinsic function +References: 21-157, 21-159 +Date: 2021-June-26 + +Paper 21-157 proposes two syntactic forms for +conditional expressions. The paper 21-159 proposes +an alternative form. This paper proposes to implement +conditional expressions using intrinsic functions + +The syntactics forms in 21-157 is too verbose, as argued in 21-159. The form in +21-159 is concise, but based on the poll [1], it is not the most popular +either. + +We propose the following syntactic form + + is ifthen( predicate, consequent, + [ ifthen( predicate, consequent, ]* + alternative) [)]* + +where the predicates are scalar logical expressions +and the consequents and alternative are compatible +expressions. The `)` must match the number of `ifthen(` used. + +Examples: + + ifthen(x >= 0.0, sqrt(x), -0.0) + + ifthen(present(x), a, ifthen(present(b), b, 0)) From 3344ade9c76b72a4f28d10541d4d3ad82fb8c3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 15:10:54 -0600 Subject: [PATCH 02/13] Add a missing reference --- proposals/conditional_expressions/cond.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 9ea267c..79b6e04 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -28,3 +28,7 @@ Examples: ifthen(x >= 0.0, sqrt(x), -0.0) ifthen(present(x), a, ifthen(present(b), b, 0)) + +References: + +[1] https://fortran-lang.discourse.group/t/poll-fortran-202x-conditional-expressions-syntax/1425 From e11bafdadb3af0bf08efd1452024d8a0a3fe875e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 15:12:42 -0600 Subject: [PATCH 03/13] Better formulation --- proposals/conditional_expressions/cond.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 79b6e04..dbcff73 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -21,7 +21,7 @@ We propose the following syntactic form where the predicates are scalar logical expressions and the consequents and alternative are compatible -expressions. The `)` must match the number of `ifthen(` used. +expressions. The number of `)` must match the number of `ifthen(` used. Examples: From 4841b4a239b38c873b789b524faf0d3d3c910b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 21:47:20 -0600 Subject: [PATCH 04/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index dbcff73..91a15fb 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -7,7 +7,7 @@ Date: 2021-June-26 Paper 21-157 proposes two syntactic forms for conditional expressions. The paper 21-159 proposes an alternative form. This paper proposes to implement -conditional expressions using intrinsic functions +conditional expressions using an intrinsic function. The syntactics forms in 21-157 is too verbose, as argued in 21-159. The form in 21-159 is concise, but based on the poll [1], it is not the most popular From eea6edbb14db061360f85ffe74b12a59b5c0e0f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 22:05:05 -0600 Subject: [PATCH 05/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 91a15fb..5b59fff 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -9,7 +9,7 @@ conditional expressions. The paper 21-159 proposes an alternative form. This paper proposes to implement conditional expressions using an intrinsic function. -The syntactics forms in 21-157 is too verbose, as argued in 21-159. The form in +The syntactic forms in 21-157 are too verbose, as argued in 21-159. The form in 21-159 is concise, but based on the poll [1], it is not the most popular either. From 02aecf4f945e712924f16a534a0b84764059ea88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 22:05:31 -0600 Subject: [PATCH 06/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 5b59fff..778a522 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -25,9 +25,9 @@ expressions. The number of `)` must match the number of `ifthen(` used. Examples: - ifthen(x >= 0.0, sqrt(x), -0.0) + res = ifthen(x >= 0.0, sqrt(x), -0.0) - ifthen(present(x), a, ifthen(present(b), b, 0)) + res = ifthen(present(x), a, ifthen(present(b), b, 0)) References: From 0d6f5eaf122b7c31f1975277928c32b016d627aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 22:38:06 -0600 Subject: [PATCH 07/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 778a522..14de7e3 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -15,9 +15,7 @@ either. We propose the following syntactic form - is ifthen( predicate, consequent, - [ ifthen( predicate, consequent, ]* - alternative) [)]* + is ifthen( predicate, consequent, alternative ) where the predicates are scalar logical expressions and the consequents and alternative are compatible From 80c211ed1d483c0944ab316688631e46ab347081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 22:51:42 -0600 Subject: [PATCH 08/13] Add answers to objections --- proposals/conditional_expressions/cond.txt | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 14de7e3..28d194a 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -1,5 +1,5 @@ To: J3 J3/XXX -From: Ondrej Certik +From: Ondrej Certik, Milan Curcic, Zach Jibben Subject: Conditional expressions using intrinsic function References: 21-157, 21-159 Date: 2021-June-26 @@ -17,9 +17,10 @@ We propose the following syntactic form is ifthen( predicate, consequent, alternative ) -where the predicates are scalar logical expressions -and the consequents and alternative are compatible -expressions. The number of `)` must match the number of `ifthen(` used. +where the `predicate` are scalar logical expressions +and the `consequent` and `alternative` are compatible +expressions. The `alternative` can be another `ifthen` as shown in an example +below. Examples: @@ -27,6 +28,27 @@ Examples: res = ifthen(present(x), a, ifthen(present(b), b, 0)) +Objections raised in the past: + +1) It is harder to do chaining due to the extra parenthesis at the end. + +Answer: it seems in practice it is not too bad, as in the second example above. +Here is a longer chain: + + res = ifthen(present(x), x, ifthen(present(y), y, + ifthen(present(z), z, 0))) + +2) `ifthen` does not behave like a regular function, it is effectively new +syntax, so we might as well actually introduce new syntax, to make it less +confusing + +There is a precedent in optional arguments, where the argument is not evaluated +but passed through through nested functions until it hits the function +`present`. In a similar way, the arguments to `ifthen` are not evaluated ahead +of time, but rather passes into the function `ifthen` itself, similar to how +`present(x)` works. Both `ifthen` and `present` must be implemented by the +compiler itself, they cannot be implemented in standard Fortran code. + References: [1] https://fortran-lang.discourse.group/t/poll-fortran-202x-conditional-expressions-syntax/1425 From 7e390907acd580f83117b77468134bd1008a10d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 23:02:03 -0600 Subject: [PATCH 09/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 28d194a..69febb9 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -17,7 +17,7 @@ We propose the following syntactic form is ifthen( predicate, consequent, alternative ) -where the `predicate` are scalar logical expressions +where the `predicate` is a scalar logical expression and the `consequent` and `alternative` are compatible expressions. The `alternative` can be another `ifthen` as shown in an example below. From ec3361e8f78b1bead6c14df986363f90a47a7083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 23:02:17 -0600 Subject: [PATCH 10/13] Update proposals/conditional_expressions/cond.txt Co-authored-by: Milan Curcic --- proposals/conditional_expressions/cond.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 69febb9..3841e37 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -45,7 +45,7 @@ confusing There is a precedent in optional arguments, where the argument is not evaluated but passed through through nested functions until it hits the function `present`. In a similar way, the arguments to `ifthen` are not evaluated ahead -of time, but rather passes into the function `ifthen` itself, similar to how +of time, but rather passed into the function `ifthen` itself, similar to how `present(x)` works. Both `ifthen` and `present` must be implemented by the compiler itself, they cannot be implemented in standard Fortran code. From 1e1355c12a9c4d8cf395046e0b90e18167424055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 23:11:33 -0600 Subject: [PATCH 11/13] Use the upload template --- proposals/conditional_expressions/cond.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 3841e37..80e2dde 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -1,8 +1,8 @@ -To: J3 J3/XXX +To: J3 J3/##-### From: Ondrej Certik, Milan Curcic, Zach Jibben Subject: Conditional expressions using intrinsic function -References: 21-157, 21-159 Date: 2021-June-26 +Reference: 21-157, 21-159 Paper 21-157 proposes two syntactic forms for conditional expressions. The paper 21-159 proposes From cf8b86fde8a62af42eea7e89f700f576e1eab6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 23:13:40 -0600 Subject: [PATCH 12/13] Make every line shorter than 75 --- proposals/conditional_expressions/cond.txt | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/cond.txt index 80e2dde..b30103c 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/cond.txt @@ -4,23 +4,21 @@ Subject: Conditional expressions using intrinsic function Date: 2021-June-26 Reference: 21-157, 21-159 -Paper 21-157 proposes two syntactic forms for -conditional expressions. The paper 21-159 proposes -an alternative form. This paper proposes to implement +Paper 21-157 proposes two syntactic forms for conditional expressions. The +paper 21-159 proposes an alternative form. This paper proposes to implement conditional expressions using an intrinsic function. -The syntactic forms in 21-157 are too verbose, as argued in 21-159. The form in -21-159 is concise, but based on the poll [1], it is not the most popular -either. +The syntactic forms in 21-157 are too verbose, as argued in 21-159. The +form in 21-159 is concise, but based on the poll [1], it is not the most +popular either. We propose the following syntactic form is ifthen( predicate, consequent, alternative ) -where the `predicate` is a scalar logical expression -and the `consequent` and `alternative` are compatible -expressions. The `alternative` can be another `ifthen` as shown in an example -below. +where the `predicate` is a scalar logical expression and the `consequent` +and `alternative` are compatible expressions. The `alternative` can be +another `ifthen` as shown in an example below. Examples: @@ -32,8 +30,8 @@ Objections raised in the past: 1) It is harder to do chaining due to the extra parenthesis at the end. -Answer: it seems in practice it is not too bad, as in the second example above. -Here is a longer chain: +Answer: it seems in practice it is not too bad, as in the second example +above. Here is a longer chain: res = ifthen(present(x), x, ifthen(present(y), y, ifthen(present(z), z, 0))) @@ -42,13 +40,15 @@ Here is a longer chain: syntax, so we might as well actually introduce new syntax, to make it less confusing -There is a precedent in optional arguments, where the argument is not evaluated -but passed through through nested functions until it hits the function -`present`. In a similar way, the arguments to `ifthen` are not evaluated ahead -of time, but rather passed into the function `ifthen` itself, similar to how -`present(x)` works. Both `ifthen` and `present` must be implemented by the -compiler itself, they cannot be implemented in standard Fortran code. +There is a precedent in optional arguments, where the argument is not +evaluated but passed through through nested functions until it hits the +function `present`. In a similar way, the arguments to `ifthen` are not +evaluated ahead of time, but rather passed into the function `ifthen` +itself, similar to how `present(x)` works. Both `ifthen` and `present` must +be implemented by the compiler itself, they cannot be implemented in +standard Fortran code. References: -[1] https://fortran-lang.discourse.group/t/poll-fortran-202x-conditional-expressions-syntax/1425 +[1] https://fortran-lang.discourse.group/t/ + poll-fortran-202x-conditional-expressions-syntax/1425 From 7c64eab781dd8b86a973280f3488c1faa38812d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cert=C3=ADk?= Date: Sat, 26 Jun 2021 23:15:48 -0600 Subject: [PATCH 13/13] Add the actually uploaded paper --- proposals/conditional_expressions/{cond.txt => 21-165.txt} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename proposals/conditional_expressions/{cond.txt => 21-165.txt} (95%) diff --git a/proposals/conditional_expressions/cond.txt b/proposals/conditional_expressions/21-165.txt similarity index 95% rename from proposals/conditional_expressions/cond.txt rename to proposals/conditional_expressions/21-165.txt index b30103c..32e4f47 100644 --- a/proposals/conditional_expressions/cond.txt +++ b/proposals/conditional_expressions/21-165.txt @@ -1,7 +1,7 @@ -To: J3 J3/##-### +To: J3 J3/21-165 From: Ondrej Certik, Milan Curcic, Zach Jibben Subject: Conditional expressions using intrinsic function -Date: 2021-June-26 +Date: 2021-June-27 Reference: 21-157, 21-159 Paper 21-157 proposes two syntactic forms for conditional expressions. The @@ -52,3 +52,5 @@ References: [1] https://fortran-lang.discourse.group/t/ poll-fortran-202x-conditional-expressions-syntax/1425 + +