DTL vs. STL - Mixins for sort()?

Don Clugston dac at nospam.com.au
Tue May 2 23:23:33 PDT 2006


Ivan Hernandez wrote:
> There was some comments about:
> 
>>> 1) It seems like things like sort, reverse, etc. are being attached as
>>> member functions rather than seperate functions. One of the nicest
>>> things about the STL is that you only have to write sort once, rather
>>> than attach it to every container. This seems more like a step backwards
>>> than a step forwards.. any particular reason?
> 
> asserting that D Templates are not instantiated like in C++ and that's why the
> sort() is being implemented on each collection class. But I think that's not a
> problem. sort() is a generic fuction, and it should work with any collection
> type. Couldn't it be implemented as a mixin?
> 
> I'm not really aware of mixin limitations on D, but it should work in other
> languages, be theirs typings dynamic like Ruby or Python, or static as Sather
> and Eiffel (all four of them allowing for code inclusion within a class).

When DTL was written, there was no implicit template function 
instantiation (IFTI). Now that we have IFTI, sort could be written 
similarly to how it's done in C++.
In fact, DTL contains many workarounds which are no longer necessary.



More information about the Digitalmars-d-dtl mailing list