Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Don Clugston via Digitalmars-d
On Friday, 29 September 2017 at 10:32:02 UTC, Timon Gehr wrote: On 29.09.2017 11:12, Don Clugston wrote: Guess what this prints import std.stdio; void main() {   int i = 0;   switch (i) for (i = 8; i < 10; ++i)   {     case 7:     writeln(i);     return;     default: ;  

D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Don Clugston via Digitalmars-d
Guess what this prints import std.stdio; void main() { int i = 0; switch (i) for (i = 8; i < 10; ++i) { case 7: writeln(i); return; default: ; } } Why does this even compile? It's because the grammar is: SwitchStatement: switch ( Expression ) Sc

Re: Exception chaining and collectException

2017-08-18 Thread Don Clugston via Digitalmars-d
On Friday, 18 August 2017 at 03:31:38 UTC, Walter Bright wrote: Chained exceptions are a good idea, but are more or less a disaster: 1. No other language does chained exceptions 2. Attempting to hammer D chained exceptions into other language schemes (such as C++) makes for lots of unfun hour