On Tue, Oct 18, 2011 at 10:09:37PM +0200, Arnaud Le Blanc wrote:
> Hi,
> 
> Le Monday 17 October 2011 15:07:30, Alain Williams a écrit :
> > On Fri, Oct 14, 2011 at 08:08:56PM +0200, Arnaud Le Blanc wrote:
> > > Hi,
> > > 
> > > I've already posted this patch and it has since been reviewed and
> > > improved. I'm re-posting it for discussion before eventually commiting
> > > it.
> > > 
> > > The ternary operator always copies its second or third operand, which is
> > > very
> > 
> > > slow compared to an if/else when the operand is an array for example:
> > Is that why the following does not work as I expected:
> > 
> >     $dbh = $how == 'r' ? (&$dbh_r) : (&$dbh_w);
> > 
> > $dbh is NOT a reference to $dbh_r or $dbh_w.
> 
> This is expected; 
> http://docs.php.net/manual/en/language.operators.comparison.php explains it:

It probably does, but it is quite subtle. I was expecting the above to work 
since
it does in C -- although in C &variable is an address which can be used in an
expression ... the PHP '&' operator is different, in spite of apparent 
similarities.

Explained here, but still ....

        http://docs.php.net/manual/en/language.references.arent.php

> > Please note that the ternary operator is a statement, and that it doesn't 
> evaluate to a variable, but to the result of a statement.

I'm not complaining.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to