surrounded type modifier

Namespace rswhite4 at googlemail.com
Wed Sep 18 06:46:27 PDT 2013


On Wednesday, 18 September 2013 at 13:42:37 UTC, bearophile wrote:
> Namespace:
>
>> Code:
>> ----
>> const { /// [1]
>> 	int a = 3;
>> }
>>
>> void main()
>> {
>> 	const { /// [2]
>> 		int b = 4;
>> 	}
>> }
>> ----
>>
>> Why is [1] allowed, but not [2]?
>
> Think about what this does:
>
> void main() {
>     {
>         int b = 4;
>     }
> }
>
>
> It creates a new scope inside the function. How do you tell 
> apart the syntax to create a new scope from having a "group 
> tagging" as in the global case?
>
> Bye,
> bearophile

If a type modifier is in front of '{' it's a group tagging, 
otherwise a scope.


More information about the Digitalmars-d-learn mailing list