Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:21883
Return-Path: <pollita@php.net>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 62196 invoked by uid 1010); 16 Feb 2006 17:20:10 -0000
Delivered-To: ezmlm-scan-internals@lists.php.net
Delivered-To: ezmlm-internals@lists.php.net
Received: (qmail 62181 invoked from network); 16 Feb 2006 17:20:10 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 16 Feb 2006 17:20:10 -0000
X-Host-Fingerprint: 69.12.155.130 69-12-155-130.dsl.static.sonic.net Linux 2.4/2.6
Received: from ([69.12.155.130:2327] helo=pigeon.alphaweb.net)
	by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP
	id 93/00-61409-944B4F34 for <internals@lists.php.net>; Thu, 16 Feb 2006 12:20:09 -0500
Received: from localhost ([127.0.0.1] helo=stumpy)
	by pigeon.alphaweb.net with smtp (Exim 4.10)
	id 1F9lrj-000835-00; Thu, 16 Feb 2006 08:20:24 -0800
Message-ID: <002201c6331d$a79473b0$58d01a44@stumpy>
To: <internals@lists.php.net>
Cc: "Andi Gutmans" <andi@zend.com>,
	"Zeev Suraski" <zeev@zend.com>
Date: Thu, 16 Feb 2006 09:23:00 -0800
MIME-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Subject: Minor engine patch to facilitate PECL/operator
From: pollita@php.net ("Sara Golemon")

Hi, purely selfish request here, I'd like to make a minor change to the 
parser... Just a bitty one... You won't even feel it...

Currently, when the parser encounters:  expr1 > expr2   it quietly (and 
reasonably) switches it around to expr2 < expr1 so that is can reuse the 
ZEND_IS_SMALLER op.  The executor has no idea this has occured, but heck, 
why does it need to know after all?

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.

Since greater-than (and greater-than-or-equal-to) are quietly flipped, 
PECL/operator has no way to tell the difference between the two and has to 
assume op1 < op2 (when in fact op2 > op1 may be the correct view).  To solve 
this I've bundled a patch with PECL/operator to set the otherwise unused 
extended_value to a 0/1 value depending on whether it's genuinely less-than 
or greater-than.

There are sleaker ways to do this than what's included in the patch (e.g. a 
new zend_do_() method really isn't needed), but I was attempting to touch as 
little as possible in implementing it.

Is there a chance of this getting merged into the engine?  Or is that just 
entirely too imposing for such an edge case extension.

http://cvs.php.net/viewcvs.cgi/pecl/operator/compare-greater-5.1.2.diff?view=markup&rev=1.2

-Sara