Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110847 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 37055 invoked from network); 6 Jul 2020 16:13:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2020 16:13:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6402E1804CE for ; Mon, 6 Jul 2020 08:04:17 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, 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-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.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 ; Mon, 6 Jul 2020 08:04:16 -0700 (PDT) Received: by mail-lf1-f41.google.com with SMTP id y18so22755940lfh.11 for ; Mon, 06 Jul 2020 08:04:16 -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; bh=gpBdeT5NB4HvmCGzjW4nSr9/mmYthkp9VZy6TOiptaA=; b=BzAeIKPVWhqVcZIfqGggQ0VT9zro/evI7sd8PtSGgWAsXwnhYaWlqvJZ1UT9IJym9H OIaRWG319abXqV1V5fWmgoZc0v+YGvByu7Ntrmk1qzkj5GrZ8gWvFR+Mq7WodhCod79m AxH4W3IJesVJvkJxaCBkPsuy6R0jWFZ96HzoCaLybtKi+fbCzOzIE5h/Ivn2Nm56nvNg 4p8cMS96f02uN+tQav8+7SChJ3SBcFe50/EAHlB/t0veugOh7HzGfs5otgB0DXGxBFib UX5bekq/U+uBZklYflTo1ZMqoxX9WEpq4U+PQwZWZxSrf5d5PqAZtIEAJtEox7KuVI05 7RPw== 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; bh=gpBdeT5NB4HvmCGzjW4nSr9/mmYthkp9VZy6TOiptaA=; b=fjFig+BtBeQFV+EwiklQ2S9IuEQwFqTTTuGU/ulq/jP3dBGtrEiXX0A1HdQPD8gG7s JokLob3EJHMR95LPBhUG42ICdzBg9Dw+GamCwDyx27eja5Wo68MeP6HbnJ329oxd8CWA 37zBhl8QHspnFWLjmkpBhu8gYW3RA45ATxd12nxmeNkyx74kXdQkn4H5Fr+sc+NcC1YN JH2F1ac82ARrz24KO4Xo6VV/q0D4zWTa0MAs02Tg+MRse3JRiBKERCFFxf/Cz0c3eM9G jSq2n8ZQh3CzFdz4Xb5mHLnC1ODhWcM4APKpRKYtL35U7NSRs8zrmlDbqq3zx5Ums+JZ KZDA== X-Gm-Message-State: AOAM530uCFWF5nQWv5E5BYw6Izqaxi13IwbZhq2E4kcmwDehcGFOaJuk GKzS39tPY8dI/LDVRfJVjQ+7jXy7sTl+guY/Qd15DW1O X-Google-Smtp-Source: ABdhPJxvGctYs2tzYpCE7K+KH5nKi8eZ7azK/34AnNskw5r9DxzhN0E6V/XdH+2sVrzgv8/7AHxEFuv5XOSpxQjtXUA= X-Received: by 2002:a19:bed7:: with SMTP id o206mr31076742lff.81.1594047853400; Mon, 06 Jul 2020 08:04:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 6 Jul 2020 17:03:57 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000000e942305a9c730c3" Subject: Re: [RFC] Named arguments From: nikita.ppv@gmail.com (Nikita Popov) --0000000000000e942305a9c730c3 Content-Type: text/plain; charset="UTF-8" On Fri, Jul 3, 2020 at 4:35 PM Nikita Popov wrote: > On Mon, Jun 29, 2020 at 5:13 PM Nikita Popov wrote: > >> On Tue, Jun 23, 2020 at 12:10 PM Nikita Popov >> wrote: >> >>> On Tue, May 5, 2020 at 3:51 PM Nikita Popov >>> wrote: >>> >>>> Hi internals, >>>> >>>> I've recently started a thread on resurrecting the named arguments >>>> proposal (https://externals.io/message/109549), as this has come up >>>> tangentially in some recent discussions around attributes and around object >>>> ergonomics. >>>> >>>> I've now updated the old proposal on this topic, and moved it back >>>> under discussion: https://wiki.php.net/rfc/named_params >>>> >>>> Relative to the last time I've proposed this around PHP 5.6 times, I >>>> think we're technically in a much better spot now when it comes to the >>>> support for internal functions, thanks to the stubs work. >>>> >>>> I think the recent acceptance of the attributes proposal also makes >>>> this a good time to bring it up again, as phpdoc annotations have >>>> historically had support for named arguments, and this will make migration >>>> to the language-provided attributes smoother. >>>> >>>> Regards, >>>> Nikita >>>> >>> >>> As we're moving in on feature freeze, I plan to move this proposal >>> forward soonishly. >>> >>> I have update the RFC to drop the syntax as an open question (I haven't >>> seen much opposition to the use of ":"), and to describe the possible >>> alternative LSP behavior at >>> https://wiki.php.net/rfc/named_params#parameter_name_changes_during_inheritance >>> . >>> >>> While writing this down and implementing it, I found that this has more >>> odd edge-cases than anticipated. Overall, I'm not sold that this approach >>> is worth it. It sounds nice on paper, but I strongly suspect that it solves >>> a problem that does not existing in practice, and will force us to keep >>> this patch-over mechanism indefinitely, while the real solution would have >>> been to fix the limited amount of code that is in the intersection of >>> "renames parameters" and "is actually invoked with named arguments". >>> >> >> Just as another reminder: I plan to put this to voting by the end of the >> week. >> >> I've also updated the RFC to make the LSP behavior a secondary vote. I'm >> not convinced this is a good idea myself, but some others seemed to prefer >> this approach. >> > > I've made two additional changes to the proposal: > > 1. Explicitly mentioned attribute support in > https://wiki.php.net/rfc/named_params#attributes1, and added it to the > implementation (oops). ReflectionAttribute::getArguments() will also return > named arguments to the attribute, and ReflectionAttribute::newInstance() > will behave in the intuitive manner. > > 2. Added some information on internal APIs in > https://wiki.php.net/rfc/named_params#internal_apis. The tl;dr is that > named params are pretty much completely transparent for normal extensions, > but there are some additional APIs if for example you want to perform a > named param call from an extension. > > > In relation to this, I'm also considering to change the semantics of > call_user_func_array() to treat array elements with string keys as named > parameters, rather than simply ignoring keys. The motivation here is not so > much call_user_func_array() in particular, but various other APIs that do > the same thing, such as ReflectionMethod::invokeArgs(), which should all > behave consistently. > > Relatedly, I'm wondering if something like this should be allowed: > > call_user_func('strlen', str: 'foo'); > > I'm leaning towards "yes", in which case call_user_func_array() should be > also be treated consistently. > Okay, I think I've now done the last set of updates to this RFC: * call_user_func(), call_user_func_array(), ReflectionClass::newInstance(), ..., now support named parameters. * I've moved the alternative LSP behavior into the alternatives section and don't plan to pursue it in this RFC. After thinking it over, I think this is a nice migration hack, but not something that should be part of the language long term. Regards, Nikita --0000000000000e942305a9c730c3--