On May 6, 2016, at 4:09 AM, Ian Partridge via swift-evolution 
<[email protected]> wrote:
> Currently, the syntax for explicitly naming property setters is:
> 
>     set(newPerimeter) { // declares newPerimeter parameter, "let" not allowed
>       sideLength = newPerimeter / 4.0
>     }
> Compare this with how extraction of associated values from enumerations looks:
> 
> switch response {
> case .Failure(let reason): // let is required here
>   print(reason)
> case .Result(let code):
>   print(code)
> }

I understand what you’re saying, and this would be a logical direction for ML 
or Haskell, which use patterns for their parameter grammars.  In Swift, 
function parameters (including setter parameters, subscript indexes, etc) do 
not allow the general pattern matching or destructuring grammar that you can 
use in ‘case’ patterns, and thus you don’t have to write:

func f(let x : Int) {}

This is one of the reasons that led to SE-0003.

-Chris

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to