On 2/21/12 10:39 AM, foobar wrote:
Regarding the downcast - you still perform a check in the code above! You gained nothing by replacing a type check with a check on a hash.
You do gain because capability checks don't force a tree structure, whereas downcasting does.
Regarding composition of several traits - even that simple snippet is enough: throw new WithRainbows!withErrorCode!withFoobar!FileNotFoundException(...); That's without further design which could probably improve this further.
To quote a classic:
It's clear that you are trying to generify exceptions. This contradicts the very notion of what exceptions are. You also seem to try to optimize the amount of exception classes. Making user code convoluted for the sake of some premature optimization which most likely has negligible affect is completely unacceptable. I get that you are a templates master, that does *NOT* mean everything must be made generic. You seem to prove the old saying that when all you have is a hammer everything looks like a nail.
It's gotta be one or the other. Andrei