Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123736 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 4742D1A009C for ; Fri, 21 Jun 2024 16:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718987096; bh=NTjGv6o7XdYwPMI29P4yoBD0PxtSf5eZ5KWXdUH+JIM=; h=In-Reply-To:References:Date:From:To:Subject:From; b=hj4I4zHeQrMM2ivcTCrExyhU7ZfyYS2uF2Ce47SDsIKClx19OPqRk/DH95L+EE1eI AqxUx2RxVpeP6w7lbe3aIHCsLfIbf2oG5LhIiANDpz8eTwB4TL8JrFsSD+imKYhDfY 1LhCzysNgmPSVCxQKZKGD1sWj0UqVSlbKye5SN3eMW4aQfHIU40/rEU+yVGYkcwdvq WlS+9Cn4aJY6yDjlIgW7SUxtObkVL3jHR1qMn3HI8581GlWU4jwmYcUJ1te7wPvIDq L9k6auZZ0N3BKePEBCdWnyYsx9v3CnpHAWSZ9JPf7Spos3PR3HZjGo+RFARADo0/8U NAZ7qOw3r2qCg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2535A180776 for ; Fri, 21 Jun 2024 16:24:55 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh5-smtp.messagingengine.com (fhigh5-smtp.messagingengine.com [103.168.172.156]) (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 ; Fri, 21 Jun 2024 16:24:54 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 90D451140250 for ; Fri, 21 Jun 2024 12:23:39 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Fri, 21 Jun 2024 12:23:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1718987019; x=1719073419; bh=qwBurqg/6T JYzk86rQYpwEmgv+LjCNLhYQla32AlAn0=; b=soHgZvJPAyXiqdqYqviQXig6ej wKh+eEfSLNw2kN68f6caG/I3lH5unU/Ypdm26NE4/3JEUcpvGkUpGMlz0g2bX8EI F5p2nJxmRAX7N5nuzcwy8SoNLmCZuT8iiCyWDgCvzZHPnc8pQ1hfUFwU/teRu/bs M+DcfxaLAMiD7Es7262weyXYsqQ4fuhq69wo/6OCjSZJT00kSaDs1CSW85RcdxZy U//fba+XKrHx4DvCDeOOKRX4+mS5v0ux3FR0fGV91Q5NqFtcsS8HUO8LJ15H179R kIFnkg6fo0zhnF121e76pRa3wQMkwmhuuXjhLdBh2EBqbM05cvnFKl9mAiqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1718987019; x=1719073419; bh=qwBurqg/6TJYzk86rQYpwEmgv+Lj CNLhYQla32AlAn0=; b=nYZC5/TR8snB533b0KOl4UiTp/gkchBzNwPFx42R3dvv yqdtzTxVVBzk0OdcHLb64MDyW8192TvZPSCkR9kWS27Nh6pOYnZP0rQ4dvRszdpZ sbgtRZISYXuqIu0LA/SQT4Gc7iBWIv7P0luWvqYUeVNB777UnwWJd9n+T7mjRwSg sLmeRl7c/7vDWcdEgAkJhI+O7Kn1oexj0KZOg2OqyH23bGAkNn1259Jfy4LXSBnV P6EjM+K6MYllp56246LAxA6dyfLF+X0SHfrQ6xXZHiE1ZjQVyslNwesIcND9eg6r fIOknc57qqt3/LC7ZOha6TAn/YFRmlvjKLeY5RCAQg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfeefgedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesth dtredtreertdenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgn fdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnh eptdduieeiffelvedtudetueffgeetveetudeufefgkedvkeffiedtgfevueevheeunecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhoph drphhhphesrhifvggtrdgtohdruhhk X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 301591700093; Fri, 21 Jun 2024 12:23:39 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-522-ga39cca1d5-fm-20240610.002-ga39cca1d Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <269a0137-a04b-4572-be3e-3741536dd291@app.fastmail.com> In-Reply-To: <84be04f2-73cd-4fdb-929d-724d4fea98fa@processus.org> References: <9d28c9tOCChpWUcP1SFiFwtf2-w2XAtDzHsmM73myA7zfBsn7TxxEqs-VCnxRAgZjsk2TxS55owmM8wSLgBQL8LgeQLntUQ9toeLMkjTVx4=@gpb.moe> <673a1803-83c4-44b4-bd73-4ba61e83412e@app.fastmail.com> <350c1531-9bcf-4e7c-824b-8d9904b9e48e@rwec.co.uk> <914cde73-3e53-44a8-94ff-bcf34000cc0c@processus.org> <84be04f2-73cd-4fdb-929d-724d4fea98fa@processus.org> Date: Fri, 21 Jun 2024 17:22:10 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] Renaming "strict types" to "scalar type coercion" Content-Type: text/plain From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On Fri, 21 Jun 2024, at 15:21, Pierre wrote: > I don't see the use of a syntax such as `$foo as ?int` since all > existing types of coercion are already possible via the cast syntax > (please correct me if I'm wrong). The current cast syntax (and its functional version, intval() etc) only performs a single "type of coercion": make a best effort to guess the value, silently use a fallback value, never fail. (int)'123hello' is 123, (int)'complete nonsense' is 0. It also doesn't support nullable types, union types, etc, and it's not clear what it should do if it did. There is currently no syntax or function to explicitly perform the coercion that mode 0 scalar parameters perform, where '123hello' and 'complete nonsense' both produce a TypeError. Nor is there any syntax or function that can answer the question "would this value be accepted as {type} in mode 0?" > In almost every case you would need coercion you also need validation, > and validation is not something that's possible with a neat syntax, I don't see why validation can't be concise, for extremely common cases, such as "Is this string obviously an integer?" > at least not this one I'm not sure what you mean by that; I consider the syntax to use very much an open question, and if I get time to write up a proposal, would like to discuss the pros and cons of various options. That could be as simple as a built-in function, but might benefit from first-class syntax so that it can be used with any type without passing it as a string. Regards, -- Rowan Tommins [IMSoP]