[Development] API style guide: scoped enum or not?

Marc Mutz marc.mutz at qt.io
Wed Jun 14 17:35:16 CEST 2023


On 14.06.23 16:33, Tor Arne Vestbø via Development wrote:
>> On 14 Jun 2023, at 16:20, Allan Sandfeld Jensen <kde at carewolf.com> wrote:
[...]
>>> B) new enums MUST be scoped, also when nested in classes¹²
>> -1 Disagree
> 
> -1 Disagree

Ok. But _why_? (Q to both)

>>
>>>
>>> C) scoped enums SHOULD NOT repeat (part of) an enum's type name in the
>>> enumerators²
>>>
>> +1 Agree, and if you find you do repeat the type name in an unscoped 
>> enum it
>> probably should be scoped. But isn't this already in our style guide?
> 
> +1 Agree, and yes, it’s already in our style guide.

It's not really, no. The wording is that repeating the name isn't 
_necessary_. That's the kind of wording that will get a discussion going 
over every new enum. It should say you shouldn't repeat the name, unless 
there's a reason (and QML is not a reason, otherwise it's not an 
exception anymore).

-- 
Marc Mutz <marc.mutz at qt.io>
Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B



More information about the Development mailing list