<div dir="ltr">An enthusiastic +1 to Erica&#39;s suggestion. <div><br></div><div>While I also see the appeal of Chris Kornher&#39;s suggestion of giving the enum a proper Type, I think Erica&#39;s syntax is more appropriate. I haven&#39;t though through the implications of having an &quot;anonymous enum&quot; 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><br></div><div>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><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 31, 2016 at 9:53 AM, Christopher Kornher via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div style="word-wrap:break-word"><div><b>Forwarding on behalf of Chris Kornher:</b></div><div><br></div><div>I think that this is a great idea. It would be nice to:</div><div><span style="white-space:pre-wrap">        </span>1) Have a standard way to generate these values from textual or other serialized representations.</div><div><span style="white-space:pre-wrap">        </span>2) A way to be able to store these vales (as preferences, for example)</div><div><br></div><div>A simple way to do support this is to make these into full-fledged enums:</div><div><span style="white-space:pre-wrap">        </span> 1) make these rawrepresentable string enums</div><div><span style="white-space:pre-wrap">        </span> 2) give the type a name for use when needed: e.g.</div><div><span style="white-space:pre-wrap">                </span></div><div style="word-wrap:break-word"><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px"><tbody><tr><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span style="color:rgb(121,93,163)"><span style="white-space:pre-wrap">        </span>scaleAndCropImage.fitImage.options_t

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


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

struct MyPreferenceStruct {
.. 
var fitOptions: scaleAndCropImage_fitImage_options_t
}</span></td></tr></tbody></table></div></div><div> </div><div><div style="font-family:Palatino-Roman">Thinking about this a bit more, requiring a name like:</div><div style="font-family:Palatino-Roman"><br></div><div style="font-family:Palatino-Roman"><div style="word-wrap:break-word"><div><div><div style="word-wrap:break-word"><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px"><tbody><tr><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"></td></tr></tbody></table><div><div style="word-wrap:break-word"><div><div><div style="word-wrap:break-word"><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px"><tbody><tr><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">scaleAndCropImage</span>(</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    image: UIImage,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <span style="color:rgb(121,93,163)">toSize</span> <span>size</span>: CGSize,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <b>operation: ScaleCropFitFitFill{<font color="#0086b3">.Fit | .Fill}</font> <span style="color:rgb(167,29,93)">=</span> .<font color="#0086b3">Fit</font></b></td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    ) <span style="color:rgb(167,29,93)">-&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">would be cleaner.  </div></div><div><br></div><div>- Chris</div><div><br></div><br><div><blockquote type="cite"><div><div class="h5"><div>On May 31, 2016, at 10:16 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br></div></div><div><div><div class="h5"><div style="word-wrap:break-word">Here&#39;s a function signature from some code from today:<div><br></div><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px"><tbody><tr><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">scaleAndCropImage</span>(</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    image: UIImage,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <span style="color:rgb(121,93,163)">toSize</span> <span>size</span>: CGSize,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <b>fitImage: <span style="color:rgb(0,134,179)">Bool</span> <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(0,134,179)">true</span></b></td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    ) <span style="color:rgb(167,29,93)">-&gt;</span> UIImage {</td></tr></tbody></table><div><br></div><div><br></div><div>And here&#39;s what I want the function signature to actually look like:</div></div><div><br></div><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(51,51,51);font-family:Helvetica,arial,nimbussansl,liberationsans,freesans,clean,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:13px"><tbody><tr><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap"><span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">scaleAndCropImage</span>(</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    image: UIImage,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <span style="color:rgb(121,93,163)">toSize</span> <span>size</span>: CGSize,</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    <b>operation: <font color="#0086b3">(.Fit | .Fill)</font> <span style="color:rgb(167,29,93)">=</span> .<font color="#0086b3">Fit</font></b></td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:Consolas,&#39;Liberation Mono&#39;,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"></td><td style="padding:0px 10px;vertical-align:top;overflow:visible;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:12px;word-wrap:normal;white-space:pre-wrap">    ) <span style="color:rgb(167,29,93)">-&gt;</span> UIImage {</td></tr></tbody></table><div><br></div></div><div><br></div><div>where I don&#39;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><br></div><div>I&#39;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><br></div><div>Thanks for your feedback,</div><div><br></div><div>-- Erica</div><div><br></div></div></div></div><span class="">_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></blockquote></div><br></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div></div>