[swift-evolution] Proposal: Pattern Matching Partial Function (#111)
ccruden at novafore.com
Tue Feb 9 14:22:08 CST 2016
> On 2016-02-09, at 22:08:16, Thorsten Seitz via swift-evolution <swift-evolution at swift.org> wrote:
>> I’m not sure where I stand on the switch-less case-list closure, but I am afraid that providing such dedicated closure syntax may set a precedent and cause others to want yet another dedicated closure syntax for their own goal; how do we consider a special closure syntax as acceptable, how many of them are too many.
> Fair enough.
The `case` inside a closure is not a new concept. Scala (among I think a few other functional languages) implements `case` as a partial function inside closures.
I actually use it quite widely, but not as often as I would use it if it were in Swift - since Scala also implements a match expression (which for the most part would be the same as the match function in Swift - with the exception that it does not need function brackets).
Given that at most we will get a match expression or the partial function `case` structure - I would prefer the `case` structure because it gives us both.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution