alias parameters and basic types

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 30 13:35:54 PDT 2016


On 07/30/2016 09:21 PM, Jonathan M Davis via Digitalmars-d wrote:
> I think that Walter's answer in those bug reports is pretty clear. An alias
> parameter aliases a symbol. Basic types are keywords, not symbols, so they
> can't be passed as an argument to an alias parameter.

As far as I see, he just says that it works as intended. But he doesn't 
give a rationale as for why it's intended to work like that. What's 
gained by rejecting basic types in alias parameters? It's surprising 
behavior for seemingly no good reason.

> And I confess that I don't know why you'd even want to.

Phobos could make good use of it. For example, many isFoo template in 
std.traits would become a bit nicer. This kind of workaround is all over 
the place:

     template isCallable(T...) if (T.length == 1)
     {
         /* use T[0] */
     }

With a "fixed" alias parameter, that would be:

     template isCallable(alias T)
     {
         /* use T */
     }


More information about the Digitalmars-d mailing list