Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79435 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95634 invoked from network); 4 Dec 2014 23:46:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2014 23:46:43 -0000 Authentication-Results: pb1.pair.com header.from=are.you.winning@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=are.you.winning@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: are.you.winning@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:63378] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/54-61462-162F0845 for ; Thu, 04 Dec 2014 18:46:41 -0500 Received: by mail-wi0-f180.google.com with SMTP id n3so29627146wiv.1 for ; Thu, 04 Dec 2014 15:46:38 -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:date:message-id:subject :from:to:content-type; bh=nXh79cRfv7AJIM6Sdr3D2977ctzZy8Dv/xueeBxw5ws=; b=jFpzpQtmnxkd+2phvDdF0hCX9ZEAqYxE/p9GNUmz8P5w1uzOmnSCsChqyMgdMOKHv+ NE9yOsTdXWZFyCPzR/vM7Tnnb6D+kYItOJxNAGLrLZ868i+RTjw+NpimfTua8eTqQEIj 2mdNInQGbqp8HfRXTiTQLS6CvjPiOVUwJPxAmOFD7W2NIgB/qv9Gq/17LPVgfLz/ET1x 14MIjQqKDAh/uMBW5lhaH0//XPw5RZNBx6e4/KZhTmjmEBGlEVzMps+LbasN86FH7Ppg dNU4A+5swXosHcyV+3u95Qgnxw4bcBQ49fyflOBy4EjJpiX+JlakHXkF07DH122XKgPW 8leQ== MIME-Version: 1.0 X-Received: by 10.180.208.69 with SMTP id mc5mr897901wic.25.1417736798356; Thu, 04 Dec 2014 15:46:38 -0800 (PST) Sender: are.you.winning@gmail.com Received: by 10.180.8.36 with HTTP; Thu, 4 Dec 2014 15:46:38 -0800 (PST) Received: by 10.180.8.36 with HTTP; Thu, 4 Dec 2014 15:46:38 -0800 (PST) In-Reply-To: References: Date: Thu, 4 Dec 2014 23:46:38 +0000 X-Google-Sender-Auth: QYOwXkJl6RkhjQ4mmsmxPeH_O7Y Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary=001a11c36d78404a8e05096c92c1 Subject: Fwd: Re: [PHP-DEV] Re: Only variables can be passed by reference From: cw@daverandom.com (Chris Wright) --001a11c36d78404a8e05096c92c1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Forgot to cc list, see below ---------- Forwarded message ---------- From: "Chris Wright" Date: 4 Dec 2014 14:09 Subject: Re: [PHP-DEV] Re: Only variables can be passed by reference To: "Andrea Faulds" Cc: > On 4 December 2014 at 12:26, Andrea Faulds wrote: >> >> >> > On 4 Dec 2014, at 10:38, Yasuo Ohgaki wrote: >> > >> > >> > Yet another sample code. This cannot be executed on 3v4l.org for security >> > reasons. >> > >> > > > $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 t= he return value tells you is that *something* changed. >> > > While I'm undecided on this change (leaning towards "no"), there is a more useful example with stream_select(): > > $socks =3D array($sock); > var_dump(stream_select($socks, $socks, NULL, 1)); > > It is rare that anything actually uses OOB data in the real world, more often than not stream_select() is preceded by a line like $e =3D NULL; > > I could maybe get behind this for specifically permitting literal NULL to be passed, as is often the convention for out params in C, where passing a NULL pointer is permitted and handled as "I don't want this data". > > Another example of where this could be useful is stream_socket_client(), where you want to specify timeout/flags/context but don't care about errno/errstr, so you could pass literal NULL to these instead of having to declare a couple of trash variables. > > That said, the use cases above would probably be better served by named parameters. > > Thanks, Chris > >> >> -- >> Andrea Faulds >> http://ajf.me/ >> >> >> >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> > --001a11c36d78404a8e05096c92c1--