Default Template Instantiation

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 19 14:09:37 PDT 2016


On Monday, 19 September 2016 at 20:47:00 UTC, Stefan Koch wrote:
> On Monday, 19 September 2016 at 20:21:30 UTC, Jonathan Marler 
> wrote:
>>
>> Yes that's why the template cannot deduce the parameters. The 
>> question is, when the parameters cannot be deduced, and they 
>> are all optional, would it be reasonable for the compiler to 
>> infer that the user intended to use the default parameters?
>
> This would be a destabilizing language-change and require even 
> more logic for templates.
>

That's what I was wondering.  I was trying to think of examples 
that this kind of feature would over-complicate.  I've been 
thinking about it the last few days and I have the same 
reservations about making template deduction more complicated 
than it already is.  That being said, I have thought of some 
examples that this feature would make much nicer.

I don't know if I would call this a "destabalizing" language 
change though.  It should be backwards compatible with the 
existing semantics.  It adds an extra step to type deduction, but 
this would be the very last step of type deduction so it would 
not override any existing semantics.


More information about the Digitalmars-d mailing list