<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">+1 on the CamelCase. Just so y’all know, though, there’s a bug in the complier involving naming collisions between cases and types. Currently (Xcode 7.2), case labels silently override type names, leading to the following error:</div><div class=""><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">enum</span> Foo {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Int <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Ok</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> Something(Int) </span>// “Error: Use of undeclared type 'Int'"</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span> Float(Double) <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Ok</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div></div><div class="">That should probably get fixed *before* the API design guidelines start recommending that case labels begin with uppercase letters. (I mean, it should get fixed anyway, but it should especially get fixed before we start encouraging behavior which makes it easier to encounter.)</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div><div class=""><br class="webkit-block-placeholder"></div><div class="">On Jan 23, 2016, at 11:18 AM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 23, 2016, at 11:01 AM, David Owens II <<a href="mailto:david@owensd.io" class="">david@owensd.io</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">What about enums with associated data? Those really are like types. So do we capitalize those?<br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""><br class="">Unless those get redesigned, there is really this contrary feel to those and other enum cases. <br class=""></div></div></blockquote></div><br class=""><div class="">Before open sourcing, I had written up some thoughts on this:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift/blob/master/docs/proposals/EnumStyle.rst" class="">https://github.com/apple/swift/blob/master/docs/proposals/EnumStyle.rst</a></div><div class=""><br class=""></div><div class="">From an API perspective, an enum 'case' behaves similarly to a factory method or initializer on a struct or class, and in native Swift we generally prefer `init`s to static factory methods when possible. We also see a lot of API design in the wild where framework authors paper over the enum-ness of their API enums with initializers:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">enum Result<T> {</div><div class=""> case Success(T)</div><div class=""> case Error(ErrorType)</div><div class=""><br class=""></div><div class=""> init(success: T) { self = .Success(success) }</div><div class=""> init(error: ErrorType) { self = .Error(error) }</div><div class="">}</div><div class=""><br class=""></div></blockquote>We hadn't settled on our argument label model when we originally designed and implemented enums; I feel like if we had, it's likely we would have favored cases that natively look and feel more like initializers, using labels to distinguish cases:<br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><br class=""></div><div class="">enum Result<T> {</div><div class=""> case (success: T)</div><div class=""> case (error: ErrorType)</div><div class="">}</div></blockquote><div class=""><br class=""></div><div class="">-Joe</div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></body></html>