dcollections 1.0 and 2.0a beta released

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri May 21 11:00:42 PDT 2010


On 05/20/2010 05:34 AM, Steven Schveighoffer wrote:
> Robert Jacques Wrote:
>
>> On Wed, 19 May 2010 21:42:35 -0400, Steven Schveighoffer
>>>
>>> Does that make sense?
>>>
>>> -Steve
>>
>> Yes and No. I understand where your coming from, but I think it's a
>> bad idea. First, I think it needlessly expands the radius of
>> comprehension needed to understand and use the library. (See
>> Tangled up in tools
>> http://www.pragprog.com/magazines/2010-04/tangled-up-in-tools)
>> Second, I think designing a library to be flexible enough to meet
>> some future, anticipated need (e.g. dlls) is a good idea, but
>> actually implementing vaporous future needs is fraught with peril;
>> it's too easy to guess wrong. Third, interface base design is
>> viral; If library X uses interfaces then I have to use interfaces
>> to interface with it. And if another library Y uses classes, then
>> I'm going have to write a (needless) wrapper around one of them.
>
> I understand these points, but I'm already using interfaces to copy
> data between containers.  I don't have to, I could have used generic
> code, but this way, only one function is instantiated to copy data
> from all the other containers.  The problem with using generic code
> is that the compiler will needlessly duplicate functions that are
> identical.

There is a copy() function that copies any range to any other range. It
might need a revisit, but I think the way to go about copying is generic.

Let's not forget that the code for copying itself is rather short and
that applications don't tend to use a large number of container types.

> Using interfaces is not as viral as you think.  My interfaces can be
> used in generic code, as long as the generic code uses functions in
> the interfaces.  If a library returns an interface, the author is
> saying "I don't want you using any functions outside this interface,"
> so why is that a bad thing?
>
> Forcing people to *not* use interfaces has its drawbacks too.
> Dcollections gives the most flexible design I could muster, while
> still being useful.
>
> I'm not saying I'm against removing the interfaces until some later
> date, but I don't see any convincing arguments yet, especially since
> I've already seen benefits from having them.

What are the benefits that you have noticed? I think you'd need to back 
up the copying argument with some data if you want to frame it as a benefit.


Andrei


More information about the Digitalmars-d-announce mailing list