Extending UFCS to work with templates.
DigitalDesigns
DigitalDesigns at gmail.com
Sun Jun 10 04:58:18 UTC 2018
The idea is that one can use UFCS with templates and types if the
first type matches:
void foo(string T)(int x);
"test".foo(4); <==> foo!("test")(4)
class X;
void foo(T : X)(int x);
X.foo(4) <=> foo!X(4)
This would be unambiguous(since types are not variables in D).
This allows one to define generic functions on a whole class of
types:
T New(T, Args...)(Args a)
{
return new T(a);
}
which then is a useful idiom because it provides a nice wrapper
for new. We could then use New in place of new in our design and
then track allocations easier, convert seamlessly between gc and
nogc allocated variables, etc.
More information about the Digitalmars-d
mailing list