Any preference on using braces to restrict scope?
Scott Kostyshak
skostysh at lyx.org
Fri Nov 18 18:13:02 UTC 2022
On Fri, Nov 18, 2022 at 06:43:38PM +0100, Thibaut Cuvelier wrote:
> 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.
Thanks, Thibaut. I agree that the syntax is strange. Perhaps once I got
used to it, it would indeed be the simplest way to reduce the scope. In
any case, I'm glad to know this alternative since I indeed was not aware
of it before I saw it in the code.
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/51024314/attachment.asc>
More information about the lyx-devel
mailing list