Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 14:45:26 + bearophile via Digitalmars-d-learn wrote: > ketmar: > > > Jonathan explains it very well. i can add the only thing: don't > > use `const` until you forced to. ;-) > > In D use immutable (or const) everywhere you can. Possibly mark > as immutable everything d

Re: rebind of const class variables

2015-01-20 Thread bearophile via Digitalmars-d-learn
ketmar: Jonathan explains it very well. i can add the only thing: don't use `const` until you forced to. ;-) In D use immutable (or const) everywhere you can. Possibly mark as immutable everything doesn't need to mutate. sure, you can cast `const` away in your code, but using `cast` is a

Re: rebind of const class variables

2015-01-20 Thread ketmar via Digitalmars-d-learn
On Tue, 20 Jan 2015 09:29:45 + qqiang via Digitalmars-d-learn wrote: > I am writing a tree data structure, and I have the following code: > > ```D > final class Node { > private { > int val_; > Node parent_; > Node left_; > Node right_; > } > > @proper

Re: rebind of const class variables

2015-01-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 20, 2015 09:29:45 qqiang via Digitalmars-d-learn wrote: > I am writing a tree data structure, and I have the following code: > > ```D > final class Node { > private { > int val_; > Node parent_; > Node left_; > Node right_; > } > > @property > const(N

Re: rebind of const class variables

2015-01-20 Thread Mathias LANG via Digitalmars-d-learn
On Tuesday, 20 January 2015 at 09:29:46 UTC, qqiang wrote: I am writing a tree data structure, and I have the following code: ```D final class Node { private { int val_; Node parent_; Node left_; Node right_; } @property const(Node) maximum() con

rebind of const class variables

2015-01-20 Thread qqiang via Digitalmars-d-learn
I am writing a tree data structure, and I have the following code: ```D final class Node { private { int val_; Node parent_; Node left_; Node right_; } @property const(Node) maximum() const { auto ret = this;