[swift-dev] switches versus the visitor pattern?

John McCall rjmccall at apple.com
Sat Aug 12 11:02:18 CDT 2017


> On Aug 12, 2017, at 6:45 AM, David Zarzycki <zarzycki at icloud.com> wrote:
>> On Aug 11, 2017, at 19:21, John McCall <rjmccall at apple.com> wrote:
>> 
>>> On Aug 11, 2017, at 7:05 PM, David Zarzycki via swift-dev <swift-dev at swift.org> wrote:
>>> 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.
>> 
>> Unless you’re splitting an existing type, most of the boilerplate updates are intentional — we want people to think about every case when doing the update.
> 
> I understand. Rather than discuss this abstractly, let’s consider a concrete example: Type::transformRec() in lib/AST/Type.cpp seems like a clear candidate that could and should switch to the visitor pattern because both NominalType and ReferenceStorageType are being handled abstractly. To what extent to you agree or disagree?

I agree.

John.


More information about the swift-dev mailing list