[bind10-dev] data classes
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Mon Oct 26 06:45:02 UTC 2009
At Sun, 25 Oct 2009 21:34:59 -0700,
Jelte Jansen <jelte at isc.org> wrote:
> > Or is your main concern with this approach that you need to list all
> > type-specific getter methods in the base class?
> >
>
> well the latter is still the case if we overload it ;)
Ah, true...I should have asked whether it's that you need to use
different method names for different concrete types (instead of the
same single function name with different signatures). Anyway,
> but in fact, it isn't so much the fact that the exception can be thrown, it's
> more that if it can be thrown they have to be caught to make calling functions
> exception-safe; for basic functions like getters this might not be ideal imho.
> (the same goes for the factory functions btw)
Okay, understood. IMO, the type mismatch exception in the case of
getter methods are different from bad_alloc from a factory function.
The former is a bug of the caller side, and if it's carefully written
it can be avoided. The latter is a system error, which cannot be
completely eliminated by the caller side. So, personally, I think the
former type of exception is justified even if you generally want to
make that method exception-free. (Or, we could still make it
"exception free" by letting the getter method abort on type
mismatch:-) But just like the discussion of whether to use exceptions
in general, I understand different people have reasonably have
different opinions. In the end there will be no single right answer,
and decided by some implementation policy.
---
JINMEI, Tatuya
More information about the bind10-dev
mailing list