Module level variable shadowing

via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 29 05:43:57 PDT 2014


On Saturday, 28 June 2014 at 12:20:15 UTC, Ary Borenszweig wrote:
> On 6/28/14, 6:30 AM, Jacob Carlborg wrote:
>> On 2014-06-28 08:19, dennis luehring wrote:
>>
>>> thx for the examples - never though of these problems
>>>
>>> i personaly would just forbid any shadowing and 
>>> single-self-assign
>>> and then having unique names (i use m_ for members and p_ for 
>>> parameters
>>> etc.) or give a compile error asking for this.x or .x (maybe 
>>> problematic
>>> with inner structs/functions)
>>
>> I think, in general, if you need to prefix/suffix any symbols 
>> name,
>> there's something wrong with the language.
>
> In Ruby the usage of a variable is always prefixed: `@foo` for 
> instance vars, `$foo` for global variable, `FOO` for constant. 
> You can't make a mistake. It's... perfect :-)

OTOH, the distinction between methods and local variables isn't 
as easy to see. It's still deterministic, albeit using 
non-obvious syntactic rules.


More information about the Digitalmars-d mailing list