Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108729 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63874 invoked from network); 23 Feb 2020 16:06:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Feb 2020 16:06:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C19761804E0 for ; Sun, 23 Feb 2020 06:23:53 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 23 Feb 2020 06:23:53 -0800 (PST) Received: by mail-wr1-f42.google.com with SMTP id g4so971503wro.13 for ; Sun, 23 Feb 2020 06:23:53 -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=iB0uYfQeW2XXK5CZC9IOuZxNIXCi37RokjG4iM+zkRw=; b=hz/tEE3VWyCrCGBaCfgrRkoSlnObp0qab2lc1/AMCSUHy7xPd/T9dYECfC6bNtAWqG jKq8eypw7r3YOC8BqK4UpDm0e1euYzCxSoqMBcGd5kCgTJHa9HejzokjwjqmYYvN0X5/ pj7DKSE9j9e/AmWNmLWV6WvCgOHv0AFYaOAk3bq+DAIKnMtkowo7a8aTBu4qAq0XrXKv e2v7WkKe1OydZ3mUKS1Vhx7PkE42hIkAriAAj8hRdb189rSRxo5m7bk4XuUACKoQRgAC vZC05e6WzTOTeePwXMfd7JJSjlVyC5ggwFMsqXNhCm36RL+d+tp/gz6WknYb2AM7Y+jD 1FgA== 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=iB0uYfQeW2XXK5CZC9IOuZxNIXCi37RokjG4iM+zkRw=; b=JeBirr7HaIH//dG443tFs85jrQyFkGfKJx6+JNWb+pHxPoPmpW3GgPGwomddd/eeVL NfMRb5UKCG25/4CGqSjHxd4zCLbW7dNqLv7mthhDNA5VHGYK4y1p+NIatpaWABmWERD4 GjJ77Szmrj6idNMZMUdPMauSoh6hK6LDwQuA5PO/ZW/X1el5URGYvrKaECIjclUjFLmG SXN/1/DiMoxDawRc6WwE75/RjAG6oQo71S4H0LEMwNgyOM8AoIPvbmzNASpFEViSHjA4 6cKdv9YRLRlUyenLxF8Fwq7d+fBlV1+M0k57/DBXHHxSNPgz4txCTstxOq39rtshbLGA pWWg== X-Gm-Message-State: APjAAAWym/NBgc0/uGc9TtO2MgNrSs6pWZW5kobxnWSICU6A4hHZtzr5 AEszTqqWUgaUsvFsI0/Z3j4KbIkN X-Google-Smtp-Source: APXvYqyWvTJqvvHiZTxih5cdV6uDFtP21iudSdipLLMtnucSrMsnPNpUHCNd3SYt+Lg3DzQTfN5ohw== X-Received: by 2002:adf:f586:: with SMTP id f6mr4847876wro.256.1582467826554; Sun, 23 Feb 2020 06:23:46 -0800 (PST) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id w19sm12886957wmc.22.2020.02.23.06.23.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 Feb 2020 06:23:45 -0800 (PST) To: PHP internals References: <8B2AFC37-9425-440C-B89D-61CBAAB0CDDD@gmail.com> <08159EA6-61E5-4E85-AC43-9637783315EA@newclarity.net> <73831D4E-B53C-4350-BDAB-2F5BB31E2E8D@gmail.com> <03009039-9B2B-49BC-9CFF-CFB77BEFE2DC@newclarity.net> Message-ID: Date: Sun, 23 Feb 2020 14:23:43 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <03009039-9B2B-49BC-9CFF-CFB77BEFE2DC@newclarity.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC] Explicit call-site pass-by-reference (again) From: rowan.collins@gmail.com (Rowan Tommins) Hi Mike, First, I'd just like to reiterate that I absolutely see benefits in this proposal, and am definitely not campaigning for it to be abandoned as a bad idea. Like with any proposal, we have to weigh those benefits against the costs, and my current personal opinion is that the scales come down *very slightly* on the cost side. I will also just say that you have made some valid points about different ways people might perceive this change, and my fears on that score may be overblown. On 23/02/2020 07:03, Mike Schinkel wrote: > The RFC does not require mandatory use, period. > > The "cost" you worry about will not exist unless and until a future RFC proposes to make it mandatory and that RFC is accepted. The RFC states very clearly that the full benefit of the change will only be realised by making the markers mandatory in some way, and includes specific discussion of how that might be introduced. Put simply, tools (and even humans) get most from knowing that a particular line of code *won't* pass anything by reference, and optional markers can't guarantee that. I am analysing the proposal on that basis, just as I would analyse a proposed deprecation on the basis that the deprecated feature will one day be removed. If we analyse it on the basis of it *never* becoming mandatory, we have to adjust our analysis of both costs *and* benefits. Regarding prefer-ref and prefer-val: > function call_with_current_user(Callable $callable, int &$foo, int $bar ) { > return call_user_func( $callable, current_user(), &$foo, $bar ); > } If you define the function this way, all callers are *required* to pass the parameter by reference. That immediately means that this is a fatal error: call_with_current_user('foobar', 42, 42); Internal functions have the magical ability to accept both literals values and reference variables, whereas userland functions have to choose one or the other. >> As an example of the second, even under strict settings, calls to certain internal functions will have an optional & at the call site, which changes their behaviour. >> >> To those without knowledge of the core, those functions simply have to be remembered as "magic", because their behaviour can't be modelled as part of the normal language. > I am unclear how the optional ampersand at the call site will change the behavior. I was referring to this line in the RFC: > If the argument is a prefer-ref argument of an internal function, then > adding the |&| annotation will pass it by reference, while not adding > it will pass it by value. Outside this mode, the passing behavior > would instead be determined by the VM kind of the argument operand. That means that for any function implemented internally as "prefer-ref", the user can now *choose* whether their variable will be overwritten by the function. I don't know exactly which functions this would affect, because as far as I know, the manual doesn't have a standard way to annotate "prefer-ref". Which is kind of my point: it's magic behaviour which sits outside most people's understanding of the language. > I don't particularly see a problem with requiring a third change in > the future. Hindsight is a wonderful clarifier. And I believe > elsewhere you have been debating me over the need for incremental > change. Caveat emptor. The distinction I would make is between incremental change, and contradictory change. If we later introduce out parameters in a way that's compatible with call-site &, that would indeed be incremental change; the effort spent adding & would move code closer to the final state. If we end up introducing call-site "out", the effort spent adding & will simply be compounded with the effort spent adding "out". Predicting the future is a mug's game, but it's at least worth exploring some possible futures, and how decisions now might help or hinder them. Regards, -- Rowan Tommins (né Collins) [IMSoP]