Alternative template instantiation syntax

Timon Gehr timon.gehr at gmx.ch
Fri Jan 27 14:51:09 PST 2012


On 01/27/2012 11:29 PM, F i L wrote:
> On Friday, 27 January 2012 at 22:20:47 UTC, a wrote:
>> On Friday, 27 January 2012 at 22:02:55 UTC, F i L wrote:
>>> Timon Gehr wrote:
>>>> alias MyFoo = Foo!q{
>>>>
>>>> }
>>>
>>> This syntax makes a lot of sense, but why have the '=' at all? Why
>>> not just:
>>>
>>> alias Num float;
>>> alias MyFoo Foo!q{
>>>
>>> };

Because then we have

alias symbol1 symbol2; which means symbol2 is an alias for symbol1 and
alias symbol1 symbol2!(...) which means symbol1 is an alias for 
symbol2!(...). It does not seem right.

>>
>> I guess one reason is that it fits better with the rest of the
>> language, it feels more natural. Also, wouldn't your proposal require
>> making the current syntax illegal and breaking pretty much all of
>> existing D code?
>
> Every proposal here would break D, so I'm not sure what you mean by "my"
> proposal. Also, because aliases are non-lvalue definitions, I don't
> think '=' makes a lot of sense, but I'm not an expert on the matter.
>

No, they are all additive and backwards-compatible changes. (the old 
syntax would persist as an alternative) And in D the lhs of a = 
initializer is not required to be an lvalue anyway: enum x = 1;


More information about the Digitalmars-d mailing list