<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="">I have mixed feelings about this since it may lead to redeclarations over and over of the same values instead of actually declaring an enum.<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 31, 2016, at 7:31 PM, Charles Constant 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=""><div dir="ltr" class="">An enthusiastic +1 to Erica's suggestion.&nbsp;<div class=""><br class=""></div><div class="">While I also see the appeal of Chris Kornher's suggestion of giving the enum a proper Type, I think Erica's syntax is more appropriate. I haven't though through the implications of having an "anonymous enum" but since the main use case is just to give functions a more convenient and legible way to specify options, I think shorter is better.</div><div class=""><br class=""></div><div class="">I really like this proposal. It would result in a lot of Swift code, out there in the world, being a little easier to read :)</div><div class=""><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, May 31, 2016 at 9:53 AM, Christopher Kornher via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div style="word-wrap:break-word" class=""><div class=""><b class="">Forwarding on behalf of Chris Kornher:</b></div><div class=""><br class=""></div><div class="">I think that this is a great idea. It would be nice to:</div><div class=""><span style="white-space:pre-wrap" class="">        </span>1)&nbsp;Have a standard way to generate these values from textual or other serialized representations.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>2) A way to be able to store these vales (as preferences, for example)</div><div class=""><br class=""></div><div class="">A simple way to do support this is to make these into full-fledged enums:</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&nbsp;1) make these rawrepresentable string enums</div><div class=""><span style="white-space:pre-wrap" class="">        </span>&nbsp;2) give the type a name for use when needed: e.g.</div><div class=""><span style="white-space:pre-wrap" class="">                </span></div><div style="word-wrap:break-word" class=""><div class=""><table 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" class=""><tbody class=""><tr class=""><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class=""><span style="color:rgb(121,93,163)" class=""><span style="white-space:pre-wrap" class="">        </span>scaleAndCropImage.fitImage.options_t

<span style="font-family:Helvetica;white-space:normal" class=""><span style="white-space:pre-wrap" class="">                </span>or perhaps, :<br class=""></span><span class="">        </span>
<span style="white-space:pre-wrap" class="">        </span>scaleAndCropImage_fitImage_options_t


<span style="font-family:Helvetica;white-space:normal" class="">enabling:&nbsp;</span>

struct MyPreferenceStruct {
.. 
var fitOptions: scaleAndCropImage_fitImage_options_t
}</span></td></tr></tbody></table></div></div><div class="">&nbsp;</div><div class=""><div style="font-family:Palatino-Roman" class="">Thinking about this a bit more, requiring a name like:</div><div style="font-family:Palatino-Roman" class=""><br class=""></div><div style="font-family:Palatino-Roman" class=""><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><table 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" class=""><tbody class=""><tr class=""><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class=""></td></tr></tbody></table><div class=""><div style="word-wrap:break-word" class=""><div class=""><div class=""><div style="word-wrap:break-word" class=""><div class=""><table 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" class=""><tbody class=""><tr class=""><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class=""><span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">scaleAndCropImage</span>(</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    image: UIImage,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <span style="color:rgb(121,93,163)" class="">toSize</span> <span class="">size</span>: CGSize,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <b class="">operation: ScaleCropFitFitFill{<font color="#0086b3" class="">.Fit | .Fill}</font> <span style="color:rgb(167,29,93)" class="">=</span> .<font color="#0086b3" class="">Fit</font></b></td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    ) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UIImage {

</td></tr></tbody></table></div></div></div></div></div></div></div></div></div></div></div></div><div style="font-family:Palatino-Roman" class="">would be cleaner. &nbsp;</div></div><div class=""><br class=""></div><div class="">- Chris</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="h5"><div class="">On May 31, 2016, at 10:16 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""></div></div><div class=""><div class=""><div class="h5"><div style="word-wrap:break-word" class="">Here's a function signature from some code from today:<div class=""><br class=""></div><div class=""><table 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" class=""><tbody class=""><tr class=""><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class=""><span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">scaleAndCropImage</span>(</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    image: UIImage,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <span style="color:rgb(121,93,163)" class="">toSize</span> <span class="">size</span>: CGSize,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <b class="">fitImage: <span style="color:rgb(0,134,179)" class="">Bool</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(0,134,179)" class="">true</span></b></td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    ) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UIImage {</td></tr></tbody></table><div class=""><br class=""></div><div class=""><br class=""></div><div class="">And here's what I want the function signature to actually look like:</div></div><div class=""><br class=""></div><div class=""><table 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" class=""><tbody class=""><tr class=""><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class=""><span style="color:rgb(167,29,93)" class="">func</span> <span style="color:rgb(121,93,163)" class="">scaleAndCropImage</span>(</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    image: UIImage,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <span style="color:rgb(121,93,163)" class="">toSize</span> <span class="">size</span>: CGSize,</td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    <b class="">operation: <font color="#0086b3" class="">(.Fit | .Fill)</font> <span style="color:rgb(167,29,93)" class="">=</span> .<font color="#0086b3" class="">Fit</font></b></td></tr><tr class=""><td style="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;border-style:solid;border-color:rgb(238,238,238);border-width:0px 1px 0px 0px" class=""></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap" class="">    ) <span style="color:rgb(167,29,93)" class="">-&gt;</span> UIImage {</td></tr></tbody></table><div class=""><br class=""></div></div><div class=""><br class=""></div><div class="">where I don't have to establish a separate enumeration to include ad-hoc enumeration-like semantics for the call. A while back, Yong hee Lee introduced anonymous enumerations (and the possibility of anonymous option flags) but the discussion rather died.</div><div class=""><br class=""></div><div class="">I'm bringing it up again to see whether there is any general interest in pursuing this further as I think the second example is more readable, appropriate, and Swifty than the first, provides better semantics, and is more self documenting.</div><div class=""><br class=""></div><div class="">Thanks for your feedback,</div><div class=""><br class=""></div><div class="">-- Erica</div><div class=""><br class=""></div></div></div></div><span class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></span></div></blockquote></div><br class=""></div></div><br class="">_______________________________________________<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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>