<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 31, 2016, at 2:04 PM, Erica Sadun <<a href="mailto:erica@ericasadun.com" class="">erica@ericasadun.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On May 31, 2016, at 12:35 PM, Matthew Johnson <<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><div class="">I think I'm -1 on this. It makes things easier for the implementer of the function and harder for the caller. </div><div class=""><br class=""></div><div class="">It's not clear whether the caller could store an argument to pass in a variable, but if they could they would need to list out all cases in the type of the variable (unless these anonymous enums have structural subtyping). This is fragile. Any time that list changes all variable declarations will have to be updated.</div><div class=""><br class=""></div><div class="">Functions are implemented once and usually called more many times. It's better for callers if you just write it like this:</div><div class=""><br class=""></div><div class="">enum FitOrFill { case fit, fill }</div><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="" style="word-wrap: break-word;"><table class="" style="border-spacing: 0px; border-collapse: collapse; color: rgb(51, 51, 51); font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px;"><tbody class=""><tr class=""><td class="" style="padding: 0px 10px; vertical-align: top; overflow: visible; word-wrap: normal;"><font face="UICTFontTextStyleTallBody" size="3" class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">func scaleAndCropImage(</span></font></td></tr><tr class=""><td class="" style="padding: 0px 10px; width: 50px; min-width: 50px; line-height: 18px; text-align: right; vertical-align: top; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td class="" style="padding: 0px 10px; vertical-align: top; overflow: visible; word-wrap: normal;"><font face="UICTFontTextStyleTallBody" size="3" class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">image: UIImage,</span></font></td></tr><tr class=""><td class="" style="padding: 0px 10px; width: 50px; min-width: 50px; line-height: 18px; text-align: right; vertical-align: top; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td class="" style="padding: 0px 10px; vertical-align: top; overflow: visible; word-wrap: normal;"><font face="UICTFontTextStyleTallBody" size="3" class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">toSize size: CGSize,</span></font></td></tr><tr class=""><td class="" style="padding: 0px 10px; width: 50px; min-width: 50px; line-height: 18px; text-align: right; vertical-align: top; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td class="" style="padding: 0px 10px; vertical-align: top; overflow: visible; word-wrap: normal;"><font face="UICTFontTextStyleTallBody" size="3" class=""><span class="" style="background-color: rgba(255, 255, 255, 0);"><b class="">operation: FitOrFill = .fit</b></span></font></td></tr><tr class=""><td class="" style="padding: 0px 10px; width: 50px; min-width: 50px; line-height: 18px; text-align: right; vertical-align: top; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td class="" style="padding: 0px 10px; vertical-align: top; overflow: visible; word-wrap: normal;"><font face="UICTFontTextStyleTallBody" size="3" class=""><span class="" style="background-color: rgba(255, 255, 255, 0);">) -> UIImage {</span></font></td></tr></tbody></table></div></div></div><br class=""><div class="">So unless these anonymous enums are structurally subtyped I think it's a bad idea. And introducing structural subtyping here seems like a pretty large hammer for this use case.</div></div></div></div></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">From the caller's point of view, the type must be inferable and exactly match a token listed in the declaration (which would also appear in Quick Help):</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font face="Menlo" class="">let _ = scaleAndCropImage(image: myImage, toSize: size, operation: .fill)</font></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">You would not be able to assign `.fill` to a variable and use that for the operation value.</div></div></blockquote><div><br class=""></div><div>If you are not allowing callers to store their argument in a variable then I am 100% opposed to this. That would the first case in Swift where you *MUST* provide a literal argument when calling a function, and *CANNOT* provide a value you store in a variable (possibly something you receive as an argument from somewhere else). Why would we want to restrict the flexibility of callers in that way?</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">-- E</div></div></blockquote></div><br class=""></body></html>