Clay language
Michel Fortin
michel.fortin at michelf.com
Thu Dec 30 07:22:22 PST 2010
On 2010-12-30 10:00:05 -0500, "Steven Schveighoffer"
<schveiguy at yahoo.com> said:
> The thing I find ironic is that with the original operator overloading
> scheme, the issue was that for types that define multiple operator
> overloads in a similar fashion, forcing you to repeat boilerplate code.
> The solution to it was a mixin similar to what you are suggesting.
> Except now, even mundane and common operator overloads require verbose
> template definitions (possibly with mixins), and it's the uncommon
> case that benefits. So really, we haven't made any progress (mixins
> are still required, except now they will be more common). I think
> this is one area where D has gotten decidedly worse. I mean, just
> look at the difference above between defining the opcat operator in D1
> and your mixin solution!
I'm with you, I preferred the old design.
> As a compromise, can we work on a way to forward covariance, or to have
> the compiler reevaluate the template in more derived types?
I stubbled upon this yesterday:
Template This Parameters
TemplateThisParameters are used in member function templates to pick
up the type of the this reference.
import std.stdio;
struct S
{
const void foo(this T)(int i)
{
writeln(typeid(T));
}
}
<http://www.digitalmars.com/d/2.0/template.html>
Looks like you could return the type of this this way...
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list