digitalmars.D.bugs - [Issue 2495] New: const syntax for member functions needs better description
- d-bugmail puremagic.com (32/32) Dec 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2495
- d-bugmail puremagic.com (9/9) Jan 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2495
- d-bugmail puremagic.com (10/10) Jan 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=2495
http://d.puremagic.com/issues/show_bug.cgi?id=2495 Summary: const syntax for member functions needs better description Product: D Version: 2.021 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: www.digitalmars.com AssignedTo: bugzilla digitalmars.com ReportedBy: jlquinn optonline.net The syntax for declaring const member functions is not very clear. There is no grammar. You need to infer from various examples what to do. For instance: class B {} class A { B x; const B getB() { return B; } } doesn't compile, because this is a const function returning a nonconst value. I had to find the answer on a forum. It's challenging to figure this out from the docs: class B {} class A { B x; const const(B) getB() { return B; } } Examples covering more use cases would probably help, as well as more formally describing how const is specified. Perhaps modifying the example of an invariant member function to return a value (other than string) would help. --
Dec 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2495 Commit pushed to https://github.com/D-Programming-Language/d-programming-language.org https://github.com/D-Programming-Language/d-programming-language.org/commit/ad5b50b8bdcc4fd4d26ee4087849843575ab30f2 fix Issue 2495 - const syntax for member functions needs better description -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=2495 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 22 2012