Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'api.': 0.05; 'yeah,': 0.09; '(false,': 0.16; 'boolean': 0.16; 'coupling': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'kern': 0.16; 'optional.': 0.16; 'php:': 0.16; 'sentinel': 0.16; 'throw': 0.16; 'exception': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'example': 0.22; 'error': 0.23; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'errors': 0.30; 'returned': 0.30; 'robert': 0.30; 'message-id:@mail.gmail.com': 0.30; 'another': 0.32; 'checking': 0.33; 'not.': 0.33; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'representing': 0.36; 'being': 0.38; 'to:addr:python-list': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'telling': 0.64; 'legal': 0.71; 'subject:skip:o 10': 0.84; 'terrible': 0.84; 'url:php': 0.85; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=Q3Gbwfwty9biOgeHx3PbRenj1zgkds/mmqivAhu9kIg=; b=V/WBATQWBoAYXHdgvJ8PzY4G342sEa8LLGGW7ua6uZkNDQC8pj3rJVPHhQ7ScKR1of SJJN1Zn1YU7pLsr1DJPfOwCQLFE/AipyZJ0zH7EYB6cA26uOmGXVtyw6qWBfxxHP2lku sGdmv7ysKbqBflewzWaeF4miYO/uIAHmkr0+oAaLRuuuvA7wA/4EwGqhBvDPaWV2SNmm 78nu8crLdT5rC+Eh5xi2cWkMHRNSZYnb2wEv2hTc2d0fZFxlu+dTFgb6O+8xUBXirHw1 A10hsXhVZsXs5zTFqle0xtNwON4y0Kd8sPOV1tt1KewNJCczZ2xeCb9zG6rhuZ+hRDUA y1Sg== MIME-Version: 1.0 X-Received: by 10.220.83.138 with SMTP id f10mr14791087vcl.7.1368311966929; Sat, 11 May 2013 15:39:26 -0700 (PDT) In-Reply-To: References: <518a123c$0$11094$c3e8da3@news.astraweb.com> <518b32ef$0$11120$c3e8da3@news.astraweb.com> <518be931$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c5bbc$0$29997$c3e8da3$5496439d@news.astraweb.com> <518c7f8e$0$29997$c3e8da3$5496439d@news.astraweb.com> <518cd360$0$29997$c3e8da3$5496439d@news.astraweb.com> <518df898$0$29997$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 12 May 2013 08:39:26 +1000 Subject: Re: object.enable() anti-pattern From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1368311970 news.xs4all.nl 15946 [2001:888:2000:d::a6]:37075 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45159 On Sun, May 12, 2013 at 5:55 AM, Robert Kern 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