Developing a plan for D2.0: Getting everything on the table
Bill Baxter
wbaxter at gmail.com
Mon Jul 27 11:13:40 PDT 2009
On Mon, Jul 27, 2009 at 10:58 AM, Andrei
Alexandrescu<SeeWebsiteForEmail at erdani.org> wrote:
> Bill Baxter wrote:
>>
>> The requirement to add the post-blit is a little annoying. If a
>> ValueContainer is made fundamental and it is built initially out of
>> components with value semantics, then no explicit post-blit will be
>> necessary. However if you go the other way and start with a
>> RefContainer then a post-blit will be necessary when you implement the
>> ValueContainer based on it. So to me it seems a little better to go
>> with the ValueContainer as the base implementation.
>
> I think it's a matter of the most frequent use. I used to be a staunch
> supporter of values for containers, until Walter revealed to me that in STL
> you have value containers to constantly worry about adding the "&"
> everywhere. Implicitly copying containers is 95% of cases an error in C++
> code. Witness all that advice about pass by reference etc. So why make that
> the default, one might ask? Better go with the flow and make the default
> case the easy case (reference), and if someone does want a value, have them
> write Value!Container.
Hmm. Yeh, when passing containers around, 95% or more probably should
be by ref.
However when creating composite objects I'd say the percentage of time
you want by ref is much lower.
But I guess even then, by-ref composition isn't necessarily bad (as
most VM languages show).
--bb
More information about the Digitalmars-d
mailing list