http://d.puremagic.com/issues/show_bug.cgi?id=11070
--- Comment #5 from [email protected] 2013-09-20 00:53:31 PDT --- (In reply to comment #3) > Well, not just auto, you just want to be able to make a declaration inside the > switch expression. This would also apply to a while statement too. > > In C++, this is legal: > > //---- > while (int i = 1) > {} > > switch (int i = 1) > {} > //---- > > This is a very reduced use case, but I've seen cases where it is useful. > > The D grammar does not allow it though. I don't see why not though. To answer my own self: > while (int i = 1) > {} This would probably be illegal in D anyways, since we aren't allowed assignments in if/for/while. Arguably, it's not an "assignment" but a "declaration", so it shouldn't be a problem either. Still, it's a thin line, and I have (albeit very rarely) also made that "typo", when copy pasting code. > switch (int i = 1) > {} Switch is special, because it doesn't actually test the args, so I see better chances of this being made legal. IMO, while the use cases arn't very important, not supporting this for switch would just be a gratuitous deviation from C++ (IMO). Then again, C doesn't support it either (afaik), so... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
