DIP10005: Dependency-Carrying Declarations is now available for community feedback

Meta via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 31 08:40:10 PST 2016


On Saturday, 31 December 2016 at 15:05:00 UTC, Adam D. Ruppe 
wrote:
> Consider the following:
>
> with (import std.stdio) void process(File input) ;
>
> Let's rewrite that to be:
>
> template process() {
>    import std.stdio;
>    void process(File input) {
>
>    }
> }

I absolutely hate making functions templated if they don't have 
to be. It breaks a whole bunch of things and is not at all 
transparent to the user. You can't take its address, pass it as a 
delegate/function pointer, use certain traits to introspect it 
(e.g. isSomeFunction, ReturnType, etc.), not to mention how 
templates really don't work well with inheritance. This all goes 
out the window when you turn a regular function into a template.


More information about the Digitalmars-d mailing list