--- Comment #4 from Steven Schveighoffer <> 2010-09-20 
04:36:35 PDT ---
Well, first of all, toString should always be const.

But pure and nothrow are two options that are also valid.  I think some real
thought needs to go into delegates and function pointers, and what can
implicitly cast.  Right now, there are no implicit casts between function
pointers (except const casts which are invalid anyways).

As a workaround, you can do something like this:

struct A {
  /*pure nothrow?*/ string toString() const { return "A"; }
  string toString() {const(A)*me = &this; return me.toString();}

What this does is put a common implementation for each overload so you don't
have to rewrite it.

When the requirements change (and they will, because toString should be const),
then in most cases you can just get away with a const function.  If you want to
have pure and nothrow available, then you still have to do something like this.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to