Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125243 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 A8A2C1A00BD for ; Sun, 25 Aug 2024 21:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724622821; bh=I+uF5g4uXYCK7o39mLcPIjL7ToDNhNqNYXZcnWLctCA=; h=Date:Subject:To:References:From:In-Reply-To:From; b=EriptlPMG0+eofmJbSCCdc7DC3KBk7zitwDPfotvljU3Qo5QG+HCo27vMnxduDAux /bCsvcjk4aHb6fjmvYEOhzJ6rZ9SCnjOZwmDpvlZNpFvb2vPPt+Pdl3PFrJVIqwrB7 bMl9dTCok8j7hZRZMwZKhnwMLhXI16jarWXbfjBjGWL7jowSjJaXDmtzD1039JEV1Q 7iP85vrDMHQdxRaA64e7OP5ohf0FK8amsx0dh6tN41yGsknd2AxYqOd1KhAP4iESrm mUYmVKJzr53OKPLzRJy3YLlZIv8SBw4Fxe2aAml7mQbOzDi/sjxJNcQ4swoUsxzv1i YiVlSMLYJnhPA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 08847180042 for ; Sun, 25 Aug 2024 21:53:41 +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,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 21:53:40 +0000 (UTC) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42ab880b73eso32840955e9.0 for ; Sun, 25 Aug 2024 14:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1724622707; x=1725227507; darn=lists.php.net; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=V9V8bViYIRs+ifWexY/ZmSJeHwN8ZxDxvv+ddfjZ0X0=; b=YijRTcPOk4LDvm7NT+8yte9tFk+dpKQv+pkEDJTKQTzQfVlOJuuyFPn+uXQQG+e071 jZF689zrISdDeJlfz9i3HasVpVZ/MYJ/fsVX+tZQLQAQtLn3qYGcUBON9N2eeNS+Xjxg +3I8ZOyt9Ig9xlwnRoPyzVNbctfe8uDos1szkHKSXGxOcJW4OGNn6/MHwxLKxNBGOQ6G 1f1wl/CnId/excbbfkqjxNjVmFc0CYb/JhA9K1P12YN+U4eaqeZnkqtModvRJ6I2Q8dz DCTubkA2sqPXw+cBdm6KUuejenFoaFjABmFsw61IHIVY1V1EwmkOYuXpW90zVIEHeVg8 tCwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724622707; x=1725227507; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=V9V8bViYIRs+ifWexY/ZmSJeHwN8ZxDxvv+ddfjZ0X0=; b=ablFsiN7/LgFqbbqfqooy0RIf07l/HUGQyoEQuHEVz3fwszDnzb2CsPhayq/PNWZeQ G9a/CB6NMqk4Qike5CG0UeINu7oZpF8Szjo09vZCrBu1sOB91P4fI9ltwzJqlW+5wh3Y nl5Mf+ALIu8ZdxH408hFEHnuyzmdWupVoBzZIHgWFvuhe+VBx8g4mf+VbxoMZEhQfHSA MMofGuBFmW3qBtxBhDVWCJfxWU8VNZSBxwMyVmJc0avHfBOWACtzkQ0LHPPULulDkr+/ E85jco/Nn8+YVzSGMmDetbLhqdh08envlz94OVU/j8FvzxjcGeNLmRUYJQrqa+OaPkGb Velw== X-Gm-Message-State: AOJu0YydwYlxvXa0vovRIrF4Y3tA5KJOBmjDsMWZ2sboP5Y2Xba0aLRp qHiOGaeGV7df00Sqhx3A1PqX4AgX/0oAm+uAhOiaOcTE0x9ap61fQjwcJ2uv85cQ2g5Cc496oeo d X-Google-Smtp-Source: AGHT+IGmWmgAKsQUWUez0A5qM8McaQPIq40xIGk7Q6qIBKhpA8PNUSOLQ8HkRBqlJ2xvo39qYwkT3Q== X-Received: by 2002:a05:600c:348e:b0:428:17b6:bcf1 with SMTP id 5b1f17b1804b1-42acc8e143amr61958535e9.22.1724622706231; Sun, 25 Aug 2024 14:51:46 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bf09:5101:493f:458f:8145:4167? ([2a01:4b00:bf09:5101:493f:458f:8145:4167]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3730815c0f0sm9275487f8f.51.2024.08.25.14.51.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 14:51:45 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------DcFbKzJew21gjcjbyQJi6ILX" Message-ID: <928d6c8c-c969-4d55-82ff-5da8fc3d3035@scriptfusion.com> Date: Sun, 25 Aug 2024 22:51:45 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Default expression To: internals@lists.php.net References: <0c8ed5d6-5507-4c41-8d7f-05d14ba8aa4c@scriptfusion.com> <0cfd3a28-3cb0-4478-85fb-cf086d8e5c66@app.fastmail.com> <3e0d031e-256f-47cd-9a2b-dcdc760f5498@scriptfusion.com> <6afeb23a-867f-457d-9b13-fdf5af02c31e@scriptfusion.com> Content-Language: en-GB In-Reply-To: From: bilge@scriptfusion.com (Bilge) This is a multi-part message in MIME format. --------------DcFbKzJew21gjcjbyQJi6ILX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 25/08/2024 22:09, Rowan Tommins [IMSoP] wrote: > > On 25 August 2024 21:00:03 BST, Bilge wrote: >> class Suspension { >>     /** >>      * @param int $delay Specifies the delay in milliseconds. >>      */ >>     public function suspend(int $delay = 1_000) { >>         var_dump($delay); >>     } >> } >> >> class MySuspension extends Suspension { >>     /** >>      * @param float|int|null $delay Specifies the delay in seconds. >>      */ >>     public function suspend(float|int|null $delay = null) { >>         parent::suspend((int)(($delay ?? 0) * 1000) ?: default); >>     } >> } >> >> new MySuspension()->suspend(2.2345); // int(2234) >> >> Not only have I demonstrated the need to use multiplication or division to change the scale, but also the need to cast. > Possibly something got lost as you redrafted the example, because as you've written it, neither the multiplication nor the cast are applied to the value looked up by "default". The parameter reduces to "(expression) ?: default", which I've already agreed is useful. Great! I'm glad we're finally getting to this, because I think this is what you, and everyone advocating for a restricted grammar, is actually missing. You think you've caught me in some kind of "gotcha" moment, but fair warning, I'm about to play my Uno Reverse card. What you're saying is that, somehow, even though the default must be constrained to a restricted subset of permissible grammars, it is still acceptable to have unrestricted expressions in the other operands. So, in this example, somehow `expr ?: default` is OK.This is simply impossible and would cause catastrophic shift/reduce conflicts in the grammar. If `default` is to live in a restricted subset of allowed expression grammars, then it can only recurse with those same restrictions, meaning /both/ operands of any operators are so restricted. Ergo I do not need to demonstrate the usefulness of applying other operators /directly/ to `default`, merely including them /somewhere/ in the expression is sufficient to demonstrate they are useful because at that point we're back to recursing the general expression grammar (free of any restrictions), unless and until you're willing to concede those particular operators I've just demonstrated the useful application for should be entered into the arbitrarily-selected restricted subset of grammars allowed to apply to `default`. If you believe I am incorrect about this, I encourage you to submit a (working) Bison patch to demonstrate how a restricted expression grammar subset can still recurse with the unrestricted superset, then we can start having this discussion more seriously. Cheers, Bilge --------------DcFbKzJew21gjcjbyQJi6ILX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 25/08/2024 22:09, Rowan Tommins [IMSoP] wrote:

On 25 August 2024 21:00:03 BST, Bilge <bilge@scriptfusion.com> wrote:
class Suspension {
    /**
     * @param int $delay Specifies the delay in milliseconds.
     */
    public function suspend(int $delay = 1_000) {
        var_dump($delay);
    }
}

class MySuspension extends Suspension {
    /**
     * @param float|int|null $delay Specifies the delay in seconds.
     */
    public function suspend(float|int|null $delay = null) {
        parent::suspend((int)(($delay ?? 0) * 1000) ?: default);
    }
}

new MySuspension()->suspend(2.2345); // int(2234)

Not only have I demonstrated the need to use multiplication or division to change the scale, but also the need to cast.
Possibly something got lost as you redrafted the example, because as you've written it, neither the multiplication nor the cast are applied to the value looked up by "default". The parameter reduces to "(expression) ?: default", which I've already agreed is useful.

Great! I'm glad we're finally getting to this, because I think this is what you, and everyone advocating for a restricted grammar, is actually missing. You think you've caught me in some kind of "gotcha" moment, but fair warning, I'm about to play my Uno Reverse card.

What you're saying is that, somehow, even though the default must be constrained to a restricted subset of permissible grammars, it is still acceptable to have unrestricted expressions in the other operands. So, in this example, somehow `expr ?: default` is OK. This is simply impossible and would cause catastrophic shift/reduce conflicts in the grammar. If `default` is to live in a restricted subset of allowed expression grammars, then it can only recurse with those same restrictions, meaning both operands of any operators are so restricted. Ergo I do not need to demonstrate the usefulness of applying other operators directly to `default`, merely including them somewhere in the expression is sufficient to demonstrate they are useful because at that point we're back to recursing the general expression grammar (free of any restrictions), unless and until you're willing to concede those particular operators I've just demonstrated the useful application for should be entered into the arbitrarily-selected restricted subset of grammars allowed to apply to `default`.

If you believe I am incorrect about this, I encourage you to submit a (working) Bison patch to demonstrate how a restricted expression grammar subset can still recurse with the unrestricted superset, then we can start having this discussion more seriously.

Cheers, Bilge

--------------DcFbKzJew21gjcjbyQJi6ILX--