Re: Default Template Instantiation

2018-05-17 Thread Stefan Koch via Digitalmars-d
On Thursday, 17 May 2018 at 08:37:01 UTC, Heromyth wrote: On Monday, 19 September 2016 at 22:59:53 UTC, Jonathan Marler wrote: On Monday, 19 September 2016 at 22:17:34 UTC, Mathias Lang wrote: [...] Good example, thanks for the information. Maybe the compiler can do more works to make the

Re: Default Template Instantiation

2018-05-17 Thread Heromyth via Digitalmars-d
On Monday, 19 September 2016 at 22:59:53 UTC, Jonathan Marler wrote: On Monday, 19 September 2016 at 22:17:34 UTC, Mathias Lang wrote: 2016-09-19 23:18 GMT+02:00 Jonathan Marler via Digitalmars-d < digitalmars-d@puremagic.com>: [...] No you can't. The example is wrong, but Stefan is right.

Re: Default Template Instantiation

2016-09-19 Thread Jonathan Marler via Digitalmars-d
On Monday, 19 September 2016 at 22:17:34 UTC, Mathias Lang wrote: 2016-09-19 23:18 GMT+02:00 Jonathan Marler via Digitalmars-d < digitalmars-d@puremagic.com>: [...] No you can't. The example is wrong, but Stefan is right. Consider: ``` template Foo (T = string) { } template

Re: Default Template Instantiation

2016-09-19 Thread Stefan Koch via Digitalmars-d
On Monday, 19 September 2016 at 22:17:34 UTC, Mathias Lang wrote: No you can't. The example is wrong, but Stefan is right. Try it. It got fixed a few versions ago. Maybe it's broken again ? I remember it working with 2.068

Re: Default Template Instantiation

2016-09-19 Thread Mathias Lang via Digitalmars-d
2016-09-19 23:18 GMT+02:00 Jonathan Marler via Digitalmars-d < digitalmars-d@puremagic.com>: > On Monday, 19 September 2016 at 21:14:38 UTC, Stefan Koch wrote: > >> On Monday, 19 September 2016 at 21:09:37 UTC, Jonathan Marler wrote: >> >>> >>> I don't know if I would call this a "destabalizing"

Re: Default Template Instantiation

2016-09-19 Thread Jonathan Marler via Digitalmars-d
On Monday, 19 September 2016 at 21:14:38 UTC, Stefan Koch wrote: On Monday, 19 September 2016 at 21:09:37 UTC, Jonathan Marler wrote: 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

Re: Default Template Instantiation

2016-09-19 Thread Stefan Koch via Digitalmars-d
On Monday, 19 September 2016 at 21:09:37 UTC, Jonathan Marler wrote: 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

Re: Default Template Instantiation

2016-09-19 Thread Jonathan Marler via Digitalmars-d
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

Re: Default Template Instantiation

2016-09-19 Thread Stefan Koch via Digitalmars-d
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

Re: Default Template Instantiation

2016-09-19 Thread Jonathan Marler via Digitalmars-d
On Monday, 19 September 2016 at 19:53:27 UTC, Basile B. wrote: On Monday, 19 September 2016 at 19:38:37 UTC, Jonathan Marler wrote: If you have a template where: 1) All parameters are optional 2) The parameters cannot be deduced Would it be reasonable to instantiate the template with the

Re: Default Template Instantiation

2016-09-19 Thread Basile B. via Digitalmars-d
On Monday, 19 September 2016 at 19:38:37 UTC, Jonathan Marler wrote: If you have a template where: 1) All parameters are optional 2) The parameters cannot be deduced Would it be reasonable to instantiate the template with the default parameter values? For example: template Foo(string str =