Short list with things to finish for D2
Leandro Lucarella
llucax at gmail.com
Thu Nov 19 17:17:15 PST 2009
Bill Baxter, el 19 de noviembre a las 14:16 me escribiste:
> > What I found hackish about it is that the code is a string manipulation
> > mess. You can already do a string manipulation mess to programatically
> > implement all the operator overloading.
>
> This is true, but if you leave it entirely up to the programmer and
> string mixins, the mess is much more messy.
> You're going to end up with code like this:
>
> mixin(genBinaryOp("+", q{MyType}, q{MyType rhs}, q{
> return this.impl + rhs.impl;
> }));
>
>
> instead of this:
> MyType opBinary(string op : "+")(MyType rhs) {
> return this.impl + rhs.impl;
> }
>
> I would have a hard time defending the former as the recommended D style.
> But the latter is not so bad. It looks like a regular template
> declaration, and code is code, not a string.
But in this case you gained nothing comparing to opAdd(), where opBinary()
is useful is where you use string mixins to avoid implementing the
operators one by one.
I know the opBinary() approach is less ugly than writing the code youself,
but a library solution could be provided in the meantime (in the
unexistent std.mixin module; which BTW, can't be named that way because
"mixin" is a keyword ;).
--
Leandro Lucarella (AKA luca) http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
When I was a child
I caught a fleeting glimpse
Out of the corner of my eye.
I turned to look but it was gone
I cannot put my finger on it now
The child is grown,
The dream is gone.
I have become comfortably numb.
More information about the Digitalmars-d
mailing list