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-15 12:22:06


On Thu, Jan 15, 2015 at 4:59 PM, Beman Dawes <bdawes_at_[hidden]> wrote:
> On Thu, Jan 15, 2015 at 10:09 AM, Olaf van der Spek <ml_at_[hidden]> wrote:
>> On Thu, Jan 15, 2015 at 2:11 PM, Beman Dawes <bdawes_at_[hidden]> wrote:
>>> A lot of the warnings involve function argument names. Should we have
>>> a guideline to prevent shadow warnings? A convention for argument
>>> names would make it easier to submit pull requests. Possible
>>> guidelines:
>>>
>>> * Prefix function argument names with "a_". Rationale: The "m_" prefix
>>> for member names has been a success.
>>> * Suffix function argument names with "_". Rationale: Short and less
>>> distracting than "m_" prefix.
>>>
>>> Thoughts?
>>
>> The "_" suffix is used for member names too.
>
> Hummm... You are right.
>
> 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.

-- 
Olaf

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