[Issue 3878] Arguments and members with the same name

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 17 16:06:21 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3878



--- Comment #9 from bearophile_hugs at eml.cc 2010-10-17 16:05:41 PDT ---
In this enhancement request I am asking for ideas to avoid a common but
specific kind of bug.
One idea (not mine) to avoid some of those bugs is to introduce the
this.fieldname syntax for method argument (type is optional and it may be
different from the field type). In the constructor the argument assigns
directly to the field:


class Foo {
    int x;
    this(this.x) {}
    void inc(int x) { this.x += x; }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list