digitalmars.D.learn - surrounded type modifier
- Namespace (13/13) Sep 18 2013 Code:
- bearophile (12/25) Sep 18 2013 Think about what this does:
- Namespace (3/30) Sep 18 2013 If a type modifier is in front of '{' it's a group tagging,
- Namespace (7/7) Sep 18 2013 Same thing with debug:
- Maxim Fomin (16/29) Sep 18 2013 Citing grammar:
- Namespace (3/35) Sep 18 2013 Should I open an enhancement report?
- Maxim Fomin (2/3) Sep 18 2013 Of course you are always free to open enhancement reports.
Code: ---- const { /// [1] int a = 3; } void main() { const { /// [2] int b = 4; } } ---- Why is [1] allowed, but not [2]?
Sep 18 2013
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
Sep 18 2013
On Wednesday, 18 September 2013 at 13:42:37 UTC, bearophile wrote:Namespace:If a type modifier is in front of '{' it's a group tagging, otherwise a scope.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
Sep 18 2013
Same thing with debug: { // scope code } debug { // debug code }
Sep 18 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.
Sep 18 2013
On Wednesday, 18 September 2013 at 14:17:04 UTC, Maxim Fomin wrote:On Wednesday, 18 September 2013 at 13:23:10 UTC, Namespace wrote:Should I open an enhancement report?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.
Sep 18 2013
On Wednesday, 18 September 2013 at 14:23:25 UTC, Namespace wrote:Should I open an enhancement report?Of course you are always free to open enhancement reports.
Sep 18 2013