-- 
Brent Royal-Gordon
Sent from my iPhone
> On Feb 27, 2017, at 10:39 AM, Matthew Johnson via swift-evolution 
> <swift-evolution@swift.org> wrote:

> 
> Here is an example of the kind of thing I have in mind:
> 
> enum PlayerState {
>   case stopped
>   sub case playing(with track: Track)
> 
>    // type of the playing case looks something like this:
>    struct Playing { let track: Track }
> 
>    // the case value constructor looks something like this
>    static func playing(with track: Track) -> Playing {
>        return Playing(track: track)
>    }
> }

Consider a different desugaring that leads to a different conclusion:

enum PlayerState {
  case struct stopped {
    init() {}
    // I have some truly remarkable thoughts 
    // on types like this one, which this margin
    // is too narrow to contain.
  }
  case struct playing {
    let track: Track
    init(track: Track) {
      self.track = track
    }
}

In this design, because the associated values on a case are really defining an 
initializer on a type, it would be against Swift conventions to use a parameter 
label like `with` instead of the actually-meaningful `track`. So the solution 
to this kind of problem is simply "Don't do that". 

-- 
Brent Royal-Gordon
Sent from my iPhone
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to