<div dir="ltr">I appreciate the desire for consistency but I really don't like this proposal. I agree with others who've said that it makes the code look heavy and that the extra parens only obscure the actual code, at least when the code is short. I don't think there is any way in which the parens make the code clearer, they're just visual noise. <div><br></div><div>If we insist on consistency then shouldn't we also do away with implicit returns from single-expression closures? After all this behavior is inconsistent with named functions. And shouldn't closures also declare their signature before their opening brace, rather than after, also to be consistent with named functions?</div><div><br></div><div>All these breaks with consistency have the effect of making the language easier and more pleasant to read, and they don't seem to be major stumbling blocks for people learning Swift. I hate to see them go away.<br></div><div><br></div><div>- Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 8, 2016 at 1:58 AM, G B via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I’d imagine it would be the same just without the colon and with the braces:<br>
<br>
<br>
enum MyEnum {<br>
case IntEnum(Int)<br>
case StringEnum(String)<br>
}<br>
<br>
<br>
var x=MyEnum.StringEnum("Hello")<br>
<br>
switch x {<br>
case .IntEnum(let x) {<br>
print(x)<br>
}<br>
<br>
case .StringEnum(let x) {<br>
print(x)<br>
}<br>
<br>
}<br>
<br>
<br>
<br>
Not much different than:<br>
<br>
if case .StringEnum(let v) = x {<br>
print(v+" again")<br>
}<br>
<br>
except that the switch compares all case statements against x.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
> On Jul 7, 2016, at 10:37 PM, David Sweeris <<a href="mailto:davesweeris@mac.com">davesweeris@mac.com</a>> wrote:<br>
><br>
> What would be the proposed syntax for cases with associated values?<br>
><br>
> In general, +1 for simplifying the syntax, but I'm not sure it'd work well, given that enums take on a larger roll in Swift than they do in other languages. Or maybe it'd be fine... I'm just too tired to picture it in my head.<br>
><br>
> - Dave Sweeris<br>
><br>
>> On Jul 7, 2016, at 15:07, G B via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>> It has always seemed odd to me that `case`s use a colon as a delimiter rather than curly braces like everything else. Is there a reason for this other than the legacy of C-like languages?<br>
>><br>
>> If I wanted to write a series of branching `if` \ `else` statements I would do it like so:<br>
>><br>
>> if x==0 { print(0) }<br>
>> else if x==1 { print (1) }<br>
>> else if x==2 { print(2) }<br>
>> else { print("other”) }<br>
>><br>
>> I believe all flow control is wrapped in curly braces, except for `case`s inside a `switch`:<br>
>><br>
>> switch x {<br>
>> case 0: print(0)<br>
>> case 1: print(1)<br>
>> case 2: print(2)<br>
>> default: print("other")<br>
>> }<br>
>><br>
>><br>
>> I feel like this would be more consistent with the rest of the syntax:<br>
>><br>
>> switch x {<br>
>> case 0 { print(0) }<br>
>> case 1 { print(1) }<br>
>> case 2 { print(2) }<br>
>> default { print("other”) }<br>
>> }<br>
>><br>
>> The colon syntax evokes a label, but the modern, complex `case` statements in Swift don’t act much like labels.<br>
>> _______________________________________________<br>
>> swift-evolution mailing list<br>
>> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>