const?? When and why? This is ugly!
Michel Fortin
michel.fortin at michelf.com
Sat Mar 7 16:58:51 PST 2009
On 2009-03-07 18:19:50 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> said:
> Later on I decided to save the filename for error message reporting and
> the such. Now I had two choices:
>
> (1) Leave the signature unchanged and issue an idup:
>
> this.filename = to!string(filename); // issues an idup
>
> (2) Change the signature to
>
> this(string filename);
Third choice: have two contructors.
this(in char[] filename) { this(filename.idup); }
this(string filename) { ... }
It's pretty easy to add a new version of a construcor or function when
you change things and need to keep backward compatibility. The question
is: should you?
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list