[swift-evolution] Proposal: Pattern Matching Partial Function (#111)

Thorsten Seitz tseitz42 at icloud.com
Wed Feb 3 00:35:29 CST 2016

Hi Craig, 

the following sentence is a bit misleading as it makes the feature seem a special ability on functions which accept closures which I do not think it should be.

> Am 29.01.2016 um 07:43 schrieb Craig Cruden via swift-evolution <swift-evolution at swift.org>:
> Any function which accepts a closure would also be able to accept a closure composed of partial functions defined usingcase/default syntax used in switch-case.

I think it should be a new feature how unary closures can be written, so I would reword it a little bit:

"Any closure that takes one argument can be composed of ..."

This would make your example of using it with reduce() invalid, though, but I think this would create ambiguities with cases where the closure is actually called with a tuple as single argument anyway (similar to the problems of the current autosplatting of tuples as function arguments which Chris want's to remove because of the subtle problems this introduces). It probably would be sufficient to just use match() within the reduction closure.

I still don't like the shortened "cases" variant and would prefer to drop it or at least replace or extend the match() example with a standard variant making it look like a "real" case expression.

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

More information about the swift-evolution mailing list