Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106296 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 93086 invoked from network); 25 Jul 2019 16:24:58 -0000 Received: from unknown (HELO mail-lf1-f52.google.com) (209.85.167.52) by pb1.pair.com with SMTP; 25 Jul 2019 16:24:58 -0000 Received: by mail-lf1-f52.google.com with SMTP id v85so34548443lfa.6 for ; Thu, 25 Jul 2019 06:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DR4ulbMYesFVls6dm+P4E2K2zHtCAjVVSeOPePBL9qo=; b=YZe4EC3eMFpoVvi8MN5zavWUTEehDdAiN/VxrWTCbWM8LYC8m+zkhPY7S2njAbW4WE Ls02URcMdzIEwYmu8tpV/bo91rqkzx2rkxKV6J6WQdJIn12FAn8L0LyxZYUHFzinfZzk LfbeSJ6I9mxGccrFelpIJcF0FiHqm3gXwJQxn9YjNQxuhypgojEwS82j039m+BBL24QL xyA6JP7ebUFMJIsiMIAJgqaGJPjkAhH49kOD8rsruqb4b11EAC67NW8wV7zF5V2/SRWt ODDFY6HIKl8s5efrkK5PaM+zZnzQKmNSioYZOuEoQ71nPNOTSswIlsbHkb5yJScD7tG0 useQ== 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=DR4ulbMYesFVls6dm+P4E2K2zHtCAjVVSeOPePBL9qo=; b=Y1KIyOecLl6g23d0fKUZMXTDjf9YgIwxPHiziRdr6mHA//DhKNTYonhO2de0yWong8 49hGcKIkH2su/ePXmuryzysSRlpC3L3Vc4cLi10/snRIb81u9vGKzqFHJ82OA+9HplWM Jwk0x7gTyx7dgURsyPuL9Ce6nKJ2b5l4v4adJQGp2/2OqJyRY1e/kESvupqFidIhHsKp Kr4AJqswv/aH2z3eLYfA01jbup+FQSZpn4ODFDlmGOz0nt8N7AoBqoZsvM63oayPs+GV /Yd5Et55/CcXjdq2BUOOzV7QTtmmhbbiEDDju5l8gXT+Az+ER2i63VsmkQiY7oCwGw6J 0MRw== X-Gm-Message-State: APjAAAX7Tqoklmg9dRNaSCNXsFzjCio8L9qJN56KBJF7zA6vw4czw/BF K/7ILMhrm7YpSAMH47mJjkYiaz3I4IedwK1NKkc= X-Google-Smtp-Source: APXvYqyWSYeHc65ddM9r0e4ku66lblzIUTyQJEPuiZ66rWI5yy87DZHOERL0t+9XENUOq1AtqJ7B0TvXmjhizlpGBdo= X-Received: by 2002:ac2:4a78:: with SMTP id q24mr38511544lfp.59.1564062516835; Thu, 25 Jul 2019 06:48:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Jul 2019 15:48:20 +0200 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b8fc27058e81aeeb" Subject: Re: [PHP-DEV] Re: [RFC] Explicit call-site send-by-ref syntax From: nikita.ppv@gmail.com (Nikita Popov) --000000000000b8fc27058e81aeeb Content-Type: text/plain; charset="UTF-8" On Thu, Jul 25, 2019 at 3:14 PM Rowan Collins wrote: > On Thu, 25 Jul 2019 at 13:32, Nikita Popov wrote: > > > I think it can either go forward as-is, in that it constitutes the first > > step towards bringing sanity to by-reference passing in the long term. > > > > > Hi Nikita, > > As I mentioned before, I think this RFC is 10 years too late: if this goes > ahead, we'll be telling a lot of people "You know all those reference > annotations you removed when you upgraded to PHP 5.4? You have to put them > all back again now!" > > To be clear, forcing a parameter to be by-reference against the signature > of the called function was a bad feature, and this proposal would have been > better. But without a time machine, I think this will cause more confusion > than it brings value. > > Adding "out" and "inout" keywords, as mentioned in "future scope", is a > much more powerful change, won't require any opt-in modes or breaks to > existing code, and would be looking forward rather than backward. It's hard > to see how tweaking the meaning of "&" will lead us closer to that, making > it feel more like "alternative" than "future". > While the out/inout keywords are conceptually nice, I don't think they really change anything regarding the migration path. In your previous mail you mentioned that we could make these keywords required if they are used on the declaring function: But that does not solve the problem of existing functions. I think nowadays it is well known that by-reference passing is to be avoided and I don't see it particularly commonly in user code. By-reference passing is mainly used when it is needed to interact with existing by-reference functions such as preg_match(). We can hardly switch these functions to use out/inout if we require the corresponding keyword on the call-site. This proposal (in conjunction with the option to make it required) would solve the main issues I have with the by-reference passing implementation -- the out/inout approach is a refinement over that, but I'm not convinced that it a worthwhile refinement relative to the language and engine complexity it will introduce. It would be a necessary step if we had plans to eliminate references from PHP entirely, but despite how much I dislike PHP references, I don't think that eliminating references entirely is possible even on a very long time-scale. Nikita --000000000000b8fc27058e81aeeb--