Any preference on using braces to restrict scope?

Scott Kostyshak skostysh at lyx.org
Fri Nov 18 18:33:48 UTC 2022


On Fri, Nov 18, 2022 at 06:14:01PM +0000, José Matos wrote:
> On Fri, 2022-11-18 at 18:43 +0100, Thibaut Cuvelier wrote:
> > You can avoid this level of indentation by defining the variable
> > within the if: 
> > 
> > if (const vector<docstring> potential_terms =
> > getSubentriesAsText(runparams); !potential_terms.empty()) {
> > 
> > I don't really like this syntax, because it makes extremely long
> > lines, but it has strong advantages.
> 
> This helps a bit:
> 
> if (const auto potential_terms = getSubentriesAsText(runparams);
>     !potential_terms.empty()) {...}
> 
> Using const auto and aligning the condition with the opening
> parenthesis.
> 
> FWIW I think that using curly brackets just to define the variable's
> scope is ugly. :-) This is an aesthetic opinion but the issue is also
> just aesthetic. :-D

Makes sense. I will drop the patch :)

Thanks to you and Thibaut for the feedback.

Scott
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221118/f5813595/attachment.asc>


More information about the lyx-devel mailing list