mixin alias

0ffh frank at frankhirsch.youknow.what.todo.net
Sun Dec 16 18:42:38 PST 2007


Derek Parnell wrote:
> On Sun, 16 Dec 2007 15:51:38 -0500, Jarrett Billingsley wrote:
>> This is correct.  You can only alias things that have names; the number 3 
>> does not have a name.
> 
> I know that is 'correct', but I was really asking what is the rationale
> behind such an apparently arbitrary design decision.

First I thought:
"Well, for one we'd have to disallow assignment expressions using the
aliased parameter (as well as pre/post-inc/decrement), which is bad
for the goal of context insensitive scanning."

But that's not it... same would go for "template Foo(int b)" where the
error is caught later. Therefore I can only conjecture that it would
add some complication to make some constant variable magically spring
to life in order to replace the literal in the template code, and
nobody has yet bothered Walter enough to do it.

>> Why does Foo!(y) match Foo(int)?

JB: As y is declared as an int, I don't see why not... otherwise the
template would only react to int literals but not int veriables, no?
But I don't use templating that much, and so may overlook something.

regards, frank


More information about the Digitalmars-d-learn mailing list