<html><head><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="">What if (.Fit | .Fill) was just a shorthand for enums that you could use anywhere, like a tuple type?<div class=""><br class=""></div><div class="">let foo: (.Fit | .Fill) = .Fit</div><div class="">let bar: (.Fit | .Fill) = .Fill</div><div class="">let frob = cond ? foo : bar // foo and bar have the same type</div><div class=""><br class=""></div><div class="">You could typealias it too.</div><div class=""><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Le 1 juin 2016 à 20:05:06, Christopher Kornher via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Jun 1, 2016, at 7:48 PM, Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">On May 31, 2016, at 3:04 PM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><font face="Menlo" class="">let _ = scaleAndCropImage(image: myImage, toSize: size, operation: .fill)</font></div><div class=""><br class=""></div><div class="">You would not be able to assign `.fill` to a variable and use that for the operation value.</div></blockquote><br class=""><div class="">This is my objection to this idea. It does not encourage reuse.</div></div></div></blockquote><div class=""><br class=""></div><div class="">-1For me too. Introducing this quasi-enum would increase cognitive load with little, if any, net benefit. This is the sort of feature that looks great and works wonderfully in example apps, but does not scale well to real systems, where options show up in more methods through time, get passed around to helpers, stored, marshaled into various formats, etc.</div><div class=""><br class=""></div><div class="">As someone mentioned, this would probably be a good fit If Swift adopts a structural type system (I suppose, I have ever used a language with one to my knowledge, unless duck typing counts)</div><div class=""><br class=""></div><div class="">As syntactic sugar for a true enum declaration, it would be a “cool” feature, but reuse would still be problematic.&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">I would not be able to assign to a variable:</div><div class=""><br class=""></div><div class="">let <b class="">selectedOperation</b> = .fill</div><div class=""><br class=""></div><div class="">In order to then do this later in the program:</div><div class=""><br class=""></div><div class="">scaleAndCropImage(image: myImage, toSize: size, operation: <b class="">selectedOperation</b>)</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>