SE-0295: Codable synthesis for enums with associated values (second review)

A very big +1 from me.
Thanks again for all your efforts in making this a part of Swift, @drexin!

I very much agree with most points in the proposal.

The only comment I have is with regards to cases where not all associated values are labelled.

There was an idea by @anandabits in the previous review discussion that keys are auto-generated for unlabelled values. This has the great advantage that you can then customize the key mapping:

I think that this is a really elegant solution that provides great flexibility.

Personally I also think that it could be nice with a 'Future directions' where we could consider the similarity between tuples and enum cases with multiple and/or labelled values - and then consider allowing encoding of structs and classes with values that are tuples (of Codable values). We could do this by borrowing the result of this proposal, and use the same strategy for supplying named coding keys for these tuples. But this is a minor thing that could be added in the future.

  • Is the problem being addressed significant enough to warrant a change to Swift?
    Most definitely.

  • Does this proposal fit well with the feel and direction of Swift?
    Yes. I am very excited by the proposal and I feel that it will be a great addition to the language.

  • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

I participated quite a bit in the first review discussion.

6 Likes