Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110019 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9738 invoked from network); 5 May 2020 19:58:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 May 2020 19:58:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9BDD180503 for ; Tue, 5 May 2020 11:33:53 -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-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) (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:33:53 -0700 (PDT) Received: by mail-io1-f47.google.com with SMTP id u11so3059819iow.4 for ; Tue, 05 May 2020 11:33:53 -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=tZyqY3Tyu4pnLAY6f/GtLGRbLgYJI5HGHbBa6GH07/8=; b=jCvmYrlDtI6j7braD/dRHyW+x8h4kUuYyHwwH0Sxet1Mu52zeFTafAUiXyio8POs1F 6o5doLxl9dUjIcD/P36RLaUAtUJkuIrB4Xs1wWY48vClh7u9RxJESsY/mO1hKx4jEm6S +OYdgXjEVUfQvz01QgymkKZ/Fce45HCPb6D/xhpM9+nxeJO/KWQRAlzd2RoN00yCngVd sgJT0RfM8e7zlp7kQXJ9Cjhiq9obNaEnYm24IZlMClmyg7Agmd2JFr2sT1cn/Owx7lfr 1RuDV5QjdoExVnG1cjvC+SN6RB/sB8HZI/NaNNwr9c1vFGCi4+CPfCdAPipDEgipnFHy qYlQ== 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=tZyqY3Tyu4pnLAY6f/GtLGRbLgYJI5HGHbBa6GH07/8=; b=O9zJEDkiFIddNMx4JUg3O/Y08i3Z9H05AmzrpoK2WulY4y038o/yeVQDLXIINs7jR4 iWgi7/ZN3NG3Cp7BUtLNZ/uOEEglGCX9sBzWp9jOhIaSrRjn5om+lgZ1D+Yjeadbppwo O0yYLDjKleEEUa6+kMmi50IRlQGzxdO1TnrS0JtjW3wYG9V+bj/AU0JrWZx9Qvqgr+g4 Bv3ul0LR6sLZjasnKoA3+gehHQ4WAsXm6nM0KwerO3/S9fcpOX0DEHdmlHUyyLNQlKJM v2yYZW4KQ27xulRdHjiizbx79P/IFgdFazVxBPEB5Vja8jgus4E3jQNLmpK2Zpc5iMe+ ErSw== X-Gm-Message-State: AGi0Pubs1urSxYtDg3xYupI8qPndogZUcY3E9cj+612ZuWfMZYGduZeH gt8neyqiiekUvQIsHMPhdh91OmGd2/tKCGWPHgw= X-Google-Smtp-Source: APiQypIZp9210o5YAxZJTkjsLnpTH1lObVCzd9ifuJbZWFZjkGlzIkKVW5sMnaRtqZHwKBMGwHn9sEhbfDdgg5a6rC8= X-Received: by 2002:a02:966a:: with SMTP id c97mr4946645jai.106.1588703632877; Tue, 05 May 2020 11:33:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 5 May 2020 20:33:41 +0200 Message-ID: To: Nikita Popov Cc: Theodore Brown , PHP internals Content-Type: multipart/alternative; boundary="000000000000b0edfb05a4eae308" Subject: Re: [PHP-DEV] [RFC] Named arguments From: ocramius@gmail.com (Marco Pivetta) --000000000000b0edfb05a4eae308 Content-Type: text/plain; charset="UTF-8" On Tue, May 5, 2020 at 8:22 PM Nikita Popov wrote: > Builders and withers? Those are not, intrinsically, good code. They are > workarounds for lack of good object initialization support. I should not > have to implement a large amount of builder boilerplate to make the > construction of simple objects safe and ergonomic. We're not talking about > some kind of complex multi-stage construction logic here, but the > construction of what essentially amounts to a value object. > They are not good code, but they are reasonable code, in which each call is an atomic state creation/mutation. Generally, named arguments really change what constitutes a good API and > what doesn't. Things like boolean flags to functions are considered bad > design *because* we do not have named arguments. If I pick out some random > Python API, say subprocess.run()... > You got multiple APIs within a single massive signature: may as well start counting the permutations of possible characters you pass to an endpoint, and what you get in the end is `eval()` :-P > subprocess.run(args, *, stdin=None, input=None, stdout=None, > stderr=None, capture_output=False, shell=False, cwd=None, timeout=None, > check=False, encoding=None, errors=None, text=None, env=None, > universal_newlines=None) > > ... and show that to a PHP developer, they're probably going to tell me > that this is horrible API design. They would, of course, be wrong. It's > reasonable API design, just in a language that supports named arguments. > There are so many ways in which the above fails in different ways (besed on flags) that I can't even start to reason about the resulting chaos. Would rather consume a dozen of differently named (curried) versions of this. Similar to the above: might as well uncurry all the defined API of a program into a single `function (string, array $args)` (which is what the PHP engine or CPUs doe at low-level, obviously). --000000000000b0edfb05a4eae308--