Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49829 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23530 invoked from network); 30 Sep 2010 20:28:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Sep 2010 20:28:56 -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 67.192.241.123 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.123 smtp123.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.123] ([67.192.241.123:58692] helo=smtp123.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/E0-18648-503F4AC4 for ; Thu, 30 Sep 2010 16:28:55 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp12.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 638A83C009E; Thu, 30 Sep 2010 16:28:50 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp12.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id 0A54A3C0096; Thu, 30 Sep 2010 16:28:49 -0400 (EDT) Message-ID: <4CA4F301.1070005@sugarcrm.com> Date: Thu, 30 Sep 2010 13:28:49 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: Adam Harvey CC: PHP internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] RFC: Comparable interface From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > The RFC is at http://wiki.php.net/rfc/comparable, and the patch at > http://www.adamharvey.name/patches/comparable.diff.txt. Any and all > feedback welcome, particularly since I'm still learning my way around > the innards of the Zend Engine, and it's entirely possible (indeed, > likely) that I've overlooked something obvious. It is not clear from the RFC, if the engine encounters $a <= $b, what actually happens? E.g.: 1. Is only $a checked for Comparable or also $b? 2. How it is ensured that if $a < $b then $b > $a? 3. Would sorting work with it? 4. If both $a and $b are objects with different compare functions, how it is determined whose function is used? Note that operators like == are assumed to be commutative, and less/more operators are assumed to be commutative in pairs, like above. As a side note, if we have traits we might instead think of having Comparable trait or interface or both, which would declare having compareTo() standard feature (as Java does) without messing with the engine and overloading operators. Surely, it would be more verbose, but that might be a good thing. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227