On Friday, October 26, 2012 21:37:00 Justin Whear wrote: > My understanding is that scope(failure) simply lowers to the catch block > of a try..catch, so there's no implementation obstacle to making the > exception available. Are there known syntax or correctness obstacles to > allowing something like this: > > scope(failure)(Exception ex) writeln(ex.msg);
Yes. It lowers to a try-catch block, but that's effectively an implementation detail. As it stands, technically speaking, a compiler could probably implement it without any lowering whatsoever (I don't think that the spec says anything about how it's implemented). But even if the compiler has to use lowering, the main problem with your suggestion is that in complicates how scope statements work, since then it's only going to be run if the exception type being caught matches what was being thrown, whereas right now scope(failure) statements run on all exceptions regardless. And scope statements aren't really meant for exception handling. Rather, they're intended for providing a clean means of making code exception-safe. So, I suspect that what you suggest would be rejected, but I don't know. You can certainly create an enhancement request for it if you want to: http://d.puremagic.com/issues - Jonathan M Davis
