Parameter-less templates?

monarch_dodra monarchdodra at gmail.com
Tue Aug 13 02:41:43 PDT 2013


On Tuesday, 13 August 2013 at 01:08:01 UTC, deadalnix wrote:
> On Monday, 12 August 2013 at 19:03:41 UTC, monarch_dodra wrote:
>> D has introduced a pretty cool tool: templates. These are 
>> basically namespaces that can be instantiated by a type/alias. 
>> Mixing with them the notion of "eponymous" allows to do some 
>> seriously cool things with them.
>>
>> One of the things I find strange though is that they *must* be 
>> parameterized.
>
> Yes and no.
>
> void foo()() {} is a parameter-less template.
>
> As the construct already exists at semantic level, I guess 
> making it available everywhere is the way to go.

I think strictly speaking, that is a "parameterless parameterized 
function", as opposed to a "non parameterized function".

In regards to template (I mean the actual "template"), I guess I 
wish we could either:
1. Allow non-parameterized templates (eg template foo {...})
2. Allow invoking a template without parameters (provided the 
template has 0 parameters, or default parameters), without doing 
"!()"

But yeah, I think I agree with you, that it should be made 
available everywhere.


More information about the Digitalmars-d mailing list