<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 4, 2016, at 8:58 AM, Hooman Mehr <<a href="mailto:hooman@mac.com" class="">hooman@mac.com</a>> wrote:</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="">How about this:<div class=""><br class=""></div><div class=""><br class=""></div><div class="">Going back to Erica’s original example:</div><div class=""><br class=""></div><div class=""><table class="tab-size highlight js-file-line-container" data-tab-size="8" style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 8; 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="" style="box-sizing: border-box;"><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-LC6" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">scaleAndCropImage</span>(</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L7" class="blob-num js-line-number" data-line-number="7" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC7" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> image: UIImage,</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L8" class="blob-num js-line-number" data-line-number="8" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC8" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">toSize</span> <span class="pl-smi" style="box-sizing: border-box;">size</span>: CGSize,</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L9" class="blob-num js-line-number" data-line-number="9" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC9" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> <b class="">operation: <font color="#0086b3" class="">(.Fit | .Fill)</font> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<font color="#0086b3" class="">Fit</font></b></td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L10" class="blob-num js-line-number" data-line-number="10" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC10" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> ) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-></span> UIImage {</td></tr></tbody></table><div class=""><br class=""></div></div><div class="">And noting that we are already allowed to declare an enum inside the function, compiler can generate an enum scoped inside the function named the label of the enum:</div><div class=""><br class=""></div><div class=""><table class="tab-size highlight js-file-line-container" data-tab-size="8" style="box-sizing: border-box; border-spacing: 0px; border-collapse: collapse; tab-size: 8; 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="" style="box-sizing: border-box;"><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-LC6" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">scaleAndCropImage</span>(</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L7" class="blob-num js-line-number" data-line-number="7" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC7" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> image: UIImage,</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L8" class="blob-num js-line-number" data-line-number="8" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC8" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">toSize</span> <span class="pl-smi" style="box-sizing: border-box;">size</span>: CGSize,</td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L9" class="blob-num js-line-number" data-line-number="9" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC9" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> <b class="">operation: <font color="#0086b3" class="">(.Fit | .Fill)</font> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> .<font color="#0086b3" class="">Fit</font></b></td></tr><tr class="" style="box-sizing: border-box;"><td id="file-scalecrop-swift-L10" class="blob-num js-line-number" data-line-number="10" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; text-align: right; white-space: nowrap; vertical-align: top; cursor: pointer; -webkit-user-select: none; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px;"></td><td id="file-scalecrop-swift-LC10" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; overflow: visible; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; word-wrap: normal; white-space: pre;"> ) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-></span> UIImage {</td></tr></tbody></table><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">@_exposed</span> <span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">num </span><b class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;">operation</b><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class=""> {</span></div></div><div class=""><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">case </span><b class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;"><font color="#0086b3" class="">Fit</font></b></div><div class=""><div class=""><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">        </span><span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">case </span><b class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;"><font color="#0086b3" class="">Fill</font></b></div></div><div class=""><font color="#0086b3" face="Consolas, Liberation Mono, Menlo, Courier, monospace" class=""><span style="white-space: pre;" class=""><b class=""> </b></span></font><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">}</span></div><div class=""><b class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;"><font color="#0086b3" class=""><br class=""></font></b></div><div class="">Then you could declare a var:</div><div class=""><br class=""></div><div class=""><span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">var</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class=""> myOperation: </span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" class=""><span style="white-space: pre;" class="">scaleAndCropImage.operation = .Fill</span></font></div><div class=""><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" class=""><span style="white-space: pre;" class=""><br class=""></span></font></div><div class=""><div class="">Then you can call:</div></div><div class=""><br class=""></div><div class=""><span style="color: rgb(167, 29, 93); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">let</span><font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" class=""><span style="white-space: pre;" class=""> scaledImage = </span></font><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; white-space: pre;" class="">scale</span><span style="white-space: pre; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;" class="">AndCropImage(image: myImage, toSize: theSize, operation: myOperation)</span></div><div class=""><br class=""></div><div class="">@_exposed above would be a compiler private annotation for the auto generated enum that will make if visible outside of the function. This way the impact is minimal and such ad hoc enum would be just the same as any other enum. The only big change in the compiler would be the ability to make some declaration inside functions visible to the outside code.</div></div></div></blockquote></div><br class=""><div class="">This is my favorite approach (assuming it's technically feasible) as it preserves the limitation that the enumerations are scoped strictly to the function but can be referenced outside of it.</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">It allows type inference for dropped prefixes because the compiler can unambiguously match the ad hoc enumeration type to the parameter.</li><li class="">It introduces the possibility (for Matthew) of assigning a value to a variable.</li><li class="">It preserves the notion that an ad-hoc enum makes syntactic and semantic sense only with respect to its use in a function/method parameter list.</li></ul></div><div class=""><br class=""></div><div class="">If an enumeration needs wider semantics, it should be a standalone type, whether as a nested or not.</div><div class=""><br class=""></div><div class="">Reiterating the reasons for this pitch:</div><div class=""><ul class=""><li class="">It streamlines coding, eliminating standalone enumeration types that are used only once</li><li class="">It enables you to see all enumeration options at a glance, and can be reflected in the QuickHelp documentation</li><li class="">It encourages `switch` coding over `if-then-else` coding so each case is labeled and self documenting</li><li class="">It pushes semantics to the call-site in a way that simple Boolean flags cannot: `operation: .Fit` means more than `shouldFill: false`.</li></ul></div><div class="">I'd like to know at this point whether Hooman's approach is even technically feasible, although it's horrible timing the Tuesday before WWDC to get core team feedback on anything.</div><div class=""><br class=""></div><div class="">-- Erica</div><div class=""><br class=""></div></body></html>