New syntax proposal for template type parameter contraints

w0rp via Digitalmars-d digitalmars-d at puremagic.com
Wed May 21 23:52:32 PDT 2014


On Friday, 16 May 2014 at 23:14:13 UTC, Idan Arye wrote:
> On Friday, 16 May 2014 at 20:31:40 UTC, Phil Lavoie wrote:
>> void myTemplateFunction( InputRange!int r ) {
>>  foreach( elt; r ) { ... }
>> }
>>
>> What do you think? Does this feel right to you?
>>
>> Phil
>
> The main problem is that `myTemplateFunction`'s signature makes 
> it look like it's a concrete function, when in fact it's a 
> template. Another problem is that we now have to have an 
> argument if we want to pass a template parameter, which is a 
> serious limitation.

I have though about this kind of problem before when I was 
thinking of similar syntax. My solution was to require empty 
template parameters at least.

void foo()(InputRange r);

In my proposed syntax however, InputRange was not a type.


More information about the Digitalmars-d mailing list