Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:58558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38467 invoked from network); 4 Mar 2012 02:27:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Mar 2012 02:27:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 207.97.245.123 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 207.97.245.123 smtp123.iad.emailsrvr.com Linux 2.6 Received: from [207.97.245.123] ([207.97.245.123:33000] helo=smtp123.iad.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 34/D3-12048-503D25F4 for ; Sat, 03 Mar 2012 21:27:18 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp52.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 3EC2D24071F; Sat, 3 Mar 2012 21:27:15 -0500 (EST) X-Virus-Scanned: OK Received: by smtp52.relay.iad1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id AD1A52406ED; Sat, 3 Mar 2012 21:27:14 -0500 (EST) Message-ID: <4F52D301.5060101@sugarcrm.com> Date: Sat, 03 Mar 2012 18:27:13 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.1) Gecko/20120208 Thunderbird/10.0.1 MIME-Version: 1.0 To: Anthony Ferrara CC: "internals@lists.php.net" References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC - discussion] Object Scalar Type Casting Magic Methods From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > I've drafted an RFC and functional-complete patch for disucssion > another alternative to add scalar object casting magic methods. > > https://wiki.php.net/rfc/object_cast_to_types > > Please review the RFC and attached patch, and start some discussion on > this proposal. Some notes: 1. Use cases for this are unclear. Wrapping scalar types does not seem very efficient as conversion is always one-directional - once you do any operation your type is gone, so unless you re-wrap it each time (at which point you could as well un-wrap it manually) it's not very useful. Enabling passing SplFixedArray to array functions is very simple - as with any iterable type - just use iterator_to_array (if you don't have builtin convertor, which SplFixedArray does). But it's not always a good idea - since it creates a full copy. Both this method and your conversion do not have a context so it is not possible to avoid creating a full copy. 2. Having separate methods is probably not the best idea. It may lead to implementation having inconsistent conversions between types, such as floats and integers, etc. or having conversions to float but not int and getting very hard to debug errors because of that. Also may lead to conversion be context-dependent and create very confusing results. 3. There's already cast_object handler, why not use it? I'm not sure messing with get is a good idea, it's not exactly meant for that. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227