[swift-evolution] Working with enums by name

Brent Royal-Gordon brent at architechies.com
Wed Jun 1 16:10:29 CDT 2016

> This should work but feels like an ugly hack to me. What if I needed
> the enum like this?
> |   enum Size : Double {
> |       case Fit = 0.5
> |       case Fill = 3.0
> |   }

What if you needed both Int and Double rawValues? What if you needed rawValues that were cryptographically signed? We have to decide which use cases are common enough to support directly in the language, and I'm not convinced that "I need to look cases up by name, but I have no choice but to use rawValue for something else" is one of them—that is, that it's *so* common that we need to direct our scarce engineering resources towards designing and implementing a separate feature merely to accommodate it. There are a whole lot of things that are *way* higher on our to-do list than this, arguably including metaprogramming features which would let you write this yourself instead of sticking it in the core language.

Brent Royal-Gordon

More information about the swift-evolution mailing list