[swift-evolution] Consolidate Code for Each Case in Enum

David Sweeris davesweeris at mac.com
Wed Jan 11 09:08:19 CST 2017


> On Jan 11, 2017, at 08:48, Derrick Ho via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Interesting proposal Tim. So instead of repeating the enum cases multiple times we repeat the functions multiple times?
> 
> I feel like this merely flipping the complexity but not really getting rid of it.

I think you have correctly summarized the proposal.

The complexity can't be gotten rid of (except maybe with macros... depending on the details, of course). Sometimes viewing the same thing from a different angle can be helpful. As long as this syntax is "in addition to" and not "instead of", the only downside I can see to allowing this is a bit of "language bloat", which doesn't particularly bother me. I don't know how hard it would be for the compiler to sort out which "mode" it should parse the enum in, though, especially since you might want to write some parts in the regular way and some parts in this new way.

So... I guess I'm +1, pending someone who knows more about compiler internals weighing in on implementation implications.

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170111/571f4d1f/attachment.html>


More information about the swift-evolution mailing list