Boost logo

Boost :

Subject: Re: [boost] Warning policy? local variable hides (i.e. shadows) global variable
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2015-01-18 13:10:39


On Sunday 18 January 2015 17:52:07 Olaf van der Spek wrote:
> On Fri, Jan 16, 2015 at 12:36 PM, Andrey Semashev
>
> <andrey.semashev_at_[hidden]> wrote:
> > On Friday 16 January 2015 12:19:30 Olaf van der Spek wrote:
> >>
> >> Next step would be to have warnings or maybe a per-class attribute or
> >> modifier to make this required.
> >
> > I would really hate that, sorry.
>
> Why?

The second part of my answer expanded on that, I think.

> >> Perhaps @@ for non-local stuff?
> >> It might look silly at first but I think it's better than relying on
> >> coding styles and prefixes.
> >
> > Right, let's add some more mangling to the already complicated C++ syntax.
> >
> > I think C++ name lookup rules are very sane and relying on them is the
> > right thing to do. Just pick the right names and you'll be fine. In fact,
> > the proper names will serve as documentation. Warnings about the code
> > that does exactly what is intended is what irritates me in compilers. I
> > often have to cripple the code just to make them happy and not myself.
> > That's why I typically disable such warnings and not "fix" the code.
> >
> > There will always be room for stupid mistakes like "=" instead of "==" in
> > conditions or a ";" right after the "for" operator or @ instead of @@ in
> > your suggested syntax or whatever else. It doesn't mean that the language
> > is broken. It means you have to pay attention.
>
> Sure, but using a prefix or suffix for member variables is a common
> practice. Do you not do it?

Yes, although not universally. There are cases when no prefixes are needed.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk