Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46587 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22205 invoked from network); 31 Dec 2009 13:21:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Dec 2009 13:21:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:40255] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/8E-12956-745AC3B4 for ; Thu, 31 Dec 2009 08:21:13 -0500 Received: from il-gw1.zend.com (unknown [10.1.1.21]) by il-mr1.zend.com (Postfix) with ESMTP id 2E482504C5; Thu, 31 Dec 2009 15:05:55 +0200 (IST) Received: from lap-zeev-win7.zend.com ([10.1.2.15]) by il-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 31 Dec 2009 15:21:07 +0200 Message-ID: <7.0.1.0.2.20091231151339.19f1d818@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Thu, 31 Dec 2009 15:21:05 +0200 To: Derick Rethans Cc: Stanislav Malyshev ,RQuadling@googlemail.com, Alexey Zakhlestin , PHP Internals In-Reply-To: References: <4B3C4041.6000406@zend.com> <10845a340912310226rdb09b26v12551fab5aedd5ae@mail.gmail.com> <4B3C7E0C.3030907@zend.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-OriginalArrivalTime: 31 Dec 2009 13:21:07.0781 (UTC) FILETIME=[1CA58F50:01CA8A1C] Subject: Re: [PHP-DEV] invalid params return value From: zeev@zend.com (Zeev Suraski) At 14:20 31/12/2009, Derick Rethans wrote: >On Thu, 31 Dec 2009, Stanislav Malyshev wrote: > > > > Would changing the returning value to Null to indicate invalid > > > arguments (or any other error condition) would create a significant BC > > > surely? Just how many functions are documented with the entity > > > &return.falseforfailure;? (198 files using this so far vs Return > > > &null; which is used very rarely). > > > > There are different kinds of failure. There's failure for the > function (i.e. > > function tried to do something and failed, like couldn't open the file) and > > failure where function wheren't even executed (like you called > fopen without > > giving it a filename). Some functions return the same in both > cases, some do > > not. I'm sure half of the functions documented as &return.falseforfailure; > > return NULL on incorrect args. > > > > As for BC - it may break some scripts that don't check properly but having > > each function do different thing is worse, since you couldn't even write a > > proper check - since you have no way of knowing what to check for. > >Hmm, I don't actually think many people test whether parsing parameters >failed, but they do test the return value. AFAIK, our "standard" is to >return NULL for parameter parsing failures (at least that's what all the >examples in README.PARAMETER_PARSING_API do). I'd like to see that be >the case for all things, but changing it now could be quite a bit of a >BC break. I agree. The real problem is we'd be breaking applications that are in fact checking the return values very properly - as properly as they can according to the documentation. Many functions can return values that are evaluated as boolean false, well as false/null to indicate error; That results in === being used to check the return value, and consequently changing from false to null or vice versa would break the code. Some pedantic users probably use === even if the function can't otherwise return a value that evaluates as boolean false. Zeev