TWiki
>
P1076 Web
>
Vhdl2019CollectedRequirements
>
TopLCS2016_094
(2020-02-17,
JimLewis
)
(raw view)
E
dit
A
ttach
---+ Language Change Specification for Conditional Return Statement ---++ | <sticky><b>LCS Number:</b></sticky> | LCS-2016-094 | | <sticky><b>Version:</b> </sticky> | 2 {25-Jan-2017} %BR% 1 {23-Dec-2016} | | <sticky><b>Date:</b> </sticky> | 25-Jan-2017 | | <sticky><b>Status:</b> </sticky> | Voting | | <sticky><b>Author:</b> </sticky> | Jim Lewis | | <sticky><b>Email:</b> </sticky> | [[Main.JimLewis]] | | <sticky><b>Source Doc:</b></sticky> | [[ConditionalReturn][Conditional Return Statement]] | | <sticky><b>Summary:</b> </sticky> | Conditional Return Statement | ---+++ Voting Results: Cast your votes here Yes: 1 %USERSIG{RyanHinton - 2016-12-27}% - ver 1 1 %USERSIG{MartinZabel - 2017-01-26}% - ver 2 1 %USERSIG{PatrickLehmann - 2017-01-26}% - ver 2 1 %USERSIG{LievenLemiengre - 2017-01-27}% - ver 2 1 %USERSIG{JimLewis - 2017-03-13}% ver 2 if 36a fails 1 %USERSIG{RobGaddi - 2017-02-27}% - ver 2 if 36a fails No: 1 %USERSIG{KevinJennings - 2017-2-8}% - Ver 2. Does not meet proposal's use case "return (<expression 1>) when <condition 1> else <expression 2>) when <condition 2> else... 1 %USERSIG{RobGaddi - 2017-02-27}% - ver 2 if 36a passes 1 %USERSIG{ThomasPreusser - 2016-12-28}% - ver 2 - following Kevin and considering Rob's comment, suggest [[LCS2016_094a][LCS094a]] 1 %USERSIG{JimLewis - 2017-03-13}% ver 2 if 36a passes Abstain: 1 %USERSIG{BrentHahoe - 2017-02-16}% Version 2 - Abstain due to lack of personal time for review. 1 %USERSIG{MartinThompson- 2017-02-17}% Version 2 - Not sure I'd use this ---+++ Style Notes Changes are shown in %RED%red font%ENDCOLOR%. Deletions are %RED%<del>crossed out</del>%ENDCOLOR%. Editing notes in %GREEN%green font%ENDCOLOR%. ---+++ Reviewing Notes See also alternative [[LCS2016_094a][LCS094a]]. ---+++ Details of Language Change <noautolink> <sticky> ---+++ Section 10.13 Return statement ---++++ production for return statement on page 168 <pre>return_statement ::= [ label : ] return [ expression ] %RED%[ when condition ]%ENDCOLOR% ;</pre> ---++++ paragraph before notes in section 10.13 on page 168 <font color="red"><strike>For the execution of a return statement, the expression (if any) is first evaluated and converted to the result subtype. The execution of the return statement is thereby completed if the conversion succeeds; so also is the execution of the enclosing subprogram. An error occurs at the place of the return statement if the conversion fails.</strike> For the execution of a return statement, the condition, if present, is first evaluated. If there is a condition, and it is FALSE, the return statement completes and execution of the subprogram resumes. If the condition is TRUE or if there is no condition, then the expression (if any) is evaluated and converted to the result subtype. If the conversion fails, an error occurs at the place of the return statement. If the conversion succeeds, the return statement completes and the enclosing subprogram completes.</font> <br> <br> ---++ Comments The execution of the return statement *also completes* when the condition is false, but then the execution of the enclosing subprogram *does not complete*. -- %BUBBLESIG{MartinZabel - 2017-01-09}% @MZ Thanks Martin. I rewrote the paragraph to better address your concerns. -- %BUBBLESIG{JimLewis - 2017-01-26}% @TODO Consider how this collides with 36a - conditional expressions @TODO In proposal explain that it is not about the value returned, but whether to return a value or not retrun. -- %BUBBLESIG{JimLewis - 2017-02-09}% Is it ok to require return (conditional_expression) when condition ; and return (conditional_expression) ; -- %BUBBLESIG{JimLewis - 2017-02-09}% If approve 36a, can return conditional_expression and if the conditional expression return unaffected then there is no return. -- %BUBBLESIG{JimLewis - 2017-02-09}% *KJ:* Does not meet proposal's use case "return (<expression 1>) when <condition 1> else <expression 2>) when <condition 2> else..." *PL:* Yes the proposal got extended, but the original use case is a language regularization to equalize all 3 control flow statements: next, exit and return. Next and exit can be used with an expression, but return not. The added use case of multiple possible return values can be achieved with LCS 036a. -- %BUBBLESIG{PatrickLehmann - 2017-02-12}% @KJ: With the revised 36a, conditional return allows return (<expression 1>) when <condition 1> else <expression 2>) when <condition 2> ; Since expression expands to (conditional_expression) -- %BUBBLESIG{JimLewis - 2017-02-21}% Discussed in Feb 23 meeting. Must be expression and not conditional_expression. Should not replace entire RHS conditional_or_unaffected_expression as unaffected is not a good way to express do not return. -- %BUBBLESIG{JimLewis - 2017-02-23}% @KJ, in conjunction with LCS_2016_36a, this is allowed return (A when cond1 else B when cond2 else C) when RTNCOND ; -- %BUBBLESIG{JimLewis - 2017-02-23}% Yes, but as written this doesn't allow return <expression 1> when <condition 1> else <expression 2> when <condition 2> ; to mean that condition 1 has priority, then condition 2, and otherwise fall through. -- %BUBBLESIG{RobGaddi - 2017-02-23}% JL: Discussed in Feb 23 meeting. Must be expression and not conditional_expression. KJ: I'm not seeing then how one can return more than one expression. LCS 36a defines conditional_expression ::= expression { when condition else expression }. This LCS defines return [ expression ] [ when condition ]. So how does one get the 'else' branch for the return? -- %BUBBLESIG{KevinJennings - 2017-02-23}% @KJ: Use parenthesis: =return (a when c else b) when done;= -- %BUBBLESIG{ThomasPreusser - 2017-02-23}% @KJ: The use case "return (<expression 1>) when <condition 1> else <expression 2>) when <condition 2> else..." could also be accomplished by: <verbatim> return (<expression 1>) when <condition 1>; return (<expression 2>) when <condition 2>; ... </verbatim> And this is also much easier to read than putting it into one line. -- %BUBBLESIG{MartinZabel - 2017-02-24}% Martin, I'd say that's only true for complex cases. The real use model to me is simple cases, the ones where you don't tie yourself in linguisitic knots in the writing of them. I'd sure like to be able to say both. =return A when (SEL = '1') else B;= and =return '0' when not ANDTERM;= and not have strange syntactic differences between them, given that I don't have them when I use a conditional assignment. I just want a nice, clean, high symmetry language. -- %BUBBLESIG{RobGaddi - 2017-02-27}% To continue rambling on about what I was going on about on during the meeting on the 23rd... Combined with 36a, my preferred evolution of this is: <verbatim> return_statement ::= [ label : ] return [ conditional_expression_or_unaffected ] ; </verbatim> where a resultant value of =unaffected= means that you don't return, and instead continue with execution. Yes, you _could_ use that to go around writing horrible things with explicit use of unaffected rather than have unaffected only come through as the implicit catch-all =else= clause. But people _could_ do a lot of horrific things. What it really gives you is exactly what I said in my comment above; a unified syntax for anywhere you're using =when= to create a conditional thingy, regardless of what type of thingy you want to do conditionally. It would mean that: 1 =return '1' when A else '0' when B;= 2 =return ('1' when A else '0') when B;= have different meanings but both are valid. I don't think either scans badly or makes its intent unclear. If we demand the trailing =when= be a part of an entirely separate language chunk, then 1) has to be written =return ('1' when A else '0') when (A or B);= which buries the intent. -- %BUBBLESIG{RobGaddi - 2017-02-27}% @Rob: See LCS094a for a proposal that provides what you want. -- %BUBBLESIG{ThomasPreusser - 2017-02-27}% %COMMENT%</sticky> </noautolink>
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r29
<
r28
<
r27
<
r26
<
r25
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r29 - 2020-02-17 - 15:34:42 -
JimLewis
P1076
Log In
or
Register
P1076 Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
Webs
Main
P1076
Ballots
LCS2016_080
P10761
P1647
P16661
P1685
P1734
P1735
P1778
P1800
P1801
Sandbox
TWiki
VIP
VerilogAMS
Copyright © 2008-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback