Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-12 Thread Benjamin Spratling via swift-evolution
> On Jul 12, 2017, at 7:33 PM, Itai Ferber via swift-evolution > wrote: > When the conditional conformance feature arrives in a future Swift release, Speaking of this, what concerns me is the really long list of approved swift features that haven’t been implemented.

Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-12 Thread Itai Ferber via swift-evolution
That’s fair. :) I think in the time frame of Swift 4, this would be too big of an addition and would require more thought, but: 1. When the conditional conformance feature arrives in a future Swift release, a lot of the hacks surrounding `Equatable` can go away here, because we’ll get things

Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-11 Thread William Shipley via swift-evolution
You’re right, my current implementation doesn’t win anything over what you’re written - in fact your technique is basically what I wrote at first. I was trying to work towards encapsulating the behavior in the encoder/decoder so that the automatic init/encode methods could work, so I wanted to

Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-11 Thread Itai Ferber via swift-evolution
Hi Wil, Thanks for putting this together! My biggest thought on this is — what does this provide that you can’t already do yourself today? Since you have to go through the work to put together default values and override `init(from:)` and `encode(to:)` to use them, I’m wondering whether this

Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-10 Thread Randy Eckenrode via swift-evolution
It seems like it would be cleaner to extend CodingKey. There might be a more general way of doing this than just requiring a Dictionary, but it seems to work. protocol DefaultingCodingKey: CodingKey, Hashable { static var defaults: [Self: Any] { get } } // Implementing the other overrides

Re: [swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-10 Thread Greg Parker via swift-evolution
> On Jul 10, 2017, at 5:16 PM, William Shipley via swift-evolution > wrote: > > (Note the horrible hack on KeyedEncodingContainer where I had to special-case > arrays of s, I guess because the compiler doesn’t know an array of > s is Equatable itself?) Correct.

[swift-evolution] [Request for Feedback] Providing defaults for reading and writing.

2017-07-10 Thread William Shipley via swift-evolution
Automatic substitution / removal of default values is very useful when reading or writing a file, respectively, and should be supported by the family of protocols and objects: • When reading, swapping in a default value for missing or corrupted values makes it so hand-created or