On Thu, 29 May 2014 15:29:31 -0400, Walter Bright <newshou...@digitalmars.com> wrote:

On 5/29/2014 11:11 AM, Dmitry Olshansky wrote:
Static if is certainly NOT an attribute, it doesn't make any sense.


Yes, it does make sense. It was not an accident that the frontend treats it as it does, the code to do it was deliberately put there.

The attributes are all designed to affect a block of code - so are version/debug/staticif - why should they be different?

private int x; // ok
static if(1) int x; // ok

private x = 5; // error
static if(1) x = 5; // ok

Static if/version/debug can affect both statements and declarations. attributes only apply to declarations. That is the major difference I see between them.

Not arguing that it's bad for the syntax to exist, I think it kind of makes sense given that static if does not create a new scope. But they don't behave like normal attributes.

-Steve

Reply via email to