[swift-evolution] Anonymous Enums

Slava Pestov spestov at apple.com
Fri Feb 19 15:05:09 CST 2016


I'm against this.

In many cases, such 'one off' types are best expressed as nested types in some other type. I think we can get more mileage by fixing the cases where nested types are currently not supported, which would not require going through the evolution process, than adding new grammar to the language for yet another special case.

Slava

> On Feb 19, 2016, at 8:46 AM, Yong hee Lee via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hi, I have a proposal.
> 
> 
> enum Foo {
>   case foo,bar
> }
> 
> func test(a:Foo) {
>   // …
> }
> 
> test(.bar)
> 
> 
> If I use an enum only as a parameter of a function, the name of enum  is redundant. 
> 
> so I suggest a compact version like below.
> 
> 
> 
> func test(a:[foo|bar]) {
>   // ...
> }
> 
> test(.bar)
> 
> 
> 
> func adjustTemperature(temp:[low|normal|high]) {
>   // ...
> }
> 
> adjustTemperature(.high)
> 
> 
> 
> I think this is very useful.
> What do you think?
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160219/caec20d7/attachment.html>


More information about the swift-evolution mailing list