Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125206 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 577961A00BD for ; Sun, 25 Aug 2024 09:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724579530; bh=QmOAHSHJTB5TsWPwisrkgxT/R00b7HZRglUmn0lBFbE=; h=From:Subject:To:References:Date:In-Reply-To:From; b=ISsjI4cfU+To0OTR7U1kRSLvJXuTbb5Q0h099tvQ/YiZAgE9KSCQnMwz9/Zddgi+G A1hywXUGkafOszoyIbInRU6Ot+B/wwX18IT6zVFrIV0pqq4w2qRe9ABH+EaNLHAjhE Qq5opAL1+FBc4y1JG96aOIwstZfPQreIbAVpYlLWuLzbqqXCrQvcwycnt9LJZumfyh 8MBjCygj+AwveJadKjvizt+O/Q2Y7QYzuRLN17iOcpOMDl1jISHvr8DyAdNFhPQErs O9kT9l58oOvWxydkJ/kRU3Fbgsk3xHaiWofippFTGxdK/ScaofJYfKc/F+v2yJzcbn LXUTx+Z3RxE1g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A44E2180042 for ; Sun, 25 Aug 2024 09:52:08 +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=1.5 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_40, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING, HTML_MESSAGE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_SOFTFAIL,STOX_BOUND_090909_B autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from buffalo.birch.relay.mailchannels.net (buffalo.birch.relay.mailchannels.net [23.83.209.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 25 Aug 2024 09:52:07 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 914DF4C668F for ; Sun, 25 Aug 2024 09:50:14 +0000 (UTC) Received: from nl1-ss105.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id F03874C6577 for ; Sun, 25 Aug 2024 09:50:13 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1724579414; a=rsa-sha256; cv=none; b=WS+qsU5MXhDEvheN6grMsS0a/oq+n7NaQYITkSSqHW6rdn2vEJTr5Yondoo6vDo2hVd7i7 fE69C3rF5Tn3oyLgiS8RkrmofCdp9eibnoi0VHWpMGoxdHW90pMV4FdEs8h1ZaP5sLiJri l0U8uhucmoIKxXFSPc8vFTHZdDDgf03sPXUoC8yUXxVI1DEybmQFhaPI3ySl58SdEUun1g ZMQAykresnoG10Pd+Aujh1hr7MSL6SuJUuSBV4PPOPmrp3kAnVpBDV3wZp1ydSnuT9MDOK bwM1G7L6Dq793WNF5geEJtAaHUS+ZhSvjqdqbkjhbCYKGOek5xzHDfmzM1VBUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1724579414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Z53tloTcS+6gKaW3A2VK+YF4+G8kUeCNNWA1xHuu4xA=; b=GNclPwBIdEv0YL79gr+6EHzzwavINr6muODRTA0x9s/yV6fUylTooIvYMFZJFbfvzyzHQa Y24dWUZ+9RNdkW39cImmr3jsJGnxCNvgmH3ZtnEx6bQ53/qfV5JI8iVw7gKp2HWNE54qP9 cKVhZnkFQTIIP10mHD/QHJiU1W6yBaBL/e7KOWJ/JqEk+jZgj+SY2B7yQA3Ezt023g7Hpd NkZ07dHjezuECDw8/tdO9icKRIk2yoOWMEMgEw04CvRhtEyQdNnKOrkLG2BIlyVCLPXPsD KDpQmOTkVbirt8TVV6shIVdXOrzW51qs0BVy7f6SkjaMMauV7yv1iWkkzqnXSw== ARC-Authentication-Results: i=1; rspamd-5549cdcdbf-ktnqx; auth=pass smtp.auth=a2hosting smtp.mailfrom=php-internals_nospam@adviesenzo.nl X-Sender-Id: a2hosting|x-authuser|juliette@adviesenzo.nl X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|juliette@adviesenzo.nl X-MailChannels-Auth-Id: a2hosting X-Shade-Average: 5ad6e05b014baa82_1724579414496_3432380674 X-MC-Loop-Signature: 1724579414496:727525501 X-MC-Ingress-Time: 1724579414496 Received: from nl1-ss105.a2hosting.com (nl1-ss105.a2hosting.com [85.187.142.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.114.99.140 (trex/7.0.2); Sun, 25 Aug 2024 09:50:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=adviesenzo.nl; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Z53tloTcS+6gKaW3A2VK+YF4+G8kUeCNNWA1xHuu4xA=; b=Xo0jI8Wh6AhTY/836jTVR+qOU+ +LLmjUQkaUk1l1nUlGCOGZ/cFPqyn15iBWCYGWVisYDPyrLk2zK+W+06j8zgCtTDWW/2y4WjCy/Co Owcd2KMxYvjHNMI72DkElfzna5jAxMOc4rLPnOBcB/vAFP1KGnmpeMsJ8SCwJwoU5mBM=; Received: from mailnull by nl1-ss105.a2hosting.com with spam-scanner (Exim 4.97.1) (envelope-from ) id 1si9sy-00000007OJZ-0fDe for internals@lists.php.net; Sun, 25 Aug 2024 11:50:12 +0200 X-ImunifyEmail-Filter-Info: QkFZRVNfSEFNIE1JRF9SSFNfTUFUQ0hfRlJPTSBNSU1FX1RS QUNFIFJ DVkRfQ09VTlRfT05FIEZST01fRVFfRU5WRlJPTSBBU04gQVJDX05BIF RPX0ROX0FMTCBSQ1ZEX1ZJQV9TTVRQX0FVVEggRlJPTV9IQVNfRE4gU kNWRF9UTFNfQUxMIFJDUFRfQ09VTlRfT05FIElFX1ZMX1BCTF9BQ0NP VU5UXzAxIFRPX01BVENIX0VOVlJDUFRfQUxMIFZFUklMT0NLX0NCIE1 JTUVfVU5LTk9XTg== X-ImunifyEmail-Filter-Action: no action X-ImunifyEmail-Filter-Score: 0.55 X-ImunifyEmail-Filter-Version: 3.8.5/202408221311 Received: from [31.201.40.213] (port=57967 helo=[192.168.1.16]) by nl1-ss105.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1si9sy-00000007OF0-05fy for internals@lists.php.net; Sun, 25 Aug 2024 11:50:12 +0200 Subject: Re: [PHP-DEV] [RFC] Default expression To: PHP internals References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> Message-ID: <66CAFE36.4080102@adviesenzo.nl> Date: Sun, 25 Aug 2024 11:49:42 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 In-Reply-To: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> Content-Type: multipart/alternative; boundary="------------070507030603050606070905" X-AuthUser: juliette@adviesenzo.nl From: php-internals_nospam@adviesenzo.nl (Juliette Reinders Folmer) This is a multi-part message in MIME format. --------------070507030603050606070905 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit (resending as I accidentally originally send a private reply instead of sending the below to the list) On 24-8-2024 18:49, Bilge 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 Bilge, I like the idea, but see some potential for issues with ambiguity, which I don't see mentioned in the RFC as "solved". Example 1: ```php function foo($paramA, $default = false) {} foo( default: default ); // <= Will this be handled correctly ? ``` Example 2: ```php callme( match($a) { 10 => $a * 10, 20 => $a * 20, default => $a * default, // <= Based on a test in the PR this should work. Could you confirm ? } ); ``` Example 3: ```php switch($a) { case 'foo': return callMe($a, default); // I presume this shouldn't be a problem, but might still be good to have a test for this ? default: return callMe(10, default); // I presume this shouldn't be a problem, but might still be good to have a test for this ? } ``` On that note, might it be an idea to introduce a separate token for the `default` keyword when used as a default expression in a function call to reduce ambiguity ? Smile, Juliette --------------070507030603050606070905 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
(resending as I accidentally originally send a private reply instead of sending the below to the list)

On 24-8-2024 18:49, Bilge 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 Bilge,

I like the idea, but see some potential for issues with ambiguity, which I don't see mentioned in the RFC as "solved".

Example 1:
```php
function foo($paramA, $default = false) {}
foo( default: default ); // <= Will this be handled correctly ?
```

Example 2:
```php
callme(
    match($a) {
        10 => $a * 10,
        20 => $a * 20,
        default => $a * default, // <= Based on a test in the PR this should work. Could you confirm ?
    }
);
```

Example 3:
```php
switch($a) {
    case 'foo':
        return callMe($a, default); // I presume this shouldn't be a problem, but might still be good to have a test for this ?
    default:         
        return callMe(10, default); // I presume this shouldn't be a problem, but might still be good to have a test for this ?
}
```

On that note, might it be an idea to introduce a separate token for the `default` keyword when used as a default expression in a function call to reduce ambiguity ?

Smile,
Juliette

--------------070507030603050606070905--