Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108700 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 19091 invoked from network); 20 Feb 2020 16:31:51 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Feb 2020 16:31:51 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AEBAD1804DA for ; Thu, 20 Feb 2020 06:48:02 -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,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-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.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 ; Thu, 20 Feb 2020 06:48:02 -0800 (PST) Received: by mail-io1-f42.google.com with SMTP id z8so4976083ioh.0 for ; Thu, 20 Feb 2020 06:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eYdAQdyKAAdlrtrL79zeOKoIicb76l8hlsbmr+l8L5U=; b=CTjXytllxdeL6sbx0btaWl/WdswHGhSdvZk7wFSQJmuL0sTJZn7LBft+JaKmiXYjrQ 3x9XxZdcoVdaPwRIqyA9FpRQngHa85CFLaFqi9pNRoA8dsNB9lNHe4s5oF8Sdz65gMCr 3SwD1h9n7AqwlzlhOc3grGDmJU9qAJEmZWh2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eYdAQdyKAAdlrtrL79zeOKoIicb76l8hlsbmr+l8L5U=; b=uUlBgNgdh6m803Q3j0AZRWp16b0rY41m6cQm+YtlpOZURZ+0qx6BQ2AOm2YwvTSYpG KV3bfsIk78AKQYITuLP/GEya/MNTH0kMxtu5i65ZqZEu7rSizyOAgMEpJr8UY3QDUjAx GfOvbHzOf5P8yezuQeYt1Cxe61Ubg8Sm9/ljnUSV8NT7zttcCQ4pq+efs6Wkw3sKafBh junlCrllWppnKD2qIbJaYeW4KitfHzV5AhheoJLLBb+oIRC09CiIx6mX93cQsP9kmmMq F5Zf2JFTnm/e9YUPyr/v9EZNI+XC7c7WT9mDP1EdGwEmNm7/CqG2r1jHN98daadPlC4n y5Ug== X-Gm-Message-State: APjAAAUwF/5x5b0aTEeNmrXkGn3ARC2n2AtrVYvi2/N2GdriDu6YjMBz dL3O5dEy4UF/khFegFKUdUdL2Jy7ps1456BJFgFGvg== X-Google-Smtp-Source: APXvYqyq26mr6Y9u16JWsA6a5a7BSoTlvT3KJ+ODnHUTh7bJBz2syBdFERAjvQ8m3wAn/lNuLYYvVwIyckcnGHuyK+s= X-Received: by 2002:a5d:8448:: with SMTP id w8mr24959413ior.161.1582210081629; Thu, 20 Feb 2020 06:48:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Thu, 20 Feb 2020 07:47:51 -0700 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Explicit call-site pass-by-reference (again) From: internals@lists.php.net ("Levi Morrison via internals") Just chiming in to voice strong support for this RFC. This is a key piece toward making PHP code statically analyzable. If it becomes required at the call site, such as in an edition of the language, it will significantly enhance the ability to reason about code and probably make it more correct as well. As a small example, consider this method on an Optional type class: function map(callable $f): Optional { if ($this->enabled) { return new Optional($f($this->data)); } else { return $this; } } The intent is to return a new optional or an empty one, but if you pass a closure that accepts something by reference you can change the original, which is not intended at all. For people who defend against it, it requires saving `$this->data` to a local variable, then passing in the local. Then if the user does a call-by-reference it will affect the local, not the object's data.