static if enhancement

Uranuz via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 24 23:38:58 PDT 2016


On Friday, 24 June 2016 at 15:24:48 UTC, Andrei Alexandrescu 
wrote:
> Does anyone else find this annoying? 
> https://issues.dlang.org/show_bug.cgi?id=16201 -- Andrei

What I think about enchancement of static if is that it could be 
interesting to have `elif` keyword like in Python, so instead of
static if (...)
{

}
else static if(...)
{

}
else static if(...)
{

}
else
{

}

I could write shorter:

static if (...)
{

}
elif (...)
{

}
elif(...)
{

}
else
{

}

In other hand it maybe not got idea to have multiple syntax just 
for the same think. But we already have multiple syntax for 
template constraints
template AA (T: int) {}
or
template AA(T) if ( is( T: int ) ) {}

And also shorthand for template using *alias* was added recently:

alias AA(T) = ...

So my idea could survive too.. :) Bad thing here is adding the 
new keyword, but I don't think that people using word `elif` for 
names of their variables or functions, if they don't write Python 
parser of course :)



More information about the Digitalmars-d mailing list