Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111179 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55592 invoked from network); 24 Jul 2020 18:58:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jul 2020 18:58:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CD03C18053B for ; Fri, 24 Jul 2020 10:53:52 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (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 ; Fri, 24 Jul 2020 10:53:52 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id y3so9056226wrl.4 for ; Fri, 24 Jul 2020 10:53:52 -0700 (PDT) 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=p6sdWTmcBKCdIZ8esRSrBb/Xj8h+2a0SVRDOrUGUqIk=; b=ZrU8r7gAoTIcle0zXNxs0nrZFSGyJoZBidQQdpqmrPjfOnUcuhF1Q2UbqFCAuDjSE8 FH242WcaUFYXIBLFAKXe+133uwRx34qTZS7V7hKo1sp+wV8lqXHcAZzDyIFf+JEcDb1R ysMVW9oxv/Ga/LV2lvOay6L93QLP5hKCYZ6Et2jozDmE1l6YU9yFY/BU/ZXusn0IZuyM IRfKyI8O3lM8mf5r7r8GVEVjUjdjdIuTnNs5DPIQLCQKmtbZA8DqTaDjnShcDaPmqo9+ DJd0VA+U/DF9LVeK/vsteGcnth2sRPTDTEIUUKF+Cp2RULg8ohYo9VbRnGAog7R8rIrL R6CQ== 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=p6sdWTmcBKCdIZ8esRSrBb/Xj8h+2a0SVRDOrUGUqIk=; b=os8WaolWP4yTcHe4ylhqw3kE1Xz5vBDFsNJ9gVePdXoMecV14qYja+yqPdsNmJZvKM /24LtW6UmVMnYUFcvleCGvK5U8ItlbQiW+ur6GyMsjZsWh6biGt3Y6eIGnnXIctNoC6W 8348or1nV8APj5NTwysQkyS6puJQkbjwYpI4zX1pHbfxy9dKQ2nYxKeeyVdReLTNAo9i kdL1/lKmj0O6PPj3f/jVhHBfZ/yhNqZLGd76qACAZ0vGEkN0qep9116CHFXJ4laIgzAo 0CZ2am04ow/x0b4NTrPWu0gFMv3H9RCnkRR+0cEnEx01sPQK4PFGaX/4VbKKG9X/S4yS +TPg== X-Gm-Message-State: AOAM533YfHg4RcZ9Sy7pVyaF0IgRiImWo/+hS1jWrTaSQO2DgQnIo+zG hEVbrmtdA9fUtgOGqkWxkUCB4JA8 X-Google-Smtp-Source: ABdhPJxcV+4JDEuv6ktuJtt63J6RMNLmHVGeiD5ZP+Ynou9yQxpmvfchY1mNmzmi3zlqaA3NF/nuBA== X-Received: by 2002:adf:f608:: with SMTP id t8mr9785182wrp.308.1595613226801; Fri, 24 Jul 2020 10:53:46 -0700 (PDT) Received: from [192.168.0.22] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id o3sm618595wru.64.2020.07.24.10.53.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jul 2020 10:53:46 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <0806a844-d93f-ab87-48eb-ad8a6be1ee69@gmail.com> Date: Fri, 24 Jul 2020 18:53:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC][Proposal] Renamed parameters From: rowan.collins@gmail.com (Rowan Tommins) On Fri, 24 Jul 2020 at 12:12, Chris Riley > wrote: The named parameters RFC has been accepted, despite significant objections from maintainers of larger OSS projects Do you have a reference for which "larger OSS projects" you are referring to? I don't remember any being named in the previous discussion, but I may well have missed it. It is likely that the way this will shake out is that some maintainers will accept the additional overhead of including parameter names in their BC guidelines and others will not, this leaves users unsure if they can use the new feature without storing up issues in potentially minor/security releases of the libraries they use. This is not really an ideal situation. To reiterate a point I mentioned a couple of days ago, library authors having to define what constitutes a BC break is definitely not a new thing. The most obvious example in PHP is that we don't have any package visibility enforced by the language, so it is entirely commonplace for a library to have entire classes which are considered implementation details and not for direct use. More subtly, any _behaviour_ change can technically be considered a BC break, and nearly all of those changes are completely unenforceable at the language level; compatibility is _always_ defined by documentation, not just code. I sympathise with people who don't want their library used with named parameters, or want to choose the names more carefully first, but the overhead for most projects is adding one line to a README file saying so. The PHP manual could equally point out the risks of using the feature with third-party code. More pressing a point is that the current implementation breaks object polymorphism. Although seemingly separate, this can be seen as an extension of the previous point: if something isn't designed to be used with named parameters, they should be used with care. It was also discussed in detail before the vote, and is the subject of two entire sections of the RFC: one detailing the selected behaviour https://wiki.php.net/rfc/named_params#parameter_name_changes_during_inheritance and another detailing the rejected alternatives: https://wiki.php.net/rfc/named_params#to_parameter_name_changes_during_inheritance as well as linking to a survey of how other languages approach the problem: https://externals.io/message/109549#109581 > The first would be to implement it as proposed above, this would allow any > parameter to be called by name regardless of the intentions of the author > of the method/function and is closest to the current behaviour. This would be a useful extension of the feature, and with the right syntax (e.g. Benjamin's suggestion of an attribute) could be added in 8.1, just as scalar types and return types where extended with nullable types and void returns in 7.1. The second option would be to use this syntax to make named parameters in userland code explicitly opt in. As others have pointed out, this was explicitly discussed in the run-up to the original RFC, and anyone who wanted opt-in named parameters could have voted No to the version Nikita put to the vote. Assuming all the same people vote, it would need 32 people who voted Yes to the current proposal to change their minds and back this alternative. There are pros and cons to this second approach, on the one hand it reduces the usefulness of the named parameter syntax by requiring changes to old code to enable it (although this could probably be automated fairly easily) The big disadvantage that persuaded me against this approach is that it would mean code cannot support both named parameters and PHP 7.x. Since named parameters are likely to be most useful in shared libraries, and those libraries are likely to support a range of PHP versions, this means users would have to wait for: - the library to drop support for PHP 7 - THEN the library maintainer to add named parameters (likely to be alongside other breaking changes) - THEN the user's application to be compatible with that version of the library While a long lead-time for new features is sometimes necessary, the alternative here doesn't seem bad enough to justify this kind of delay. > I've never written any code in swift, however having quickly read the > documentation I think that my proposal is almost identical to swift > argument labels if the first option is chosen. Swift's argument labels are actually only superficially "named parameters", and come from a completely different background, as I explained here: https://externals.io/message/110004#110025  They don't make a particularly good comparison for PHP. Regards, -- Rowan Tommins [IMSoP]