Workaround for DIP 1005
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 7 10:29:02 PST 2017
On Tue, 07 Feb 2017 15:00:17 +0000, Andrea Fontana wrote:
> I don't understand why we can't use a template like:
You can. However, that makes things awkward when you want to pass that as
a delegate. It makes it awkward to read. You don't get to specify the
return type unless it happens to be the same as a parameter type.
A near equivalent is:
template extractDate()
{
import std.datetime;
Date extractDate(SysTime time)
{
return time.date;
}
}
Better type checking, but you need to refer to it as `extractDate!()`
sometimes. That's still better than having to refer to it as `extractDate!
(SysTime)`.
More information about the Digitalmars-d
mailing list