What is Expressiveness in a Computer Language
Joachim Durchholz
jo at durchholz.org
Sun Jun 25 07:48:04 EDT 2006
Dimitri Maziuk schrieb:
> That is the basic argument in favour of compile time error checking,
> extended to runtime errors. I don't really care if it's the compiler
> or runtime that tells the luser "your code is broken", as long as it
> makes it clear it's *his* code that's broken, not mine.
You can make runtime errors point to the appropriate code. Just apply
"programming by contract": explicitly state what preconditions a
function is requiring of the caller, have it check the preconditions on
entry (and, ideally, throw the execption in a way that the error is
reported in the caller's code - not a complicated thing but would
require changes in the exception machinery of most languages).
Any errors past that point are either a too liberal precondition (i.e. a
bug in the precondition - but documenting wrong preconditions is still a
massive bug, even if it's "just" a documentation bug), or a bug in the
function's code.
Regards,
Jo
More information about the Python-list
mailing list