[Issue 3452] New: Can't alias member functions such that the object name is implicitly stored in the alias

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Oct 29 14:00:44 PDT 2009


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

           Summary: Can't alias member functions such that the object name
                    is implicitly stored in the alias
           Product: D
           Version: 2.035
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dsimcha at yahoo.com


--- Comment #0 from David Simcha <dsimcha at yahoo.com> 2009-10-29 14:00:43 PDT ---
struct Foo {
    void bar() {}
    void baz() {}
}

void doStuff(Foo foo) {
    alias foo.bar fun;
    fun();  //  Error: need 'this' to access member bar
}

I can't think of any reason why this shouldn't work.  foo.bar is a compile-time
symbol for the member function Foo.bar() on the instance foo.  Once I alias
foo.bar to fun, calling fun() should be equivalent to calling foo.bar().

Even if there's some language legalese reason why this shouldn't work according
to the spec, it's still a reasonable enhancement request.

-- 
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