mixins rock
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Jul 26 07:37:19 PDT 2012
On 9/9/04 10:44 PM, Ben Hinkle wrote:
> Here I thought mixins were a pain but I've been going through mintl and
> experimenting with consolidating shared code into mixins and they've been
> working great. I'd like to really say thanks to Walter for adding mixins. I
> wasn't convinced before but I'm really liking them now. In my sandbox mintl
> now has three mixins:
> - one for opCat-like functions (6 functions)
> - one for opApply overloads and variations (8 functions)
> - one for backwards opApply and toSeq variations (5 functions)
>
> They cut way down on the cut-and-paste aspect of mintl that had been
> bothering me. It's to the point where there isn't any "boilerplate" code in
> the individual containers.
>
> I've found using public mixins to be more successful that using private
> mixins. Private symbols seem to trip up mixins. The rules are probably
> obvious but I haven't taken the time to figure them out so I've gotten in
> the habit of only mixing in public declarations and having the mixins only
> reference public symbols.
>
> -Ben
Nice work, and good discussion in this thread. A great next step would
be to write about how you all use mixins (both of the code and string
kind) in blogs and articles.
Andrei
More information about the Digitalmars-d
mailing list