Re: scope of variables

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...

To start the dialog, in what situation would it be beneficial to allow duplicate variable names of various types?

I believe it is not a good coding practice because it hinders, rather than enhances, readability of code. When the reader sees 'b = somefunc()' they might get confused if they missed seeing that 'b' was also declared in the local block.

However sometimes when code is 'copy&pasted', shadowed identifiers can get accidentally created - and the code still works. Ideally in that situation, the coder should re-factor the names to better reflect the copied code's new "environment".

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu