A
Arne Vajhøj
Tomas said:And this is the case I want the program to crash. It is reading the
configuration during initialization and the configuration contains
invalid value. I get an error, fix the configuration and run again.
But you do not get the exception you should.
You get an assertion error.
And if you don't want your program to crash in this situation, noone
forces you to use this construct.
No. But little point in adding features to the language that
are not really needed just because people do not need to use
them.
No, not the same benefits. It has its own benefits.
Let me rephrase: it does not carry benefits in the same order
of magnitude as exceptions and checked exceptions.
But the talk here
is about misuse, not benefits. And misused @Safe would usually do less
damage than misused try-catch.
You have to compare benefits with with drawbacks.
I can't object, but compare it to construct that it is meant to
replace, i.e.
try {
safe_statement;
} catch(EXCEPTION e) {
throw new AssertionError(e); // or throw new RuntimeException(e);
}
How is misuse of @Safe more difficult to find than the misuse of this?
It is more difficult to spot.
And besides the construct itself is not very good in the first place.
Arne