D wrapper classes leak memory. Next steps?

via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 31 18:11:21 PDT 2014


On Friday, 31 October 2014 at 21:43:26 UTC, eles wrote:
> it would seem to make sense to make them all const by default, 
> and one would have to specifically mark as mutable those that 
> would be changed.

Yes, I think that would be interesting. I also thought about the 
possibility of putting all mutable parameters to the left of a 
dot-operator, but it takes some time getting used to (not sure if 
I could get used to it):

(arr1,arr2).swap_range(10,20);

arr1.merge(arr2); //merge by copy
(arr1,arr2).merge; // merge by moving

> -- Why not make all pointer declarations as constant by 
> default? Then, you explicitely ask for a mutable reference 
> (hell, you could even limit the number of mutable references 
> that could be asked for, if you want). Just reformulate to say:

I think immutable/const by default is the best option. It is 
primarily in loops that mutable is needed and since mutables are 
more likely to cause bugs it would be nice to have some attention 
drawn to them.



More information about the Digitalmars-d mailing list