Template Usage with Eponymous Trick

ShadoLight ettienne.gilbert at gmail.com
Thu Jan 30 17:00:08 UTC 2020


On Thursday, 30 January 2020 at 16:16:48 UTC, MoonlightSentinel 
wrote:
> On Thursday, 30 January 2020 at 15:14:43 UTC, ShadoLight wrote:

[...]
>
> From my POV is
>
> void foo(T)() { ... }
>
> just a shorthand notation for...
>

Agreed. My question though is should the 'shorthand' notation 
_replace_ the 'longhand' notation, or be available _in addition_ 
to the 'longhand' notation in the eponymous case (so the 
eponymous notation is just 'syntax sugar' if you will).

If you had...

template foo(T) {
    bar(){..}
}

...you have no choice but to use foo!(int).bar()- (where T is 
'int'). So, I'm asking, in the eponymous case, should...

template foo(T) {
    foo(){..}
}

force you to use foo!(int)() instead (as is currently the case), 
or should foo!(int).foo() also still be acceptable/available?

For consistency's sake I think it should be but, if there is some 
reason why this is not technically possible/advisable, I was 
hoping someone would enlighten me.

And, in that case some of the examples in the documentation needs 
fixing.



More information about the Digitalmars-d-learn mailing list