| |
LCS-2016-094 |
| |
2 {25-Jan-2017} 1 {23-Dec-2016} |
| |
25-Jan-2017 |
| |
Voting |
| |
Jim Lewis |
| |
Main.JimLewis |
| |
Conditional Return Statement |
| |
Conditional Return Statement |
return_statement ::=
[ label : ] return [ expression ] [ when condition ] ;
return (a when c else b) when done;
-- return (<expression 1>) when <condition 1>; return (<expression 2>) when <condition 2>; ...And this is also much easier to read than putting it into one line. --
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.
-- return_statement ::= [ label : ] return [ conditional_expression_or_unaffected ] ;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:
return '1' when A else '0' when B;
return ('1' when A else '0') when B;
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.
--