Exceptional coding style
Mehrdad
wfunction at hotmail.com
Wed Jan 16 13:45:48 PST 2013
On Wednesday, 16 January 2013 at 19:29:59 UTC, mist wrote:
> Mixins and templates are tools to avoid copy-paste, there is no
> point to using them just for the sake of that. I have already
> mentioned that first example is not related to copy-paste and
> thus not fixable with that, it is more related to alias. Second
> is fixed perfectly in D using string mixins and single template
> unary operator with much more readable code.
String mixin are uglier than C-macros, IMO.
(No, I'm not saying they're worse. They're just uglier, visually
speaking.)
I avoid string mixins as much as possible.
Not to mention they're quite intensive work for the compiler to
do compared to a regular declaration, which creates obvious
problems.
> My point is - when you have a lot repetitive text pieces in
> your code, it is much better in longer scope to use advanced
> language tools instead of advanced editing tools.
Only if the increase in ugliness is worth the ease of editing.
> And this is one place where D is so superior do C++.
Sure, but that's an unrelated discussion.
> I must admit I'd prefer to have template mixins allowed for
> statements to minimize string mixin usage but it is still much
> much better than copy-paste in my opinion.
The problem with the idea of a mixin is that it's just ___too
much abstraction___.
It's almost like making a FactoryFactorFactory in Java, except
now you have a MyClassOperatorMixinTemplate or something like
that.
I don't know about you, but I just don't believe in abstracting
away every single character I type.
More information about the Digitalmars-d
mailing list