Shadowing of members
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jan 9 23:49:01 PST 2013
On Thursday, January 10, 2013 08:40:00 Jacob Carlborg wrote:
> On 2013-01-10 03:57, bearophile wrote:
> > Most wise programmers use different argument names like a_,b_ and so on,
> > because it's very easy to create bugs in that situation.
>
> If you need a special naming convention for your member variables you
> have made something wrong when designing the language.
You don't need it. It just makes the code clearer if you do. Certain classes
of problems don't generally happen when you do that. But if someone prefers to
not name their member variables specially, then they don't have to. Just like
someone could prefer to always reference member variables with the this
pointer/reference, but it's not required. Out of the two, I think that
prepending member variables with _ makes way more sense. But to each their
own. The language doesn't force anything on you with regards to variable names
save for the fact that you can't use key words for them and the fact that you
can't shadow local variables with other local variables.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list