Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112962 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39660 invoked from network); 22 Jan 2021 00:00:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jan 2021 00:00:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AF4011804AA for ; Thu, 21 Jan 2021 15:40:27 -0800 (PST) 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 21 Jan 2021 15:40:26 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 760BC5C023E for ; Thu, 21 Jan 2021 18:40:26 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute4.internal (MEProxy); Thu, 21 Jan 2021 18:40:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Rk2ADE F9uVoq+VQDwKGV1euG/uKAKyGBh4ptG0k7FTM=; b=eRS1LojjD8kADbj6OW1kqG ORn0qqkn6LD9ZsJwQCkSCEFoyPg06YgmpW0YtSXmFrpZpq9fE0xJs8bbjKlX2Qfc uBmXbkvOPffRdBY6SYRS4SjjfwWnj4VAvD3rLtHTtvhKaVa+cB7PA14xY5KzIKCm SpKkGdo99pNp26j/08cc1aoD5oy8GmF3EIHVtaNwWo4tzOmvAxPH69P/nXAW44zJ ZE8HKG2QkIRtNfS8obtbRP9tFtPdJ7mWpBiIBiylK6vtEBjSdNrbKcH+R6Novd2Z ath6/bA3pa6MPWEujCGTsOMtIlrcPKDTkTL3IOqYZ82x9mNdthQVHCLSfuKAsKmg == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehgdduvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 1DA0D14200A2; Thu, 21 Jan 2021 18:40:26 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-78-g36b56e8-fm-20210120.001-g36b56e88 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <766fb62e-9413-4472-89be-6557a45c64c8@Spark> <19bd9792-b966-4b8e-af24-a8e4399f7a2f@www.fastmail.com> Date: Thu, 21 Jan 2021 17:40:05 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] Null Coalescing Assignment in Method Signature From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jan 21, 2021, at 4:37 PM, Sara Golemon wrote: > On Thu, Jan 21, 2021 at 3:29 PM Larry Garfield > wrote: > > > > I'm unclear why you'd allow null at all then. > > If you want $bar to be optional, and to be an empty array if not > specified, then just do: > > > > function foo(array $bar = []) { ... } > > > > At that point, the only thing adding ?array does is allow you to > explicitly pass null, > > presumably because it has some meaning to your function. > > If you don't want that, don't allow it. > > > > Smells a little like it's verging on the `default` proposal that was > brought up awhile ago... > > function foo(int $a, array $b = [], string $c = '') { ... } > foo(123, default, "bar"); > > In this case, foo() never wants `null` as a valid value, but neither does > the caller actually want anything different from the default. > > Allowing a null-coalescish sort of initializer is another potential way to > solve this problem, and I'm not here to say I endorse any of them, but > maybe that's the intent. > > -Sara I'd argue that named arguments have rendered the main argument for `default` null and void. (How many puns can he squeeze into one sentence, Bob?) --Larry Garfield