-
Notifications
You must be signed in to change notification settings - Fork 17
Initial draft of conditional expression intrinsic paper #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I believe this idea (not a specific proposal though) was discussed by the committee and the following feedback is summarized in: Half the arguments are with issues that come up with extending The first counter argument is harder chaining, but I think you just put the extra parenthesis at the end. Not too bad, it still seams more readable overall than alternatives. The stronger counter argument is that this does not behave like a function, the |
One other not-a-function aspect is that a conditional expression can return an actual variable, not just the value. So it can be used in But your paper looks good and should invite discussion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Ondrej! Besides my in-text comments, here are a few general comments and questions:
- Can this function be
simple
? I think so. - In this approach,
consequent
andalternative
must be type compatible. This is a restriction relative to the keyword (and other) forms, where you could do:or with a Python-like syntax:res = if cond then 1 else 1.234
Because of this restriction, I don't thinkres = 1 if cond else 1.234
ifthen
could be used to invoke different specific procedures when passed as an argument to a generic procedure, which seems an attractive use case to me. But maybe I miss an important detail.
Co-authored-by: Milan Curcic <[email protected]>
Co-authored-by: Milan Curcic <[email protected]>
Co-authored-by: Milan Curcic <[email protected]>
First of all, the keyword version would be:
and my understanding is that it would be exactly equivalent to:
The restriction on |
Isn't this semantically exactly the same as:
I would think both could return a variable. But I haven't thought of it like this. I would expect both |
Yes, actually my second comment and examples are completely irrelevant, the keyword form has the same restriction for types. It wasn't obvious to me that it would have to have it, but it does simplify things. |
Co-authored-by: Milan Curcic <[email protected]>
I pushed in answers to some common objections. @milancurcic, @zjibben let me know if you have any other feedback, or if I should upload as is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found two small typos, otherwise I think it's in good shape. The longer chained example is not bad at all, I find it quite readable. Thanks for leading this proposal.
Co-authored-by: Milan Curcic <[email protected]>
Co-authored-by: Milan Curcic <[email protected]>
Thanks @milancurcic for the quick review. I think @zjibben implicitly approved it, so I am going to go ahead and upload it. |
Ok there it is: https://j3-fortran.org/doc/year/21/21-165.txt |
What if you have this conforming program unit:
Would this feature change the meaning of it? I.e. |
Not if the program had a declaration of |
As the example didn't have a declaration of Is this a backward compatibility problem for any new intrinsic procedure? |
Yes, and yes. This is always a consideration when standard or extension intrinsic functions are added. If you use |
The paper explains the motivation.
The other two referenced papers are:
@klausler, @milancurcic, would you have time to please review this and help me polish it? I would like to submit this for Monday's vote also.