[Issue 4070] New: prefix const on member functions considered confusing

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 5 10:26:46 PDT 2010


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

           Summary: prefix const on member functions considered confusing
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: simen.kjaras at gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras at gmail.com> 2010-04-05 10:26:45 PDT ---
struct foo {
  const foo* bar( ) const {
    return new foo;
  }
}

This function does not return a const foo, as one might expect. Rather, it is
twice specified that this function does not change any members of foo.

This is troublesome because, everywhere but in a function declaration, const
foo* would be equivalent to const( foo* ). It is hence a source of confusion
and inconsistency.

If this is a case of unfortunate C++ inheritance, please make const foo bar( )
an error, and enforce the use of parentheses. If not, get rid of it.

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