Variadic grouping

JS js.mdnq at gmail.com
Mon Jul 29 10:22:49 PDT 2013


On Monday, 29 July 2013 at 16:52:17 UTC, Meta wrote:
> On Monday, 29 July 2013 at 16:02:02 UTC, monarch_dodra wrote:
>> Except for this...
>> alias K = Select!(true, 4, int);
>>
>> ;)
>>
>> Useful? I don't think so... but I thought I'd point it out ^^
>
> I think it's a feature that this doesn't work. As for variadic 
> grouping, named parameters could easily solve this problem, and 
> have applications for other situations beside variadic 
> arguments.

I'm not sure how named parameters would solve the original 
problem but using a syntax like what I'm suggesting one can do 
stuff like

template Log(alias cond, args...; string file = __FILE__, string 
mod = __MODULE__)
{

}

which could be called without explicitly having to supply 
__FILE__ and __MODULE__, currently you can't write such a CT 
logging feature with variadic parameters.

(although another solution would to have __PREVIOUS_FILE__, 
__PREVIOUS_MODULE__, etc... that would return the file, module, 
line number, etc.. of what called the template or function)

I think using the ';' notation is very concise and natural... 
just that forgetting to use it could be very problematic.



More information about the Digitalmars-d mailing list