[swift-evolution] Ad hoc enums / options

Ricardo Parada rparada at mac.com
Wed Jun 1 21:13:03 CDT 2016

> On Jun 1, 2016, at 5:38 PM, Tony Allevato via swift-evolution <swift-evolution at swift.org> wrote:
> we could consider allowing this:
>     func foo(bar: (.fit | .fill)) {
>       baz(bar: bar)
>     }
>     func baz(bar: (.fit | .fill | .florp) { ... }
> In other words, an ad hoc enum T can be used wherever an ad hoc enum U is expected if T ⊆ U.

If that were the case then it may not be that bad. 

I would not use it that much as I favor reusability and would normally create an enum for it for maximum flexibility and reuse. 

I like tuples but I don't use them much and I have survived in other languages without them. :-)

This is all sugar to me. I may use it when putting code together quickly but not in formal APIs. 

I really look forward to seeing other features in Swift that will elevate the language and run-time to levels where Objective-C still has an edge over Swift. In particular reflection, property behaviors, KVC, etc.   

More information about the swift-evolution mailing list