why ; ?

Bruce Adams tortoise_74 at yeah.who.co.uk
Fri May 9 16:10:40 PDT 2008


On Thu, 08 May 2008 19:19:23 +0100, Nick Sabalausky <a at a.a> wrote:

> "Michael Neumann" <mneumann at ntecs.de> wrote in message
> news:fvvd1a$7p3$1 at digitalmars.com...
>> terranium wrote:
>> > Michael Neumann Wrote:
>> >
>> >> Another example which leads to hard to read code and potential
>> >> bugs is (ignoring compiler warnings):
>> >>
>> >>      class A
>> >>      {
>> >>        int i;
>> >>
>> >>        //
>> >>        // add some 25 lines of code here
>> >>        //
>> >>
>> >>        void foo(int i)
>> >>        {
>> >>          // what is "i" here?
>> >>        }
>> >>      }
>> >>
>> >> This is solved in Ruby by using a separate namespace for instance
>> >> variables ("@i" for instance variable "i", and "i" for local variable
>> >> "i").
>> >
>> > In C family languages this is ruled out by naming convention.
>>
>> Which in the case of using a m_ prefix leads to hard(er) to read code.
>> And then there is no standard naming convention, and who actually uses
>> such a naming convention? Without that, you can't easily distinguish a
>> local variable from an instance variable from a global variable.
>>
>
> In "good" C family languages, the instance variable is referred to by
> prefixing it with something like "this.". I think there are some that do  
> it
> differently (ECMAScript, IIRC), but I'd argue those ones are making a big
> mistake.
>
A interesting take on this comes from the IDE crowd. You always know the  
type/context
of a variable because of tool-tips and syntax highlighting.
Its just us old-timers stuck in a world of ASCII editing.



More information about the Digitalmars-d mailing list