On Sun, May 12, 2013 at 5:55 AM, Robert Kern <robert.k...@gmail.com> wrote: >> Another example of temporal coupling is json_decode in PHP: you must >> follow it by a call to json_last_error, otherwise you have no way of >> telling whether the json_decode function succeeded or not. >> >> http://php.net/manual/en/function.json-last-error.php > > > I suspect that the author might say something about error checking being > optional. But yeah, terrible API. :-)
The problem with that one isn't that error checking is optional, but that errors are signalled with a perfectly legal return value (FALSE, if I recall correctly - which is also returned if you json_decode a boolean false). Better design would either throw an exception on error, or have a unique sentinel representing the errorness of the return value. ChrisA -- http://mail.python.org/mailman/listinfo/python-list