Boost logo

Boost :

Subject: Re: [boost] Warning policy? local variable hides (i.e. shadows) global variable
From: Olaf van der Spek (ml_at_[hidden])
Date: 2015-01-16 06:19:30

On Fri, Jan 16, 2015 at 4:46 AM, Gavin Lambert <gavinl_at_[hidden]> wrote:
> On 16/01/2015 06:22, Olaf van der Spek wrote:
>> On Thu, Jan 15, 2015 at 4:59 PM, Beman Dawes <bdawes_at_[hidden]> wrote:
>>> So like with the "m_" prefix, a boost library wishing to avoid
>>> shadowing would need to use deliberately ugly or unusual formal
>>> parameter names. Ugh!
>> Ruby requires @ to access class members. I've been wondering, wouldn't
>> it be nice to have something like this in C++ as well?
>> "m_" and "_" would no longer be required.
>> Obviously this isn't a short-term solution.
> There *is* something like that in C++ -- you can prefix all member accesses
> with "this->".

Right, but that's just ugly. :p

> Of course, then you get yelled at by all the people who hate the added
> verbosity, because this is optional. (And I don't disagree with them; and
> the pun was intended.)

Next step would be to have warnings or maybe a per-class attribute or
modifier to make this required.

> (And it doesn't help with function arguments, which is what was being
> discussed here.)

Perhaps @@ for non-local stuff?
It might look silly at first but I think it's better than relying on
coding styles and prefixes.


Boost list run by bdawes at, gregod at, cpdaniel at, john at