[swift-evolution] Ad hoc enums / options

Austin Zheng austinzheng at gmail.com
Wed Jun 1 11:39:43 CDT 2016


> On Jun 1, 2016, at 8:58 AM, L. Mihalkovic <laurent.mihalkovic at gmail.com> wrote:
> 
> 
> 
>> On Jun 1, 2016, at 2:38 PM, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>>> On 01.06.2016 11:00, Austin Zheng wrote:
>>> Tuples are a structural type, they are described entirely by the fact
>>> that they are a tuple, plus their contained types.
>>> 
>>> Enum cases are not individual types; that precedent exists nowhere in
>>> Swift. You can't (yet) build a structural type out of something that
>>> isn't a type. The fact that you had to propose something like
>>> "AdhocEnumFitFill_2383748" as an autogenerated name for the type
>>> demonstrates the proposal's weaknesses:
> 
> Vehemently disagree! The problem is only to think that the name must be random: It CAN ABSOLUTELY NOT be random in order to respect the semantic of a nominal type. Once you accept that, then this is just a very simple and clever syntax sugaring for enum declarations.

My point isn't that the name is random, it's that you need an autogenerated name to begin with, and that it shouldn't be compared to a tuple because (like you said) it's a nominal type (albeit one that you don't directly name).

That being said, I completely agree with you that this is just language sugar around some types that the compiler synthesizes for you. It's sugar I consider a largely useless addition to the language, but there is nothing technical stopping it from being implemented.

> 
> See my other response for more details
> 



More information about the swift-evolution mailing list