On Thursday, 6 July 2017 at 14:59:10 UTC, Crayo List wrote:
On Wednesday, 5 July 2017 at 21:05:04 UTC, Ola Fosheim Grøstad wrote:
On Wednesday, 5 July 2017 at 15:48:33 UTC, Crayo List wrote:
What happens to the 3000 direct and indirect calls to open() ?

Notice how the 'interface' has not changed, only the implementation.

No, the exception spec is part of the interface whether it is in the function declaration or not.

I disagree!
Once an interface is defined you should be able to alter the implementation all you want without impacting client code!

Correct. And throwing a different kind of exception changes the interface, and *does* impact client code. Consider:

void fun() {
    try {
        gun();
    } catch (GoodException goodEx) {
        // Ignore
    } catch (Exception badEx) {
        FireZeeMissiles();
    }
}

void gun() {
    throw new GoodException ();
}

Now J. Random Programmer decides to change gun()'s implementation:

void gun() {
    throw new BadException();
}

If your assertion that this doesn't change the interface and doesn't impact the client is correct, no missiles will be fired. Sadly, this is not the case, and Switzerland is now wiped off the map.

--
  Biotronic

Reply via email to