<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><div style="font-family: Calibri,sans-serif; font-size: 11pt;">I agree. These are different proposals that can coexist but I think they should be evaluated separately by the community.<br><br></div></div><div dir="ltr"><hr><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">From: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">Vladimir.S via swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Sent: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">‎27/‎05/‎2016 08:05 AM</span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">To: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:cocoadev@charlessoft.com">Charles Srstka</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Cc: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;"><a href="mailto:swift-evolution@swift.org">swift-evolution</a></span><br><span style="font-family: Calibri,sans-serif; font-size: 11pt; font-weight: bold;">Subject: </span><span style="font-family: Calibri,sans-serif; font-size: 11pt;">Re: [swift-evolution] [Proposal] Enums with static stored propertiesfor each case</span><br><br></div>Correct me if I'm wrong, but this idea with accessors is not the same as <br>static properties for each case. The one of ideas of initial proposal - <br>static(!) values would be created only once and it is important in case it <br>is expensive to create such value(or if should be created only once per case)<br><br>The suggested solution based on 'accessor' - will create assotiated <br>properties each time the enum instace created, for each instance of enum type.<br><br>We can have something like the example with accessors now :<br><br>enum MyError: ErrorProtocol {<br>&nbsp;&nbsp;&nbsp;&nbsp; struct MyErrorInfo {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let localizedFailureReason: String<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let url: String<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp; case fileNotFound(url: String)<br>&nbsp;&nbsp;&nbsp;&nbsp; case fileIsCorrupt(url: String)<br><br>&nbsp;&nbsp;&nbsp;&nbsp; var info : MyErrorInfo {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch self {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case fileNotFound(let url) : return <br>MyErrorInfo(localizedFailureReason: "File \"\(url.lowercased())\" not <br>found.", url: url)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case fileIsCorrupt(let url) : return <br>MyErrorInfo(localizedFailureReason: "File \"\(url.lowercased())\"&nbsp; is <br>corrupt.", url: url)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>}<br><br>var e = MyError.fileNotFound(url: "http://something.some")<br>var info = e.info<br>print(info.localizedFailureReason, info.url)<br><br>But yes, such MyErrorInfo will be created on each `info.` call. This is <br>worse that create MyErrorInfo once per each enum instance initialization, <br>but IMO these solutions are close enough.<br><br>In any case, I don't see why tuple for enum and enum with `accessor` can <br>not co-exists.<br><br>On 27.05.2016 2:28, Charles Srstka via swift-evolution wrote:<br>&gt;&gt; On May 26, 2016, at 4:47 PM, Brent Royal-Gordon via swift-evolution<br>&gt;&gt; &lt;swift-evolution@swift.org &lt;mailto:swift-evolution@swift.org&gt;&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; - Abusing rawValue is just that: an abuse.<br>&gt;<br>&gt; In addition, enums with associated types can’t have rawValues.<br>&gt;<br>&gt; Why is this relevant, you may ask? Because error enums are a huge use case<br>&gt; for something like this. Being able to do the below would be great:<br>&gt;<br>&gt; enum MyError: ErrorProtocol {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; accessor var localizedFailureReason: String<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; accessor var url: NSURL<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; case FileNotFound(url: NSURL) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.localizedFailureReason = “File \"\(url.lastPathComponent ??<br>&gt; “”)\” not found.”<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.url = url<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; case FileIsCorrupt(url: NSURL) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.localizedFailureReason = “File \"\(url.lastPathComponent ??<br>&gt; “”)\” is corrupt.”<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.url = url<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt; }<br>&gt;<br>&gt; This would be much cleaner than the existing method of using a switch to<br>&gt; create a userInfo dictionary for creating an NSError to send to<br>&gt; -[NSApplication presentError:] and similar methods.<br>&gt;<br>&gt; Charles<br>&gt;<br>&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; swift-evolution mailing list<br>&gt; swift-evolution@swift.org<br>&gt; https://lists.swift.org/mailman/listinfo/swift-evolution<br>&gt;<br>_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></body></html>