Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101300 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2723 invoked from network); 11 Dec 2017 02:29:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2017 02:29:58 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.173 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.128.173 mail-wr0-f173.google.com Received: from [209.85.128.173] ([209.85.128.173:46994] helo=mail-wr0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D3/05-53433-3ADED2A5 for ; Sun, 10 Dec 2017 21:29:55 -0500 Received: by mail-wr0-f173.google.com with SMTP id x49so15964940wrb.13 for ; Sun, 10 Dec 2017 18:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=SOf7dafkarfefLma7AzCfGSDaton7xtMazybbk+V2mo=; b=ftF4+6vgcN019EdbigjJUqYJRmszcyQsaHEYbycUE8qMRb5f8kPIEO3Ty6+S+8pXtQ n4/gTeFlyACS2ii3XugA0iyO5XtMjwEZ6/Pwro9BIwceMGveqt/g1tbygdTUC5XrqSQU 0IImJJyHIBi6Sr6kKvMJtPZ6RQCMxWX+i8xV8rXE1s4yXPjmA1ld7/eBji0lUd+Gj2Os LunXb47Zpe+A8DQJiFyOEeX9911eRp96diF92V/OThPkRkQ/yBleXv17VGdcYV5yImaI bnm8FI4O8F8CCyk25JTmQP1JEMxhtJMVsDrwLw6ampDQZCNxjo4i8t32bi8cKQefhgxI wKWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=SOf7dafkarfefLma7AzCfGSDaton7xtMazybbk+V2mo=; b=Q8UDN67mkO9OZ11D9Mq3iMMG1EQQUFAdkgl68E2cpgEXATYOi/6rmLprHcc/5hAFYU r7Jth7GyKmta0wPghcNQ+FbtdzZdc14yq9HgSHiTWPE13YIMGHUnz0PNgc8IV3t1cmmJ Xbu2/NDag+5rg/Lc5rCS6gBGsR2Ns2QJ3BzBQIkILS2NMYqNXXvdXqdZuEOzJWNLQzPt oXw7o1RD0uzrddrlNMqxsL5ojFCBL6ZSW3Xv5dCDkL7olXQOnR1nwV/IueSbO+s8NhYL AbF/LBM7BBiEqc/VlZ79SZMAVtH6vvLqkJ/5h3q6d10MxgRo6pfaF6FQJbVYtSjXIWTT QKAw== X-Gm-Message-State: AJaThX4TgZ7YaEpcvbUbOKRqNVDRIvEhQ6ky+CO2/9wTR+j9hpuIFULH M1thFBHd993Wy7ow6wMdpX1Fuqj08Jvny3Z/HzY= X-Google-Smtp-Source: AGs4zMYfCt8WN8VT7Vc388FFIq2fy/Z7PMogkwCINFSz6kAgzm9oz/03fnVz8QgP6Pj15BgxBLhgNHvcfiP8FX+VWVc= X-Received: by 10.223.186.67 with SMTP id t3mr30496603wrg.276.1512959392161; Sun, 10 Dec 2017 18:29:52 -0800 (PST) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.28.169.197 with HTTP; Sun, 10 Dec 2017 18:29:51 -0800 (PST) In-Reply-To: References: Date: Sun, 10 Dec 2017 19:29:51 -0700 X-Google-Sender-Auth: 86K7f9iPQd5B7XEEis_femO-jeA Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] Explicit call-site send-by-ref syntax From: levim@php.net (Levi Morrison) On Wed, Dec 6, 2017 at 12:49 PM, 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: > > https://wiki.php.net/rfc/explicit_send_by_ref > > In short, while currently we have > > function byRef(&$ref) {...} > byRef($var); > > this proposal would also allow > > function byRef(&$ref) {...} > byRef(&$var); > > so that the use of by-reference passing is obvious without having to > consult the function declaration. I think we ought to commit to requiring the ampersand at the call site some point in the future. As others have noted it provides little benefit at the call site if it is not required. However, there is an area where this does provide value that others have not yet mentioned or thought of: `callable` parameters. public function apply(callable $f) { return $f(&$this->data); } This requires the callable to accept the argument by reference, something we cannot currently require. Of course this is rarely needed; I am merely pointing out this feature is more than a syntactic hint to humans. Based on the current discussion I would vote yes on this RFC, despite the concerns raised by others.