Congratulations to the D Team!
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jul 11 11:11:31 PDT 2012
On Wed, Jul 11, 2012 at 08:01:44PM +0200, deadalnix wrote:
> On 11/07/2012 19:49, Andrei Alexandrescu wrote:
> >On 7/11/12 1:40 PM, Jakob Ovrum wrote:
> >>Some classes don't lend themselves to immutability. Let's take something
> >>obvious like a class object representing a dataset in a database. How is
> >>an immutable instance of such a class useful?
> >This is a good point. It seems we're subjecting all classes to certain
> >limitations for the benefit of a subset of those classes.
> Did you saw the proposal of feep/tgehr on #d ?
> It basically state that you can overload a const method with a non
> const one if :
> - You don't mutate any data that belong to the parent.
> - You are prevented to create any immutable instance of that classe
> or any subclasse.
+1, very good, I like this idea!
It parallels my idea about the base class being const but not the
derived class, except that this is a much better implementation (no need
for new syntax, fits in with the existing type system). So basically the
const in const(BaseClass) applies only to the members inherited from
BaseClass, and the derived class's members are allowed to mutate.
More information about the Digitalmars-d