July 20, 2013 Re: DIP42 - Add enum E(T) = expression; eponymous template support | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manu | On Wednesday, 26 June 2013 at 00:47:53 UTC, Manu wrote:
> This raises the parallel question of:
> alias A(T) = expression;
>
> Which I think is equally common as the enum case described here?
>
Common or not, I'd expect consistency.
|
July 21, 2013 Re: DIP42 - Add enum E(T) = expression; eponymous template support | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 25 June 2013 at 21:31:15 UTC, Walter Bright wrote:
> http://wiki.dlang.org/DIP42
Reading through this thread, I already foresee a messy specification coming along for this. Instead, I'd propose something different that would keep the rules consistent yet have many more applications:
template(...) declaration = ... ;
So what you would have instead:
template(T) enum E = ... ;
template(T) alias A = ... ;
There's also the possibility for simple template constraints as well:
template(T) if(...) enum E = ... ;
Anything more complicated, such as static if, is probably best left to the classic style:
template E(T)
{
static if(...) enum E = ... ;
else enum E = ... ;
}
|
July 22, 2013 Re: DIP42 - Add enum E(T) = expression; eponymous template support | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 06/26/2013 12:15 AM, bearophile wrote: > But it's not immediate to assign a generic lambda: > > alias sum = (x, y) => x + y; > > Bye, > bearophile http://d.puremagic.com/issues/show_bug.cgi?id=9426 |
Copyright © 1999-2021 by the D Language Foundation