Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101258 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48036 invoked from network); 6 Dec 2017 21:32:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Dec 2017 21:32:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:38702] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EB/44-24804-2D1682A5 for ; Wed, 06 Dec 2017 16:32:02 -0500 Received: by mail-wm0-f51.google.com with SMTP id 64so9521714wme.3 for ; Wed, 06 Dec 2017 13:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=Vl/T7WD5jgFaVsujoq/eK4ZmzD+8fz+gR2MOyTPDpzI=; b=pgxfKn4oAdI5IP2gWBRqEu37QbFeyVDYFfTzZDNWj/CrhU5mIU0EhKB94mdGph/Gb9 0IoCGK7cPaQ/3eR9aMDclV09yGOe46tCfXBLpXcY/7ykhqyMS66lqpLSuCTPmtkEmg4+ gY6apiEU/3wlG30gJMms0O47YXXNrrjUG7+6kSp06rlLlGoNmVBQyqUioNzG/CN5VlD5 my+jwbNW/H15BWVrQW5ypeo3gRHMyHRz5Qpi7N7yXjoJCkuGYDuSMRdtW/ZoNO2RoqF3 4Y4BFNztgSd0W7yPvs4MK5vQGCA3hovZO4hy4n/e0rATdcdQGa/wiB2O4JXRL3H2IrBV U6Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=Vl/T7WD5jgFaVsujoq/eK4ZmzD+8fz+gR2MOyTPDpzI=; b=UoXynT7fEddeSivgg4uiptC4fMT8mUru8m5jaSkaH1pm95JYdv3WpHntSw/G3H9TFD u6p4ES7AHpDath7bx1mdKgQWggaJjjua6jYZo+PJQ0d1+jHtHnhvKKJIPBq3UP/j61f+ 5UuO70m78Ct2ThqRDH85JwDsXdzQmvKskqP+ZAkDuYYZiS+BX69rEaD67z8e+DSZe4SH zkMsLL2tiWMMhhS1pTslas+Xczsm5WHJSCgcF6ezGh2ojNE9eQ+tJVWA0gGKOjnCxZNR AUh0ecFNto8Ej8Gx5WiFfAwWdxEZ8/hJx4lu1CkJJWHmY+g6FK1sL+vZYd5YDnjwuEK+ Oibg== X-Gm-Message-State: AKGB3mIMGu1nvKrIrsAnoCOBYSvJjpIYubqFwB8WuSL3hZefmqT4J4au WhLLxtyB+rjaOvIbAyPEWrrn/w== X-Google-Smtp-Source: AGs4zMbG6fLsFshjtViA8wHgM2a+tRdMPOjxdalj0wWPwXxHOcYMQeFlGXZrCRmtMUMtkPIzytxMOQ== X-Received: by 10.28.51.133 with SMTP id z127mr10570224wmz.84.1512595919398; Wed, 06 Dec 2017 13:31:59 -0800 (PST) Received: from ?IPv6:2a00:23c4:4b81:ae00:697b:8122:7786:31b7? ([2a00:23c4:4b81:ae00:697b:8122:7786:31b7]) by smtp.googlemail.com with ESMTPSA id d10sm4146043wmh.15.2017.12.06.13.31.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Dec 2017 13:31:58 -0800 (PST) To: internals@lists.php.net References: Message-ID: <2d16694d-d9d7-77b1-6a9d-740b92750878@gmail.com> Date: Wed, 6 Dec 2017 21:31:54 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Explicit call-site send-by-ref syntax From: rowan.collins@gmail.com (Rowan Collins) On 06/12/2017 19:49, Nikita Popov wrote: > Hi internals, > > I'd like propose optional support for explicitly marking by-reference > argument passing at the call-site, in addition to the declaration-site Hi Nikita, I approve of the aims of this proposal, but I do wonder if it would be a bit awkward to reuse the syntax which people had to spend so much effort removing in PHP 5.4 (you refer to it as a PHP 4 feature, but for many people it's a much more recent memory). Aside from the frustration of "why didn't we allow it in these cases all along", I can see people being confused if it went from OK to fatal error to encouraged and maybe even mandatory. Your future scope section mentions having more explicit "out" and "inout" annotations; perhaps it would be better to skip ahead to these, with new syntax, and more immediate benefits all round. Is there a reason we can't do this right now? I imagine these working like the & annotation, with the following extra rules: 1) Parameters marked "out" or "inout" in function definitions MUST also be marked "out" or "inout" in calls to that function. 2) Parameters marked "&" in function definitions MAY be marked with "out" or "inout" in calls to that function. 3) A variable passed to an "inout" parameter would raise a notice if it was not defined before use, since it should have a value for the "in" part. 4) A variable passed to an "out" parameter would NOT raise such a notice, since the function call would be a valid initialisation. 5) An already-initialised variable passed to an "out" parameter would be set to null before calling the function. If the function never assigned to it, it would remain null in the calling scope. Rule 2 allows for better interoperability between old and new code, and I am imagining it also applying to core functions, so that this would work without pre-initialising $matches: preg_match($pattern, $string, out $matches); I'm not sure how reference-returning functions fit into this picture, and there are probably other kinks to iron out, but it seems like it would have a lot more benefits overall. Regards, -- Rowan Collins [IMSoP]