[webkit-dev] Compile times and class-scoped enums

Jer Noble jer.noble at apple.com
Mon Jan 23 11:23:12 PST 2023



> On Jan 23, 2023, at 11:05 AM, Geoffrey Garen <ggaren at apple.com> wrote:
> 
>>> However, this change requires moving class-scoped enums out into the namespace scope.
>> 
>> Seems worthwhile. Doesn’t seem to me like it would have far reaching effects.
> 
> I agree.
> 
>> +    using Type = DOMAudioSessionType;
> 
> Did you do this to make the patch smaller, or do you prefer this style?

Yes to both. IMO, there’s nothing inherently wrong with having an enum scoped to a class apart from that makes it impossible to forward declare. If there was some language supported mechanism to forward-declare class-scoped enums, we’d probably just do that instead. So, this pattern of declaring the enum outside of a class and pulling it into the class with a using declaration is a bit ugly, insofar as it pollutes the global namespace, but it does allow you to continue to use the type as if it were file scoped.

-Jer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20230123/21e19529/attachment.htm>


More information about the webkit-dev mailing list