<div dir="ltr"><div><div><div><div><div>Thanks for the explanation Mateusz, I think I understand. So the enum still only has 3 cases, SMALL, MEDIUM, and LARGE, but an instance also has some properties?<br></div><br></div>So some code to use it might be:<br></div>var aFormat = Format.LARGE<br></div>aFormat.width = 150 // aFormat is still Format.LARGE - this doesn't change<br></div><div><br></div>Is that right?<br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 10 Oct 2016 at 09:06 Mateusz Malczak via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="gmail_msg">
> Perhaps it is a bit ugly, but I don’t know if allowing stored properties on<br class="gmail_msg">
> enums is the solution: that looks very ugly to me too.<br class="gmail_msg">
<br class="gmail_msg">
That may look ugly, but can be very useful, if only you think<br class="gmail_msg">
rawValue's are useful then you should also agree that stored<br class="gmail_msg">
properties would be useful :)<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
| Mateusz Malczak<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
2016-10-10 9:26 GMT+02:00 David Hart via swift-evolution<br class="gmail_msg">
<<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>>:<br class="gmail_msg">
> Perhaps it is a bit ugly, but I don’t know if allowing stored properties on<br class="gmail_msg">
> enums is the solution: that looks very ugly to me too.<br class="gmail_msg">
><br class="gmail_msg">
> On 10 Oct 2016, at 02:36, Erica Sadun via swift-evolution<br class="gmail_msg">
> <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> I would love to be able to have stored properties in addition to the varying<br class="gmail_msg">
> elements.<br class="gmail_msg">
><br class="gmail_msg">
> Now, I end up creating a secondary struct T and doing case a(T, whatever),<br class="gmail_msg">
> b(T, whatever), c(T, whatever), etc. where the same associated structure is<br class="gmail_msg">
> every case, *or* I end up putting the enum into a struct which means the<br class="gmail_msg">
> guiding semantics are the struct and not the enumeration. Both approaches<br class="gmail_msg">
> are ugly.<br class="gmail_msg">
><br class="gmail_msg">
> -- E<br class="gmail_msg">
><br class="gmail_msg">
> On Oct 9, 2016, at 6:03 PM, Jay Abbott via swift-evolution<br class="gmail_msg">
> <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> Mateusz,<br class="gmail_msg">
><br class="gmail_msg">
> To me, "Enumeration defines a type with well defined set of possible values"<br class="gmail_msg">
> seems to contradict the idea of having properties that can have different<br class="gmail_msg">
> values. What could you do with this special enum - what would the code that<br class="gmail_msg">
> uses it look like?<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> On Sun, 9 Oct 2016 at 04:56 Robert Widmann via swift-evolution<br class="gmail_msg">
> <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> I’ve started doing this to try and mimic “Smart Constructors” in Haskell<br class="gmail_msg">
>> and I think it works quite well.<br class="gmail_msg">
>><br class="gmail_msg">
>> struct Format {<br class="gmail_msg">
>> enum FormatBacking {<br class="gmail_msg">
>> case SMALL(Int, Int)<br class="gmail_msg">
>> case MEDIUM(Int, Int)<br class="gmail_msg">
>> case LARGE(Int, Int)<br class="gmail_msg">
>> }<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> swift-evolution mailing list<br class="gmail_msg">
> <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> swift-evolution mailing list<br class="gmail_msg">
> <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
><br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>