[swift-evolution] Proposal: pattern match based on associated value(s) only

Seth Friedman sethfri at gmail.com
Sun Feb 28 15:39:46 CST 2016


+1 to this. I've said this before, Amir, but please take the time to
actually write a considered proposal instead of increasing the already high
traffic of this list with a couple words and a code sample.

On Mon, Feb 22, 2016 at 7:11 PM Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> > For example:
> >
> > enum Color {
> >       ...
> > }
> >
> > enum Vehicle {
> >       case Car(Color)
> >       case Motorcycle(Color)
> >       ...
> > }
> >
> > switch vehicle {
> >       case _(.Red): … // pattern match based on associated value only
> > }
>
> As usual, Amir:
>
> 1. Why do you want this feature?
>
> 2. What's actually wrong with the status quo?
>
> 3. Can you talk about a non-toy example you've encountered where it would
> have made your code better?
>
> 4. Can you talk about the proposed design in a little more detail? Are
> there weird edge cases, and how would you handle them? (In the case of this
> feature, here's one I see: Suppose you have two different associated value
> types but they both have a .Red case. What happens then?)
>
> A half-dozen-word subject line and a code example simply aren't enough to
> evaluate a proposal. Without knowing exactly what you're proposing and why
> you think it's a good idea, we can't really evaluate it properly.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> 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/20160228/83f562b6/attachment.html>


More information about the swift-evolution mailing list