Decision on container design

Jonathan M Davis jmdavisProg at gmx.com
Sat Jan 29 19:03:55 PST 2011


On Friday 28 January 2011 10:31:58 Andrei Alexandrescu wrote:
> 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.

Overall, I think definitely support this approach. I definitely think that 
containers should be reference types, and I'm not sure that I care much whether 
they end up being structs or classes. My one concern would be the ability to 
inline the container's function calls, and marking them as final fixes that 
problem. I'm not sure that I know enough about the sealing issue to comment on 
it, but if what we're doing doesn't preclude having it later, then that sounds 
like it's a good compromise. And I definitely think that make it so that 
containers don't have to worry about moving primitives is the way to go.

So, I'm essentially 100% behind this, and I don't see any real issues with it. 
Containers is one of the places that Phobos is generally behind on and which 
really needs to be taken care if we really want people to be using D and Phobos. 
So, it's great to see that progress is being made with regards to containers.

- Jonathan M Davis


More information about the Digitalmars-d mailing list