The daily D riddle - this parameter

Nick Treleaven nick at geany.org
Thu Feb 1 13:12:21 UTC 2018


On Sunday, 28 January 2018 at 06:44:28 UTC, Timothee Cour wrote:
> likewise the following compiles, but IMO should not:
> class A{ void fun(this a){}}
> (instead we should have typeof(this)

Yes, it's also confusing reading it, I thought it was template 
this for a second. It even works if fun is static! This is ironic 
as template this doesn't work outside of methods, even though it 
should:
https://issues.dlang.org/show_bug.cgi?id=17713

In fact, template this syntax is backward:

void fun(this T)(){} // current
void fun(T this)(){} // could work?

The latter actually has the type and variable in the correct 
position. (Not that I expect it will change now).


More information about the Digitalmars-d mailing list