Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125233 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 220E41A00BD for ; Sun, 25 Aug 2024 20:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724616121; bh=615S96Lg/f+zpgDBH0p7WPO6cFmo51uNsoTPUK6K5BY=; h=Date:Subject:To:References:From:In-Reply-To:From; b=n8FLBf8lBqZQ6NBBq79zR718fj88TOQpmau3W5BOPVQ8lBbTq/WlIY3aE885akdBH VyrNcyoB3V2te9tp4pXhy1PoHRZrEZOHx316bTZADuiGBt48l2Vr+Nhp0Zh6o08Rw/ wpX143+bp0RZT1C0DfZViwynnylIAzFKTXPEF6KLC5VTUBCZaaN20wF17Bs/0jneHX QdPShrQmsFKI5likBBsUyg4mxCD7lVYs9Uki5XDTfNqaIcUE26tTLeCGnUSWSef6fC 1KDt/+LZeeWXlhL+edP+6AnHwN86k5VbTJFUqWd04qPl0IxLU5eWyfLU96fYUoP98K Wl7VST2MQaJvA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 47E4918007F for ; Sun, 25 Aug 2024 20:02:00 +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,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-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 20:01:59 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-371c5187198so2106375f8f.3 for ; Sun, 25 Aug 2024 13:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1724616006; x=1725220806; darn=lists.php.net; h=content-transfer-encoding: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=hFVYAY43/PmfWwTQG4kn1PZnlz7MyurfECHb7Ef6cZs=; b=gFJTzlU5A5K6kaZ/LoKl/yCcMqHf/p8/yPfrmS2TBrFONLP9asRAfUw4BxoGKqxnFJ crqurbx08gV8B/f7SnPreMxTMGGHzcCoZKJop3e/SSmRjyeiBGI8rwVXkMoXN9jj3VVj /HIqR2LQoIGFa+XxdY79k0koA/S3E8GXRfvgLaKoKfGdrJI67qil595FvyOefI+zfenb tRtyQ5SwncZXK/voCN+YlyimAqf25h1u3RvzGUkBzUfTUE3V+JexGNi4Q/VcJSsUVw9F hk9Tm9tFl7lAw12Z+9O0doa2HWvTYYO23pSRyLhocmUWaIvsNu8tjNRJAkyXB/BSBW9/ FOsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724616006; x=1725220806; h=content-transfer-encoding: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=hFVYAY43/PmfWwTQG4kn1PZnlz7MyurfECHb7Ef6cZs=; b=rCfNYSb9809iFiUfxRD/m1FWxta2h6JlRnNRcAtYyHg9UBQ6jHFbB525wtrBmnD66r 5oBZlBl+5NJ2Hb+fQ5zJT1PwyzfKvswE6N52Gt7C7Q8PVgEdTO5I2Vpv1Nmu9gy1HOGN wzh6prEI25tedtD/K4A21VA6sVHjlzmZLr+w37FZ6Zwd55F8AJKpAllsQeI6ZZt2Ux37 uY3Leu9UW8f7XLZAwSAOZLw0wvRZ+yYX1EeWCEAXPfNxBhp0PxABanIE0JV3AHeDkEh6 028TNWb2tXoEojdyOn3DwUIrqO0RmmjUVNeSTH0SR1fcJOhCBRsXeoI1qDt8Z1Z0m+/5 Hvhg== X-Gm-Message-State: AOJu0YytY5xMtvKxQI+jXyMF1FXSD6icHbaoYNq5T1QzsvrN4/9oTSFv 7B40PT3W8t1tZfWodCcU9+OI+AZ7omhCgy+jF7CYMf2pnXqnuZHEfKkdjDmMAtZYGeDtlZpN0aq 6 X-Google-Smtp-Source: AGHT+IEnEnzloRAE3RjD0faAqadNzXK5pS53Xuv0e3B3E48oZX6UzTSOG3sG4SRtxEQhdqh7sRG+Jw== X-Received: by 2002:adf:978d:0:b0:368:4da3:a3ac with SMTP id ffacd0b85a97d-373118d1d93mr5337672f8f.40.1724616006140; Sun, 25 Aug 2024 13:00:06 -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-3730817a076sm9125455f8f.60.2024.08.25.13.00.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 25 Aug 2024 13:00:05 -0700 (PDT) Message-ID: <6afeb23a-867f-457d-9b13-fdf5af02c31e@scriptfusion.com> Date: Sun, 25 Aug 2024 21:00:03 +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> Content-Language: en-GB In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: bilge@scriptfusion.com (Bilge) On 25/08/2024 17:05, Rowan Tommins [IMSoP] wrote: > On 25/08/2024 16:29, Bilge wrote: >> You can write, `include(1 + 1);`, because `include()` accepts an >> expression. You will get: "Failed opening '2' for inclusion". Should >> we restrict that? No, because that's just how expressions work in any >> context where they're allowed. > > > I think a better comparison might be the "new in initializers" and > "fetch property in const expressions" RFCs, which both forbid uses > which would naturally be allowed by the grammar. The rationale in > those cases was laid out in > https://wiki.php.net/rfc/new_in_initializers#unsupported_positions and > https://wiki.php.net/rfc/fetch_property_in_const_expressions#supporting_all_objects > They do not seem like better comparisons because, in both cases, support for those respective features was limited due to technical obstructions. My implementation already permits `default` as a general expression (thanks to Bob's Bison patch), Q.E.D. there is no technical constraint precluding support for default as a general expression grammar. What you are proposing is an artificial limitation on the language, which is an entirely different proposition (and not a healthy one, in my view). Allow me to address the point made in your previous email which ended up hinting that `default + 1` should also be prohibited because it hasn't been explicitly justified. Notwithstanding I don't have the energy to justify every single permutation of expressions, I'll humour the arithmetic operators criticism with an example just to demonstrate that one can justify just about anything with sufficient enthusiasm and creativity. Suppose we have a Suspension class that suspends the current process for a specified delay in milliseconds, but our subclass wants to present an interface that deals with whole seconds (including fractional seconds using floats). 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. Cheers, Bilge