Decision on container design

Michel Fortin michel.fortin at michelf.com
Fri Jan 28 13:05:59 PST 2011


On 2011-01-28 13:31:58 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> Today after work I plan to start making one pass through std.container. 
> After having thought of things for a long time, my conclusions are as 
> follows:
> 
> 1. Containers will be classes.
> 
> 2. Most of the methods in existing containers will be final. It's up to 
> the container to make a method final or not.
> 
> 3. Containers and their ranges decide whether they give away references 
> to their objects. Sealing is a great idea but it makes everybody's life 
> too complicated. I'll defer sealing to future improvements in the 
> language and/or the reflection subsystem.
> 
> 4. Containers will assume that objects are cheap to copy so they won't 
> worry about moving primitives.
> 
> Any showstoppers, please share.

Not my preferred choices (especially #1), but having containers in 
Phobos will certainly be an improvement over not having them. So go 
ahead!

About #4, it'd be nice to have the containers use move semantics when 
possible even if they fallback to (cheap) copy semantic when move isn't 
available. That way, if you have a type which is moveable but not 
copyable you can still put it in a container. Does that makes sense?


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list