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

Maximilian Hünenberger m.huenenberger at me.com
Thu Feb 4 08:34:57 CST 2016


I'm open to this topic. Looking for more community feedback...

In my opinion it should be either the more verbose form or the concise one.

Just like parameters in closures: You can use shorthand argument names ($0, $1, $2,...) or parameter names.

> Am 04.02.2016 um 15:18 schrieb Craig Cruden <ccruden at novafore.com>:
> 
> I originally had them mutually exclusive but there was pushback and the fact that no harm would be done by mixing them - I did not see the reason why not to allow them.
> 
> You could have a couple cases each with several lines of code then a value, and then a few that are just key/value mappings….  
> 
> 
>> On 2016-02-04, at 21:14:58, Maximilian Hünenberger <m.huenenberger at me.com> wrote:
>> 
>> Should we allow mixing "case" and "cases"?
>> 
>> I don't think so since a "cases" between several "case"'s is not recognizable enough.
>> 
>> With the current grammar "cases" is also allowed after "case" labels:
>> 
>> Example (this is currently allowed):
>> 
>> match(3) {
>>   case 1: "one"
>>   case 2: "two"
>>   cases 3: "three", 4: "four"
>>   default: "undefined"
>> }
> 


More information about the swift-evolution mailing list