Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79431 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85269 invoked from network); 4 Dec 2014 22:02:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2014 22:02:54 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.173 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.223.173 mail-ie0-f173.google.com Received: from [209.85.223.173] ([209.85.223.173:45946] helo=mail-ie0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/A2-61462-C0AD0845 for ; Thu, 04 Dec 2014 17:02:53 -0500 Received: by mail-ie0-f173.google.com with SMTP id y20so16597329ier.4 for ; Thu, 04 Dec 2014 14:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=mtQI7Jz02ro92lgul6U+oOVeV9wGRCtOF2jaVeEjfk8=; b=DpRC1F4aZOqU7AS2GPpSdn2wAe1OO14iFzPTzdfW9pXN6WQMWcJbWxNMLzt7GvSOMC nWIn/TyeN6xGQEX1gsXej4QjNPN/Q8cFVKcgCxGoA3W9AXUgsjg9dxhUUeZ7B63VQTAH 0QcOtJK/FjOZ9NiO8jAmSd1BDcEhNF70SgjrpYyeTbHfSfpnvIKAcnLak3pau8TZ8zH+ GKYRkBhb5kuXPiTx//gFLLJZeTPofO0KAV7uaC+KaTR5YDwSWBBwecB0BOWLQhqfAXAo AW3eDaQ++0LIe/L5SPfhxLvVO3d/s5gdNtfFuuV1HgoB8HwQVUCGM7UfoHzCI6LME8GF gLEA== X-Received: by 10.107.36.5 with SMTP id k5mr12001259iok.4.1417730570134; Thu, 04 Dec 2014 14:02:50 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.107.164.217 with HTTP; Thu, 4 Dec 2014 14:02:09 -0800 (PST) In-Reply-To: References: Date: Fri, 5 Dec 2014 07:02:09 +0900 X-Google-Sender-Auth: uIPegK4IeUuVuH5GmmS4ort19Ds Message-ID: To: Andrea Faulds Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1140f54e052b6905096b1f23 Subject: Re: [PHP-DEV] Re: Only variables can be passed by reference From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1140f54e052b6905096b1f23 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Andrea, Stas and all On Thu, Dec 4, 2014 at 9:26 PM, Andrea Faulds wrote: > > > $sock =3D fsockopen('www.php.net', '80'); > > var_dump($sock); > > > > $socks =3D array($sock); > > var_dump(stream_select($socks, $socks, $socks, 1)); > > > > //var_dump(stream_select(array($sock), array($sock), array($sock), 1)); > > //Fatal error: Only variables can be passed by reference in > > /home/yohgaki/tmp/ttt.php on line 8 > > ?> > > Using stream_select without real variables like that is weird, what=E2=80= =99s the > point? You=E2=80=99ve discarded the read/write/error information, all the= return > value tells you is that *something* changed. There are 2 points. It does not have to be module functions. User may define function which has similar to stream_select(). int stream_select ( array &$read , array &$write , array &$except , int $tv_sec [, int $tv_usec =3D 0 ] ) This kind of signature requires $tv_sec. If $write and $except can null(NULL) or empty array(array() or []), but it does not allowed. Even when there is parameter to pass, user has to create variable always. select_select([$a], [$b], [$c], 10); fails with E_ERROR, while $x =3D [$a]; $y =3D [$b]; $z =3D [$c]; stream_select($x, $y, $z, 10); works, but It does not look nice. Stas points out "these are constant". It is a kind of constant since array(1,2,3) is array literal and value never changes. I'm not sure how literals are handles in Zend engine, but it may use the value as referenced parameter. array_splice(array(1,2,3,4), 2); Code like this is useful to get certain part of config, etc. Nobody writes code like above directly. If function returns literal and passed as referenced argument, then PHP raises error. Please take a look at this code http://3v4l.org/qUDOv Raising errors for this kind of code is not good. IMHO. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1140f54e052b6905096b1f23--