I agree this seems more like a cxx question.

Note that one reading of the Google C++ style guide actually requires use
of if-with-initializer when applicable:

"Place a function's variables in the narrowest scope possible, and
initialize variables in the declaration."

Reasonable engineering judgment on the "narrowest scope possible" is fine,
but this C++ feature isn't even particularly obscure in 2025.

On Tue, Aug 12, 2025, 1:31 PM Giovanni Ortuño <ort...@chromium.org> wrote:

> Would c...@chromium.org <https://groups.google.com/a/chromium.org/g/cxx>
> be a better group for this type of discussion?
>
> On Tue, Aug 12, 2025 at 4:24 PM Matt Menke <mme...@chromium.org> wrote:
>
>> The question wasn't so much whether it's allowed, but whether it's a
>> reasonable style choice, due to the loss in readability. If there was a
>> widespread shift to prefer the pattern, that's one thing, but if one or two
>> developers introduce it only in their corners of the code, that's
>> potentially a significant loss in readability when other Chrome devs work
>> on that corner of the world.
>>
>> On Tue, Aug 12, 2025 at 4:20 PM Daniel Cheng <dch...@chromium.org> wrote:
>>
>>> It's been allowed in Chrome C++ for some time now, so it's allowed in
>>> Blink.
>>>
>>> In general,
>>> https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++-features.md
>>> tries to default allow features in older C++ versions, with specific
>>> callouts to things that are banned.
>>>
>>> Daniel
>>>
>>> On Tue, 12 Aug 2025 at 13:13, 'Stefano Duo' via blink-dev <
>>> blink-dev@chromium.org> wrote:
>>>
>>>> Hi blink-dev,
>>>>
>>>> Matt gave me advice to mail this list.
>>>>
>>>> We are discussing
>>>> <https://crrev.com/c/6830059/3..10/components/cronet/cronet_proxy_delegate.cc#b95>
>>>>  a
>>>> C++ 17 feature: if statements with initializers
>>>> <https://abseil.io/tips/165>. It is recommended when a variable is
>>>> used within the if statement, but not outside of it.
>>>>
>>>> Pros: reduced variables scope.
>>>> Cons: new syntax, currently not common in Chromium.
>>>>
>>>> How does the community feel about this? Should its usage be allowed?
>>>>
>>>> Thank you,
>>>> Stefano
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "blink-dev" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to blink-dev+unsubscr...@chromium.org.
>>>> To view this discussion visit
>>>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/f8f46d20-0fe9-4a8d-b8a8-30d99a39a635n%40chromium.org
>>>> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/f8f46d20-0fe9-4a8d-b8a8-30d99a39a635n%40chromium.org?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "blink-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to blink-dev+unsubscr...@chromium.org.
>> To view this discussion visit
>> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAEK7mvpS054nM4bsd%2BUzZ7trefV13MmJeF22YTHw0j%3DLco5Y4g%40mail.gmail.com
>> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAEK7mvpS054nM4bsd%2BUzZ7trefV13MmJeF22YTHw0j%3DLco5Y4g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "blink-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to blink-dev+unsubscr...@chromium.org.
> To view this discussion visit
> https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAMDKGBV6_OKnUSP9cv0WTrMB7bbc1FHtNq6qwHVRtLS8x%3DbCgw%40mail.gmail.com
> <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAMDKGBV6_OKnUSP9cv0WTrMB7bbc1FHtNq6qwHVRtLS8x%3DbCgw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to blink-dev+unsubscr...@chromium.org.
To view this discussion visit 
https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CACwGi-7H%3DiFcdKx%2Bm0WDJL9NVPPmtsFNmmD5VBwbRbQ5-Dfz7g%40mail.gmail.com.

Reply via email to