Heap: container or range?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jan 29 20:21:01 PST 2009


> I still have yet to come to terms with passing ranges by value. I
> would expect take to modify my range. I naturally expect heaps to be
> destructive as elements are taken out. I also expect ranges to
> shrink. I don't see any issue...

Both ways have advantages and disadvantages. My early experiments 
involved passing by reference and it was an absolute mess: I'd forget a 
"ref" here and there with weird results, or I'd forget to save a copy of 
my range and I'd find is shrunk like an dehydrated fig in no time. One 
advantage of pass by value is that code is shorter and nicer - no need 
for a lot of temporaries.

Andrei



More information about the Digitalmars-d mailing list