I see no reason why the compiler should be reordering anything here. That changes the semantics of the code. It's not like it's a great burden on the programmer to just reorder the blocks so that they're in the correct order. Having the compiler give a warning or error would be plenty, and a lot better than letting the programmer continue to screw up their code in ignorance. If they don't understand how the catch blocks work, they're likely to screw up more than just the order.

I do think that having the compiler complain when one catch block hides another makes a lot of sense, but I think that that's as far as it should go. It's the programmer's job to fix their code, not the compiler's.

You are right.. I just have wishful thinking of the compiler being smart enough to auto-fix some things, but when you start making assumptions then errors and problems tend to arise more. That and if the compiler DOES reorder those blocks, then you re-ordering them for a specific reason may not work and could have unintended results. Course I don't see how with Try/catch since only one block (plus finally) can be used at a time.

Reply via email to