Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 13, 2013 Aliasing lambdas | ||||
---|---|---|---|---|
| ||||
Is there any reason why this isn't allowed: alias f = (x => x); but this is: template A(alias B) { alias A = B; } alias f = A!(x => x); ??? |
January 13, 2013 Re: Aliasing lambdas | ||||
---|---|---|---|---|
| ||||
Posted in reply to Peter Alexander | On 01/13/2013 08:55 PM, Peter Alexander wrote:
> Is there any reason why this isn't allowed:
>
> alias f = (x => x);
>
> but this is:
>
> template A(alias B) { alias A = B; }
> alias f = A!(x => x);
>
> ???
No. It is a gratuitous grammar limitation.
|
January 13, 2013 Re: Aliasing lambdas | ||||
---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Sun, Jan 13, 2013 at 9:07 PM, Timon Gehr <timon.gehr@gmx.ch> wrote:
> On 01/13/2013 08:55 PM, Peter Alexander wrote:
>>
>> Is there any reason why this isn't allowed:
>>
>> alias f = (x => x);
>>
>> but this is:
>>
>> template A(alias B) { alias A = B; }
>> alias f = A!(x => x);
>>
>> ???
>
>
> No. It is a gratuitous grammar limitation.
The same limitation forbids:
alias __traits(whatever, ...) result;
The grammar says:
AliasDeclaration:
alias BasicType Declarator
(and others, but this is the one limiting you). BasicType should be replaced by PrimaryExrpession, or something like that.
|
January 13, 2013 Re: Aliasing lambdas | ||||
---|---|---|---|---|
| ||||
Posted in reply to Philippe Sigaud | On 01/13/2013 09:38 PM, Philippe Sigaud wrote:
> On Sun, Jan 13, 2013 at 9:07 PM, Timon Gehr <timon.gehr@gmx.ch> wrote:
>> On 01/13/2013 08:55 PM, Peter Alexander wrote:
>>>
>>> Is there any reason why this isn't allowed:
>>>
>>> alias f = (x => x);
>>>
>>> but this is:
>>>
>>> template A(alias B) { alias A = B; }
>>> alias f = A!(x => x);
>>>
>>> ???
>>
>>
>> No. It is a gratuitous grammar limitation.
>
> The same limitation forbids:
>
> alias __traits(whatever, ...) result;
>
> The grammar says:
>
> AliasDeclaration:
> alias BasicType Declarator
>
> (and others, but this is the one limiting you). BasicType should be
> replaced by PrimaryExrpession, or something like that.
>
I think it should be roughly:
alias TemplateArgument Identifier;
alias Identifier=TemplateArgument;
Note: The current grammar allows
alias int x = 2;
Which does not make any sense.
|
Copyright © 1999-2021 by the D Language Foundation