And yet he safer CPP rules seem to be qt least partially separate from the 
older-but-still-active  “coding style guidelines”

Which is perhaps a larger conversation that needs to happen.

Sounds like there’s zero risk of objections. In this one, so I’ll prep some 
patches.

Sent from my iPhone

> On Apr 11, 2026, at 7:54 AM, Jean-Yves Avenard <[email protected]> 
> wrote:
> 
> +1
> 
> Though I actually thought it was already a rule following updates with SafeCPP
> 
> Sent from my iPhone
> 
>>> On 11 Apr 2026, at 1:33 pm, Brady Eidson via webkit-dev 
>>> <[email protected]> wrote:
>>> 
>> This has come up in countless patch reviews over the last few years, and 
>> it’s been obvious which way the winds are blowing.
>> 
>> Collectively I think we’ve decided it’s beneficial to have types related to 
>> lifecycle management explicitly pointed out in code, and we’ve been 
>> reviewing patches with that strong preference in mind for our common smart 
>> pointer types.
>> 
>> But at the same time, we think it's often ugly and verbose to fully spell 
>> out the full template of smart pointer types e.g.:
>> 
>>     RetainPtr<NSMutableArray> mutableArray = adoptNS([[NSMutableArray alloc] 
>> init]);
>> 
>> That’s a little verbose. So for quite some time we’d preferred:
>> 
>>     auto mutableArray = adoptNS([[NSMutableArray alloc] init]);
>> 
>> But at some point advances in C++ came along and our baseline compiler 
>> support for the project advanced to the point where the template goop isn’t 
>> necessary.
>> So it follows, it’s extremely common review feedback as of late is to use 
>> `RetainPtr` instead:
>> 
>>     RetainPtr mutableArray = adoptNS([[NSMutableArray alloc] init]);
>> 
>> I propose we make this a formal style rule. Update 
>> https://webkit.org/code-style-guidelines/ with examples like:
>> 
>>     auto foo = adoptNS([[SomeClass alloc] init]); // Error
>>     RetainPtr foo = adoptNS([[SomeClass alloc] init]); // The fix
>> 
>>     auto foo = adoptRef(*new SomeClass); // Style error
>>     Ref foo = adoptRef(*new SomeClass); // The fix
>> 
>>     auto foo = adoptRef(new SomeClass); // Style error
>>     RefPtr foo = adoptRef(new SomeClass); // The fix
>> 
>> And it’s even a rule that is trivially enforceable by `CheckWebKitStyle`
>> 
>> Assuming there’s no objection, I’ll be preparing patches for the script and 
>> the website soon.
>> 
>> Thanks,
>>  Brady
>> _______________________________________________
>> webkit-dev mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
_______________________________________________
webkit-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to