<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="">Also I think it’d be cleaner to just accept an enum in one initializer<div class=""><br class=""></div><div class=""><font face="Menlo" class="">enum KeyType {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; case RSA</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; case Curve25519</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; case AES</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class="">Then you get that semantic niceness of:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">init(keyType: .RSA)</font></div><div class=""><font face="Menlo" class="">init(keyType: .Curve25519)</font></div><div class=""><font face="Menlo" class="">init(keyType: .AES)</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class="">— Harlan</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 13, 2015, at 11:41 AM, Sean Heber 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 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="">In this particular example, perhaps Key should be an enum instead of a struct.</div><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=""><br class=""></div><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="">l8r</div><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="">Sean<br class=""><br class="">Sent from my iPad</div><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=""><br class="">On Dec 13, 2015, at 10:07 AM, ilya 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" 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=""><div class=""><div dir="ltr" class="">Good point on that. I still think the best solution is to take the existing syntax of<div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class="">struct Key {</div><div class="">&nbsp; &nbsp; init(forRSA:Void) { /* */ }</div><div class="">&nbsp; &nbsp; init(forCurve25519:Void) { /* */ }</div><div class="">&nbsp; &nbsp; init(forAES:Void) { /* */ }</div><div class="">}</div><div class=""><br class=""></div><div class="">let a = Key(forRSA: ())</div><div class=""><div class=""><br class=""></div><div class="">or&nbsp;</div><div class=""><br class=""></div><div class="">let empty: Void = ()</div><div class="">let c = Key(forAES: empty)</div></div></div><div class=""><br class=""></div><div class="">and make it somewhat easier to read.&nbsp; Perhaps<br class=""></div><div class=""><br class=""></div><div class=""><div class="">let b = Key(forCurve25519: _ )</div><div class=""><br class=""></div><div class="">I think many people will read Key(forAES) as Key.init(_: forAES), so that may be not the best expression here.</div><div class=""><br class=""></div><div class=""><br class=""></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Dec 13, 2015 at 4:21 PM, Drew Crawford<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:drew@sealedabstract.com" target="_blank" class="">drew@sealedabstract.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 13, 2015, at 7:13 AM, ilya &lt;<a href="mailto:ilya.nikokoshev@gmail.com" target="_blank" class="">ilya.nikokoshev@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><span style="font-family: HelveticaNeue; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; word-spacing: 0px; float: none; display: inline !important;" class="">You can easily call a private parametrized init from a class function though. </span></div></blockquote></div><div class=""><br class=""></div></span><div class="">Sure, but we're just shuffling the deck.&nbsp; We've gone from a bad public API to a bad private API.</div><div class=""><br class=""></div><div class="">Actually, it's worse, because we now have BOTH a bad private API AND a bad public API.&nbsp; There is a reason that NSData.dataWithData(...) is a Swift compile error.</div><div class=""><br class=""></div><div class="">The (ab)use of class functions as constructors is a holdover from ObjC times.&nbsp; If you want to make an instance in Swift, you should type ClassName( and see what autocomplete suggests; you should not have to read through the documentation of class functions to see if they are secretly constructors that have been filed at the wrong shelf in the library.</div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CzM39owGTpkJ1zyGXnrRVEXja65D5KHvjV3-2BNib8-2FALraiVmeCRqDAcj1l8z35EyfyxNce005dhh8czCOSygpB8GvaO8YBxaQjp7cp-2BBsyWr73gn4wJKxfTOkE5nFIZJelApEPJM1H59akcJetq4urRVdzsTIzlv-2F88JrTaucp-2BaKFp8H5VvwwKgMILL2g5eYmSJgmhb-2BOsdcumzws0bbPbuhNZaMi2B5y4MhwYz-2BI8-3D" alt="" width="1" height="1" border="0" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div></blockquote><blockquote type="cite" 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=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=z0Ft8gvIaLt1zLwfkl4og6osLD9N8tlWJY1PY2zqWLW99Np4Jcz0Yy7yFXKpxyEdN6jk-2BgTyflD52zbAyyE0K4AP72RKJuMaDWrirSSaT7PCL-2FyETxflm4Hz-2FHbkDVjSx5hKxtNzKTqFr6xsipdoQA3-2FpaEBz-2BjbgUzBKBi7GdzZUAgP2uLnQnHQKlFfrNlOQoiCiz6hLXGeA8oFXVvW14S0zmLUYKIZ7j7oP-2FFCDJ4-3D" alt="" width="1" height="1" border="0" 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; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span 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; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br 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=""><span 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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=""><a href="mailto:swift-evolution@swift.org" 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="">swift-evolution@swift.org</a><br 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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></body></html>