[swift-dev] switches versus the visitor pattern?

David Zarzycki zarzycki at icloud.com
Fri Aug 11 18:05:49 CDT 2017

Hi Slava,

Thanks. I’m not planning on seeking them out. I just want to minimize future merge conflicts with an experimental branch I’m working on. The visitor pattern helps people like me by minimizing the number of boilerplate updates a person needs to do after adding a new type to the type system.

Thanks again,

> On Aug 11, 2017, at 18:27, Slava Pestov <spestov at apple.com> wrote:
> I’ve seen some switches over TypeKind more easily expressed as a series of if/else if statements also.
> However unless you come across an ugly switch that you want to refactor while working on something else, I probably wouldn’t spend time actively seeking them out and changing them. I don’t think switching over the kind is considered a code smell in itself.
> Slava
>> On Aug 11, 2017, at 2:48 PM, David Zarzycki via swift-dev <swift-dev at swift.org> wrote:
>> Hello,
>> Before I spend time creating patches, are there arguments against converting exhaustive switch statements to the visitor pattern in the Swift source base? In particular, I’m curious about switches that reason about the TypeKind enum.
>> Thanks,
>> – Dave
>> _______________________________________________
>> swift-dev mailing list
>> swift-dev at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-dev

More information about the swift-dev mailing list