Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109555 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10955 invoked from network); 7 Apr 2020 16:44:50 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Apr 2020 16:44:50 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F3D2D180510 for ; Tue, 7 Apr 2020 08:12:47 -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.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-f41.google.com (mail-io1-f41.google.com [209.85.166.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 ; Tue, 7 Apr 2020 08:12:47 -0700 (PDT) Received: by mail-io1-f41.google.com with SMTP id m4so3716503ioq.6 for ; Tue, 07 Apr 2020 08:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datadoghq.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5UF2FCRR85QvYcQb01nkIoEXI2tvjx0IVX0jLF/MVDQ=; b=NZVYrOhacZdXrY8lLEoWUfvxL0oK/Cl3GXkQBFpZQaOMdorCmhC0mo0pnOVAtckXH2 /i31TxInaryStpx4t/847MB38U4lhbVmh9KYUbmgscT5mira8EQn30GZUndh8BnvZA8D 9U3jwERD6/kxXy2U/ojjCg3zt/9vTmoPajn6U= 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=5UF2FCRR85QvYcQb01nkIoEXI2tvjx0IVX0jLF/MVDQ=; b=Ela59MVZPRHycm4yRug935l6NsfXHmefZTYT06rHsKd6vrAPUq5eMSZnqjKdCEMWfy ua2Aq4agERiPOiSNo66IXAZRPQNLEyJpKD39M+lFi9vCdywdqDTh9WhNwa5PidHfFima EFpBSONfJViGiVyxNE2f4RtRhRkRAdvKqbMrCuH1o5817sY3nk2Ie0yP9ktzljMfdnGf I5bW+W1uGVBoW8qu1QYaX+LSJKDTmq90r5kfNdbxZZf2zbTkrcNNAhbKwEaZyBi+wET5 8zbcEueO1TCimhlPjdWRypxsZ6jKi4dEiQdmpLVTHOFj+yTtf0XpyeOAlamf0w90+3ld oZLg== X-Gm-Message-State: AGi0PuZEFWwMtb/5X+1nye+bcPOCnP27Q0nCIRfp1JpshgdOQ7l3jvsU h6WFVeC44aL4UxWVkcpUY6sZJyhBgOFF1gNv4rZqgQ== X-Google-Smtp-Source: APiQypKyqK2vBLb78UtwDQCWYAzBwquATz8sxy0mFM+BPluVvMOo9/8aqUmw74h6HgAIxosMBQ0m4GMM6DhH6Dsf53I= X-Received: by 2002:a02:3f49:: with SMTP id c9mr2499830jaf.10.1586272363343; Tue, 07 Apr 2020 08:12:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Reply-To: Levi Morrison Date: Tue, 7 Apr 2020 09:12:31 -0600 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Resurrecting named parameters From: internals@lists.php.net ("Levi Morrison via internals") On Tue, Apr 7, 2020 at 6:45 AM Nikita Popov wrote: > > ## LSP checks for parameter names > > Parameter names currently have no particular significance in PHP, only > their position in the signature is important. If named parameters are > introduced (in a way that does not require opt-in at the declaration-site), > then parameter names become significant. This means that changing a > parameter name during inheritance constitutes an LSP violation (for > non-constructor methods). I would prefer to emit a low severity diagnostic if the parameter names do not match during inheritance, specifically noting that named parameter calls may not work as expected on such methods, rather than emitting a diagnostic when named parameters get used. If we decide to do it at named parameter usage as proposed, I would want a stronger error than simply a diagnostic: the user is directly hitting a case where we have very reasonable doubt that the code is doing what was intended. > > ## Internal functions > > The larger problem is that internal functions don't have a well-defined > concept of parameter default value. Parameter defaults are implicit in C > code, and sometimes based on argument count checks. When named parameters > are involved, one generally cannot assume that if a later (optional) > parameter is passed, all earlier (optional) parameters are passed as well. I know that if we can make parameter defaults in Reflection that some people would consider that reason enough to vote yes on this proposal. It's always annoying with Internal and User functions have differences. I am okay with a heavier cost to named parameters in general. It's a new feature, and generally a _convenience_ one. ----- I am a bit worried about variadics having named parameters in them. I remember encountering code that assumes that `...$a` is a packed array. Is that assumption always correct today?