[swift-evolution] Anonymous Enums
Harlan Haskins
harlan at harlanhaskins.com
Fri Feb 19 14:57:01 CST 2016
My worry is that this isn’t very different from
enum Temperature { case low, normal, high }
It’s 7 more characters and fully expressible now.
- Harlan
> On Feb 19, 2016, at 12:48 PM, Sean Heber via swift-evolution <swift-evolution at swift.org> wrote:
>
> I too very much like the cleverness of this, but in my experience often what is initially a single-use enum turns into a multi-use enum in short order, so I don’t know if I’d be able to use this much at the end of the day.
>
> Gotta say I like that syntax, though. Could be neat as a shorthand for defining regular enum cases, maybe! :P
>
> enum Temperature = [low | normal | high]
>
> l8r
> Sean
>
>
>> On Feb 19, 2016, at 2:42 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> It's certainly clever and I particularly like the temperature example.
>>
>> -- E
>>
>>
>>> On Feb 19, 2016, at 9: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
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> 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/86e09933/attachment.html>
More information about the swift-evolution
mailing list