Lance Dillon wrote:
Just throwing this out there, some modules have the functions present regardless, and return a message or error code saying it isn't implemented if it wasn't compiled in.? So another option is to have all the methods present, and either return a message or error code, or throw an exception, and let the programmer deal with it.
All things considered, I would have a preference to have all methods present and accounted for, even if they do not work. And then, for maximum ease of use, choose to: a. Return a value which can indicate failure, but the programmer can choose to ignore if the failure is non-essential. b. Indeed have undefined constants which allow programming just like one does in C, which allows compile time decisions to except support for certain features.
When you think about it, what is easier, to try something, catch the error and try an alternative, or to have an if statement to determine if the first exists and do the alternative if it doesn't.? Really kind of the same thing....
Using exceptions forces the programmer to take rather explicit and verbose actions to accomodate in this case; so I'd prefer returncodes instead which can be ignored without a lot of fuss (and it avoids rather costly exception handling).