Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46649 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96512 invoked from network); 12 Jan 2010 01:46:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jan 2010 01:46:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.117 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.117 us-mr1.zend.com Received: from [63.205.162.117] ([63.205.162.117:38420] helo=us-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4C/83-26332-094DB4B4 for ; Mon, 11 Jan 2010 20:46:57 -0500 Received: from us-gw1.zend.com (us-ex1.zend.net [192.168.16.5]) by us-mr1.zend.com (Postfix) with ESMTP id CD73143CEA; Mon, 11 Jan 2010 10:52:40 -0800 (PST) Received: from [192.168.16.93] ([192.168.16.93]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 11 Jan 2010 17:46:54 -0800 Message-ID: <4B4BD48D.9030003@zend.com> Date: Mon, 11 Jan 2010 17:46:53 -0800 Organization: Zend Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Lightning/1.0b2pre Thunderbird/3.0 MIME-Version: 1.0 To: Etienne Kneuss CC: Clint Priest , internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Jan 2010 01:46:54.0306 (UTC) FILETIME=[1E32AC20:01CA9329] Subject: Re: [PHP-DEV] __toString(), __toArray() From: stas@zend.com (Stanislav Malyshev) Hi! >> Why not a __cast($Type) magic function? The interesting thing is that in the engine the object handler is actually: typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type TSRMLS_DC); i.e. the handler is already generic, but implementation API isn't - standard engine handler supports only IS_STRING (and IS_BOOL is a funny way - objects are always true). In other words, extensions already can do this, PHP programmer can't. > 1) It's more self-explanatory to explicitly call the appropriate > converting method, enough with implicit madness! This is probably the reason why the above was done - conversion to the string representation is a very frequent action (especially in the Web world where everything ends up being in the text page anyway ;) while conversion to numeric types is very special case and very ambiguous, as Etienne noted, and conversion to an array is also rather special case (a lot of cases where array-like syntax is called for are served by ArrayAccess). -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com