Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125272 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 0CCC21A00BD for ; Mon, 26 Aug 2024 14:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724682167; bh=LDmrwiKdLQCvE6fl15ks0OuDiNDVqWlktkZ23a+PNes=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=KP8xqMBBrEKzGTztgYNQk9/npRhLNZD/D4SNXAyKExYgyH3/d4fe45bYPBmT8gL+2 /K3nJyIWXMLSewLtrFArZ23HLac5CtBLCpKKkBrympyBwwNmks/d6RJsFCh4ZcZjCq 2mteSgCXJ694NnDofu2E28uDCr0pkm89ttazu+nVP3mI3beBfaZTaF+yTsrfoEDnz5 /cr6xLSVGfYWFicQZlHR32fpWxw8S1Vl05AoUvytyNchf8NLzGy14VwCByAjGuhpgq P6oMfLS4SCTcW4fmSLk8OOt7H7p2ASzDXLUaVjGmBLDMkiN8N08563Bf96UUVjZThX o+QroMFu4u7aw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4DC7318003E for ; Mon, 26 Aug 2024 14:22:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, HTML_MESSAGE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail1.25mail.st (mail1.25mail.st [206.123.115.54]) (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 ; Mon, 26 Aug 2024 14:22:45 +0000 (UTC) Received: from smtpclient.apple (unknown [49.48.221.224]) by mail1.25mail.st (Postfix) with ESMTPSA id 1CFEF60401; Mon, 26 Aug 2024 14:20:45 +0000 (UTC) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_7BA93336-FA0A-41DF-AFF8-EBABDC5F598E" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: [PHP-DEV] [RFC] Default expression Date: Mon, 26 Aug 2024 21:20:33 +0700 In-Reply-To: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> Cc: "internals@lists.php.net" To: Bilge References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> X-Mailer: Apple Mail (2.3776.700.51) From: php-lists@koalephant.com (Stephen Reay) --Apple-Mail=_7BA93336-FA0A-41DF-AFF8-EBABDC5F598E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On 24 Aug 2024, at 23:49, Bilge wrote: >=20 > Hi gang, >=20 > New RFC just dropped: https://wiki.php.net/rfc/default_expression. I = think some of you might enjoy this one. Hit me with any feedback. >=20 > This one already comes complete with working implementation that I've = been cooking for a little while. Considering I don't know C or PHP = internals, one might think implementing this feature would be = prohibitively difficult, but considering the amount of help and guidance = I received from Ilija, Bob and others, it would be truer to say it would = have been more difficult to fail! Huge thanks to them. >=20 > Cheers, > Bilge >=20 Hi, I noticed someone talking about the various ways the `default` keyword = could be used in an expression including in match() and looking in the = RFC examples I see it is listed, so I think it's useful to clarify here. = I haven't followed the entire thread in depth so I apologise if this was = already answered, but I haven't noticed it being mentioned/clarified = yet. Can you clarify in the following, is the arm comparing against match's = default or the parameter's default? Or to put it another way, in the = second call, If `$arg` is 2, will the match error out due to an = unmatched subject, or will it pass 1 to `F`? function F(int $foo =3D 1) {} F(match(default) { default =3D> default }); F(match($arg) { 'a' =3D> 0, default =3D> default }); Cheers Stephen=20= --Apple-Mail=_7BA93336-FA0A-41DF-AFF8-EBABDC5F598E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

On 24 Aug 2024, at 23:49, Bilge = <bilge@scriptfusion.com> wrote:

Hi gang,

New RFC = just dropped: https://wiki.php.net/rfc/default_expression. I think some = of you might enjoy this one. Hit me with any feedback.

This one = already comes complete with working implementation that I've been = cooking for a little while. Considering I don't know C or PHP internals, = one might think implementing this feature would be prohibitively = difficult, but considering the amount of help and guidance I received = from Ilija, Bob and others, it would be truer to say it would have = been more difficult to fail! Huge thanks to = them.

Cheers,
Bilge


Hi,

I noticed someone talking about the = various ways the `default` keyword could be used in an expression = including in match() and looking in the RFC examples I see it is listed, = so I think it's useful to clarify here. I haven't followed the entire = thread in depth so I apologise if this was already answered, but I = haven't noticed it being mentioned/clarified = yet.

Can you clarify in the = following, is the arm comparing against match's default or the = parameter's default? Or to put it another way, in the second call, If = `$arg` is 2, will the match error out due to an unmatched subject, or = will it pass 1 to `F`?


function =
F(int $foo =3D 1) {}

F(match(default) { default = =3D> default = });

F(match($arg) { 'a' =
=3D> 0, default =3D> default });

Cheers

Stephen 
= --Apple-Mail=_7BA93336-FA0A-41DF-AFF8-EBABDC5F598E--