<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Agreed. It's also likely that you'll be setting some internal flag with this information already. <br><br>Sent from my iPhone</div><div><br>On Dec 13, 2015, at 8:55 AM, Harlan Haskins via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">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=""> case RSA</font></div><div class=""><font face="Menlo" class=""> case Curve25519</font></div><div class=""><font face="Menlo" class=""> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</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="">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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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=""> init(forRSA:Void) { /* */ }</div><div class=""> init(forCurve25519:Void) { /* */ }</div><div class=""> 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 </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. 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"> </span><span dir="ltr" class=""><<a href="mailto:drew@sealedabstract.com" target="_blank" class="">drew@sealedabstract.com</a>></span><span class="Apple-converted-space"> </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 <<a href="mailto:ilya.nikokoshev@gmail.com" target="_blank" class="">ilya.nikokoshev@gmail.com</a>> 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. 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. 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. 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"> </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>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nE9rxSXA5G4kxsTVkgv43pXkLx-2B36P-2BPNJufHeY0dgdFhoqBDNPRvXi-2BkMRAWJdQTRuOel9Jw9KQJIVZo3V5acm1ZRM9wYRRbgbunz07ml-2Fu28Ozl5Ba1JxOKi1a2-2FWDLqJnkPV-2FRf6pokWRqYl2J-2Bd-2BX1fVhNpGYDw5KOwlgdeMAzc4mj-2BgHCl6Spr-2FGdj86RlE4PlEaZjQjUEKlwM47w-3D-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;">
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>