> 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.
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
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
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
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
> 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.
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