Any preference on using braces to restrict scope?

Thibaut Cuvelier dourouc05 at gmail.com
Fri Nov 18 17:43:38 UTC 2022


On Fri, 18 Nov 2022 at 18:41, Scott Kostyshak <skostysh at lyx.org> wrote:

> What do you think of the attached patch? It adds braces to restrict the
> scope of the variable 'potential_terms'. I like this style, since it
> makes it easier for me to read, but I wonder if others would find it
> annoying. For example, it adds an extra layer of indentation.
>

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20221118/002be0ce/attachment-0001.html>


More information about the lyx-devel mailing list