Conclusions of the exception discussion

kennytm kennytm at gmail.com
Sat Feb 25 12:46:23 PST 2012


"Daniel Murphy" <yebblies at nospamgmail.com> wrote:
> "deadalnix" <deadalnix at gmail.com> wrote in message 
> news:jiagbg$liu$1 at digitalmars.com...
>> Le 25/02/2012 07:26, Daniel Murphy a Ècrit :
>>> https://github.com/D-Programming-Language/dmd/pull/738
>> 
>> I do think this approach have a flaw. If we go in that direction, then it 
>> push devs to create new Exception type just to catch them, because this is 
>> the only way we have.
>> 
> 
> This is a different issue to whether or not we have the syntax to catch 
> multiple exceptions with a single catch block.
> 
>> If I understand properly your pull request, the compiler will be 
>> duplicating catch block ? If it is the case, would it be possible to use 
>> static if to use type specific stuff of E1, E2 or E3, depending on which 
>> one we are facing ?
>> 
> 
> No, it just creates stub catch blocks that jump to the real one. 
> Duplicating the blocks would have weird effects on things like static 
> variables.  I think that kind of code duplication is better done with 
> something that works like mixing in case statements.
> 
> catch(auto e : E1, E2) { body; }
> ->
> 
> catch(E1 e)
> {
>   goto catchE2;
> }
> catch(E2 e)
> {
> catchE2:
>   body;
> }

Won't work unless the compiler enforce that 'body' does not use code which
requires typeof(e) == E2.


More information about the Digitalmars-d mailing list