DIP69 - Implement scope for escape proof references

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 20 18:30:06 PST 2014


On 12/6/14 4:49 PM, Manu via Digitalmars-d wrote:
> In the situation where templates are involved, it would be nice to be
> able to make that explicit statement that some type is ref or not at
> the point of template instantiation, and the resolution should work
> according to the well-defined rules that we are all familiar with.

Another drive-by comment: I understand the motivation for this and the 
difficulties involved. There needs to be a clear understanding that 
adding new type qualifiers is extremely intrusive and expensive. Because 
of that, I think we should best address binding generation via a set of 
tactical tools i.e. standard library artifacts that do all that mixin 
business in an encapsulated and reusable manner.

(As an aside forcing a template instantiation to decide ref vs. no ref 
should be easy but currently can't be done, i.e. this code should work 
but currently doesn't:

T fun(T)(ref T x) { return x + 1; }

void main(string[] group)
{
     int function(int) f1 = &fun!int;
     int function(ref int) f2 = &fun!int;
}

)


Andrei



More information about the Digitalmars-d mailing list