Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110020 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12914 invoked from network); 5 May 2020 20:03:14 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 May 2020 20:03:14 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7A58D1804E3 for ; Tue, 5 May 2020 11:38:14 -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-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) (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 ; Tue, 5 May 2020 11:38:14 -0700 (PDT) Received: by mail-io1-f43.google.com with SMTP id f3so3477791ioj.1 for ; Tue, 05 May 2020 11:38:14 -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=nu863I9Wvp6EfXzZ9NM6o8It4EqMX/LXMbX2C1AsLRo=; b=YLKSz5mG8aBYWH4F+q0FBVWffWVAj94zQauBPEtpyMC34GncDiwUrp9D2+8yHVAQBU QcSzR9lFxsWXX+yex4CV8CyLfa4Y4n1bZ+/P4o50KS2pWm8PGT556iNlcB6miKL9Y2Xe fky28RKwg639ol0SHEGWTqKGAYtNTzJ2hj+A830fqRT7SmnTD5yrwkkB65dzycJGMNcI Oz3ffEQXNesunzn345bJ/ej+njgIOxBcqi9N4GQ9To2B/4pN80PUqJ3zW/6ufN9uTLWH V0FmRVuGM7BzakvVbrk/SkZa9h8gO2/UKkmR6+NKrYousvEp+gxcP9YDmVmJf3P67QSc /O4Q== 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=nu863I9Wvp6EfXzZ9NM6o8It4EqMX/LXMbX2C1AsLRo=; b=QLObAinXq7+DaxzmQzmPU3p7rSkgUH54Fn0OEdrbmqoa0iSTKqIu0utNEDKZqCsykm MzJUddoY2HcsPFmXvIwwwL1SR36CfXOi8Tt1m+POLn8miZSZ8nl2H1DsVLruMHwJcwwL hr2mch6YZeJzCwWp8wi/zxF05xXq90Tyh+nqOomTvInRmIgtVj5WbpfEeo4pKdhnL/Wr Xlk8KrJimjZOK4VZqPenCM1++IxQKRVpRCe9z259I9KLY8w2GYmDA19Q6Ffmu08RGcS8 OlshZYGBsPivzVZNGkl4zQ81ZNDQCWao9v4yAf35pKuPMkLLqVNQL8PWyjIaDS5GZU/v LnJA== X-Gm-Message-State: AGi0PuZ/TdHn8N/prtDObEKFyjqP2EiZwigBXoM49wFpKcLgqzbDhXfy lJ6W1sC2MISVDb1Iwg++uvr0n59AEj8t0ONtGXbECx3q X-Google-Smtp-Source: APiQypLAKDYPBVH114NQdoLbyVGRd+MUp1uD8EEgObpodhYd8pInx2Ym+sTMJ1lRYtO/a5q3P+EHwJl6hAHnSoWeEPs= X-Received: by 2002:a6b:3bcb:: with SMTP id i194mr4765439ioa.120.1588703891343; Tue, 05 May 2020 11:38:11 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 5 May 2020 20:37:44 +0200 Message-ID: To: Nikita Popov Cc: Marco Pivetta , Theodore Brown , PHP internals Content-Type: multipart/alternative; boundary="00000000000018d28005a4eaf3c8" Subject: Re: [PHP-DEV] [RFC] Named arguments From: kjarli@gmail.com (Lynn) --00000000000018d28005a4eaf3c8 Content-Type: text/plain; charset="UTF-8" On Tue, May 5, 2020 at 8:22 PM Nikita Popov wrote: > Anyway. Your point that named arguments expand the API surface has been > acknowledged. I don't think this issue is really avoidable, it's a rather > fundamental trade-off of named parameters. I do think you're a bit quick in > jumping to conclusions. It's not like this problem doesn't exist in > (nearly) every language supporting named arguments. > > There are some things we can do to mitigate this though. One that we > recently discussed in chat is to allow methods to change parameters during > inheritance, and allow named arguments to refer to the parameter names of > the parent method as well. Renaming parameters in a way that causes > conflicts (same parameter name at different position) would cause an LSP > error. I'm not entirely convinced this is the best approach yet, but this > does address some concerns (including the "interface extraction" concern > you mention on reddit). > > Another is to allow specifying the public parameter name and the private > parameter variable name separately, as is possible in Swift. This would > allow changing "parameter" names arbitrarily, without breaking the public > API. This would be a pretty direct counter to your concern, but I'm not > really sure that your concern is important enough to warrant the additional > weight in language complexity. I've never used Swift myself, so maybe this > is actually awesome and I just don't know it. > > Regards, > Nikita > Hi, If I understand this correctly, something like this could be done? ``` // current version, argument name = "firstArgument" function example(string $firstArgument) {} // name changes, bc can be kept, argument name = "firstArgument" and "argument" function example(string firstArgument: $argument) {} ``` This would make it possible to keep backwards compatibility, and perhaps even trigger a notice when called with the old name? Regards, Lynn --00000000000018d28005a4eaf3c8--