On Mon, Nov 24, 2014 at 4:11 PM, Dave Angel <da...@davea.name> wrote:
> The case I found astounding in C++ was in the initializer list where the
> line
>
>     value:value
>
> would assume that the first one was  this->value, and the second was a local
> named value (usually an argument to the constructor).

That's occasionally quite useful. You can create a variable which
shadows another, and reference the original in its initialization, as
a simple means of mocking for debug:

//Maybe a global, or at least at wider scope
string separator="whatever... maybe pulled from a MIME document";
...
{
    string separator="** DEBUG **"+separator+"** DEBUG **";
    ...
    code using separator
    ...
}

You can comment or uncomment the debug line, and everything inside the
braces will be affected by its alteration - but nothing outside them
will, because it's shadowed and not altered. Can be extremely handy.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to