Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21888 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78676 invoked by uid 1010); 16 Feb 2006 22:55:28 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 78660 invoked from network); 16 Feb 2006 22:55:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Feb 2006 22:55:28 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:63638] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id E9/00-12271-FD205F34 for ; Thu, 16 Feb 2006 17:55:28 -0500 Received: (qmail 16609 invoked from network); 16 Feb 2006 22:55:22 -0000 Received: from localhost (HELO zeev-notebook.zend.com) (127.0.0.1) by localhost with SMTP; 16 Feb 2006 22:55:22 -0000 Message-ID: <7.0.1.0.2.20060217005156.0b12d660@zend.com> X-Mailer: QUALCOMM Windows Eudora Version 7.0.1.0 Date: Fri, 17 Feb 2006 00:55:03 +0200 To: "Sara Golemon" Cc: ,"Andi Gutmans" In-Reply-To: <000901c63322$20b5d550$5c8be5a9@ohr.berkeley.edu> References: <002201c6331d$a79473b0$58d01a44@stumpy> <7.0.1.0.2.20060216192615.099c9598@zend.com> <000901c63322$20b5d550$5c8be5a9@ohr.berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: Minor engine patch to facilitate PECL/operator From: zeev@zend.com (Zeev Suraski) I understand. Aren't you slightly worried about the implications of making it possible for x>y to have a different meaning than yy and y > >Enter PECL/operator, which tries to implement operator overloading > > >for objects (and does a decent job at that). In the interrest of > > >ease of use and consistency, every overloaded binary operator is > > >[meant to be] left associative. This is, in the expression expr1 > > >op expr2 expr1 gets to decide how it will combine-with/compare-to >expr2. > > > > > What does it mean that it gets to decide? If it's left associative, > > then it's evaluated from left to right, no? > > >Yes, and that's the problem. $a > $b *isn't* read by the current parser as >$a > $b, it's read as $b < $a. > >For all normal PHP comparisons, the distinction is unimportant... 4 < 2 >and 2 > 4 will both evaluate to false after all. > >However, the way object operator overloading is being done is: If the first >operand is an object implementing an overload method for this op, dispatch >to that method rather than using the tranditional comparison function. e.g. >$a < $b turns into $a->__is_smaller($b). > >Now say you've got that expression the other way around: $a > $b. What >you'd expect is that if $a is an object, it'll try to call >$a->__is_greater($b). What you get is an automatic reversal of the >expression by the engine: $b < $a, which turns into: "If $b is an object, >dispatch to $b->__is_smaller($a);" which is not the same thing. > >-Sara