News for hackers. Stuff that matters.
Re:Why Checked Exceptions Failed by breadwinner on Saturday July 15, 2023 @06:19PM (#36741457)
It is dangerous to call a method on an object whose type is not being checked by the compiler. Whether that's a ridiculous thing to worry about depends on how important your program is. If your work for NASA and your code will run inside the Mars rover, it is not ridiculous to worry about such things, but if you're writing some code that will be used once and thrown away then yeah, it might be ridiculous.
Re:Why Checked Exceptions Failed by somehnguy on Saturday July 15, 2023 @07:16PM (#36741800)
It is being checked by the compiler though. For your example to work both would need to extend a common object (unless the only thing you ever do to that object is call fire(), which is nonsensical) or you would get a compile time error right off the bat.

It's a ridiculous thing to worry about in either of your cases. That incredibly specific situation simply isn't ever going to happen in practice because so many other conditions need to be met for the compiler to let you proceed.

Re:Why Checked Exceptions Failed by breadwinner on Saturday July 15, 2023 @08:40PM (#36742293)
> For your example to work both would need to extend a common object

Not necessarily at all.

> unless the only thing you ever do to that object is call fire(), which is nonsensical

You can be calling other methods on the object in other places, but in one particular block of code you may be only calling fire(). And in that block of code, all the compiler cares is that the type has a fire() method. Thus the compiler is not doing a full check.

> It's a ridiculous thing to worry about in either of your cases.

Not at all... if your program is running inside a NASA rover, or if your program is running inside a robotic surgery machine you have to worry about safety and you want to maximize compile-time checks.