surrounded type modifier

Maxim Fomin maxim at maxim-fomin.ru
Wed Sep 18 07:17:02 PDT 2013


On Wednesday, 18 September 2013 at 13:23:10 UTC, Namespace wrote:
> Code:
> ----
> const { /// [1]
> 	int a = 3;
> }
>
> void main()
> {
> 	const { /// [2]
> 		int b = 4;
> 	}
> }
> ----
>
> Why is [1] allowed, but not [2]?

Citing grammar:

FunctionBody:
     BlockStatement
     BodyStatement
     InStatement BodyStatement
     OutStatement BodyStatement
     InStatement OutStatement BodyStatement
     OutStatement InStatement BodyStatement

BlockStatement:
     { }
     { StatementList }

As you can see there is no room for attributes. Why dmd does not 
support attributes here is separate question - probably because 
such construct would be confused with lambda, but this is not a 
serious reason.


More information about the Digitalmars-d-learn mailing list