Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:27204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44541 invoked by uid 1010); 27 Dec 2006 20:02:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 44526 invoked from network); 27 Dec 2006 20:02:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Dec 2006 20:02:43 -0000 Authentication-Results: pb1.pair.com header.from=andrei@gravitonic.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=andrei@gravitonic.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gravitonic.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: andrei@gravitonic.com X-Host-Fingerprint: 204.11.219.139 lerdorf.com Linux 2.5 (sometimes 2.4) (4) Received: from [204.11.219.139] ([204.11.219.139:53267] helo=lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/03-20830-041D2954 for ; Wed, 27 Dec 2006 15:02:43 -0500 Received: from [66.228.175.145] (borndress-lm.corp.yahoo.com [66.228.175.145]) (authenticated bits=0) by lerdorf.com (8.13.8/8.13.8/Debian-3) with ESMTP id kBRK25EU018655; Wed, 27 Dec 2006 12:02:05 -0800 Mime-Version: 1.0 (Apple Message framework v624) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-ID: Content-Transfer-Encoding: 7bit Cc: Antony Dovgal Date: Wed, 27 Dec 2006 12:02:29 -0800 To: php-dev Internals X-Mailer: Apple Mail (2.624) Subject: Return value of convert_to_*() From: andrei@gravitonic.com (Andrei Zmievski) Antony and I just had a spirited discussion on IRC about his latest patches to convert_to_unicode() and convert_to_string(). The specific troublesome point was conversion of IS_OBJECT type. His point was that since all we care about is the end result, then the function should return SUCCESS regardless of whether the object could convert itself to a string or whether we forced the conversion and got a simple "Object" string. I do not subscribe to this point of view. I added return values to conversion functions precisely because I wanted to distinguish between "good" and "forced" conversions. We can convert anything to anything, that's not a problem, but in certain cases I do care that we tried to convert IS_OBJECT to IS_STRING and couldn't do it without falling back onto the "Object" crutch. One such place is zend_parse_parameters(). If you say zpp(..., "s", &str, &str_len) and the user passes an object without __toString() method, zpp() should issue an error saying that it expected a string and got an object instead, even if we "forced" the conversion result to be a string in convert_to_string(). My problem with considering "Object" a "successful" conversion is this: why do we issue E_RECOVERABLE error if the object couldn't convert itself to a string? Why should the user be able to catch that and not my code? Please tell me that this is a valid point of view. -Andrei