I like the spirit of this idea because it matches features found in other
languages that have prominent pattern matching (ML, Haskell, etc.). But I’m
concerned about the overloading of existing syntax for this case. Plus, if you
find yourself destructuring large enum cases like this, have you considered
making a struct containing those fields?
enum Value {
struct Leaf {
let data: Any?, moreData: Any?, evenMoreData: Any?
}
case container(leafs: [Value])
case leaf(Leaf)
}
func foo(_ v : Value) {
switch v {
case let .leaf(x):
print(x.data, x.moreData, x.evenMoreData)
case .container:
break
}
}
~Robert Widmann
> On Jul 10, 2017, at 8:35 AM, Sash Zats via swift-evolution
> <[email protected]> wrote:
>
> Hi, I wanted to propose a better handling of enum cases with associated value
> (somewhat) detailed proposal is here
> https://github.com/zats/swift-evolution/blob/master/proposals/0181-better-handling-of-enum-cases-with-associated-values.md
>
> <https://github.com/zats/swift-evolution/blob/master/proposals/0181-better-handling-of-enum-cases-with-associated-values.md>
> I'm not sure I can suggest good detailed implementation since I'm not too
> familiar with Swift internals
> But i'm sure it's something I can research if proposal makes sense to
> community
> Since I havne't communicated through this mailing list, I'm not sure what's
> the etiquette, let me know if something is missing from the proposal.
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution