Making containers that "go both ways"
Bill Baxter
dnewsgroup at billbaxter.com
Fri Jan 25 18:02:47 PST 2008
Hey,
Just wanted to throw this idea out for comment.
I find I can't really decide whether a container class should be a
struct or a class. Struct feels right if I want minimal overhead and
something that works more like a built-in datatype. But class feels
right for situations where I'm less concerned about performance, and
also offers the additional ability to extend the basic functionality via
subclassing.
So something I did (a while back now...) was to create some containers
in OpenMesh/D that use mixins for all their guts, and provide both
struct and class wrappers for them.
It seems to me like that might be the "right" way to do containers in D.
Somewhat unfortunately, because it's more complicated than just writing
one or the other.
Thoughts?
--bb
More information about the Digitalmars-d
mailing list