Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127940 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 lists.php.net (Postfix) with ESMTPS id B2E4A1A00BC for ; Mon, 7 Jul 2025 16:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751906668; bh=u7CbLaNvli2eMfpaDlm8qQabDNVZnB92zqnbD7+z8yg=; h=Date:From:To:In-Reply-To:References:Subject:From; b=JiJfSH0D1UVZ8rTwiTy1c4nfq1fKAsePKBN1lTCBqdogscxiqaC0qdqESxj3GdaPb gqdqfJtBSMam42X+ojuXk6PxuIJN68NJehQHY4ozUrh6n7UmBUoiSCJ0VmsmYt3MJA ex6gf5rzpfVOxdXPYPaX0YjfLAaPXYADrkuZsYjU9igxfyCxKJPU/x0Jm+ieb/fuSx VM14zL+3e8p9W9jgHeTm3c83uHGrYh6ElsC6w+lNfU197aKYGhmgrA+H7TndROSn3T gb5Q5tdRgQWzwYCp2FF3gZQ5tXcIwZC1RGowblK3KHhP2LomWPPVJqKerhhc/ZYPuz DyWj2tC7dbxFg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B8A091804AC for ; Mon, 7 Jul 2025 16:44:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Jul 2025 16:44:27 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3BC5B7A01CF for ; Mon, 7 Jul 2025 12:46:18 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-05.internal (MEProxy); Mon, 07 Jul 2025 12:46:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; 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=fm3; t=1751906778; x=1751993178; bh=u7CbLaNvli 2eMfpaDlm8qQabDNVZnB92zqnbD7+z8yg=; b=P7y8gu8vbo0Ucsu6A/pJKd436n fhIs5lpMd2mKO1sdMMTV8O10qHGAhkm7fNUNGF5R+CNixCU+8A2Kfspsi/4agVSF hkHu/b/HrFDrXrgPRaVyUViC3glOaRrln5St9B0vcW+NJBIIw91emEoEmUiKwIMh QLr3Rdlsr3cw9EATByiaMkAz2Epwfvs0UovW3AesfDZ+qg+Ji+Q39K91DouHoYmz 67/kcXqt8zhE7mKsnDj95N3t91L09pVnKf3IoWq1ztqUAXKJWfHNUAFajzjlrVwn rdMk8zAjgIBE3gSXmyjf+0nUCnlMjyb3bj87ROanMFuuPFEGab/s2wP3i+9w== 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-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1751906778; x=1751993178; bh=u7CbLaNvli2eMfpaDlm8qQabDNVZnB92zqn bD7+z8yg=; b=lyjxfDC86kFCsvcne5nZjS8UT1wVxCz7xC6YR7Wt2iRfE51Ence 8ljqvO/AlPqzKhKj8Ts39t5Z+SHTYIFtiBnocDHU1VoClsv/yn17ldfMEMM8dWT0 o0ZeHTnBPuveEBtr8wbxcscSJ8gTsg4QmewQFOGxZoWJSmp2jA9TzKpBqNKsGCOJ HQ6JECFmp1yq1OgW3Fxtv0dSqy2cvAsSSO0M2iKDQJFnkXa46Jl625CK2alwlUW1 +5vlfWKoNLxzsNKV0KTcyDATiYV8/uSEb+BeYFKXPV3MiSkwgB010PhcqJ0X4Tdw uwXgIuCNnQao4OmtdH8h4pa904N75xbFZcw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefvdefudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertd ejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdr tghouggvsheqnecuggftrfgrthhtvghrnheptdeitddvvdevhfdufffhgeelffetgeffve ekheekfeeluedutdeiveekvdetjedvnecuffhomhgrihhnpeefvheglhdrohhrghenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsoh htthhlvggurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id D3D1A2400094; Mon, 7 Jul 2025 12:46:17 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Te0cb2f0d99ee0b50 Date: Mon, 07 Jul 2025 18:45:57 +0200 To: internals@lists.php.net Message-ID: <16080a86-528e-403d-b3a7-9324732af5ee@app.fastmail.com> In-Reply-To: <2030e2a6-6093-417b-89d0-0afc5724ab4d@app.fastmail.com> References: <9f14ae52-6c78-41a1-8d2a-7330fd92d1a9@app.fastmail.com> <2030e2a6-6093-417b-89d0-0afc5724ab4d@app.fastmail.com> Subject: Re: [PHP-DEV] [Discussion][RFC Idea] Cast Variables by Reference Content-Type: multipart/alternative; boundary=53648ebd49c74e2096d94e60b917caa2 From: rob@bottled.codes ("Rob Landers") --53648ebd49c74e2096d94e60b917caa2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Mon, Jul 7, 2025, at 18:41, Rob Landers wrote: >=20 >=20 > On Mon, Jul 7, 2025, at 18:22, Joseph Leedy wrote: >> Hello, I'm Joseph, or Seph for short. I'm a long time listener, but a=20 >> first-time caller. I've had an idea rattling around in my noggin for = a while=20 >> that I'd like your feedback on: >>=20 >> As a developer, I would like to have variables of one type cast to an= other=20 >> type automatically so that I do not need to assign the variable to it= self. >>=20 >> Instead of the following: >>=20 >> ```php >> $price =3D '5.0123'; >> ... >> $price =3D (float) $price; >>=20 >> var_dump($price); // Result: `float: 5.0123` >> ``` >>=20 >> What if we could do this instead? >>=20 >> ```php >> $price =3D '5.0123'; >> ... >> (float) $price; >>=20 >> var_dump($price); // Result: `float: 5.0123` >> ``` >>=20 >> If everyone thinks this a good idea, I would be willing to put togeth= er an=20 >> RFC and work on the implementation myself, with guidance from an expe= rienced=20 >> core developer. I have no experience with C/C++, other than a brief f= oray=20 >> more than twenty years ago, but I am willing to learn. >>=20 >> Thank you for your consideration! Also, a huge thank you to everyone = who=20 >> has made PHP what it is today!=20 >>=20 >> (**Note**: No AI was used in the writing of this message.) >>=20 >=20 > Hey Seph, >=20 > This is basically how non-strict mode works; there's no need for a cas= t. (I very rarely use strict mode, so I was a little confused on why you= 'd ever want to do this) >=20 > =E2=80=94 Rob Aaaand, I just discovered ctrl-enter sends the email. But to continue on with what I was saying, casting is relatively dangero= us (which is why I stay away from strict mode). https://3v4l.org/6VvWc#vnull vs. https://3v4l.org/1cQ9l#vnull =E2=80=94 Rob --53648ebd49c74e2096d94e60b917caa2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Mon, Jul 7, 2025, at 18:41, Rob Landers wrote:


=
On Mon, Jul 7, 2025, at 18:22, Joseph Leedy wrote:
Hello, I'm Joseph, or = Seph for short. I'm a long time listener, but a 
first-ti= me caller. I've had an idea rattling around in my noggin for a while&nbs= p;
that I'd like your feedback on:

As= a developer, I would like to have variables of one type cast to another=  
type automatically so that I do not need to assign the = variable to itself.

Instead of the following:

```php
$price =3D '5.0123';
= ...
$price =3D (float) $price;

var_du= mp($price); // Result: `float: 5.0123`
```

What if we could do this instead?

```php<= /div>
$price =3D '5.0123';
...
(float) $price;

var_dump($price); // Result: `float: 5.0123`
```

If everyone thinks this a good idea,= I would be willing to put together an 
RFC and work on t= he implementation myself, with guidance from an experienced 
<= div>core developer. I have no experience with C/C++, other than a brief = foray 
more than twenty years ago, but I am willing to le= arn.

Thank you for your consideration! Also, a = huge thank you to everyone who 
has made PHP what it is t= oday! 

(**Note**: No AI was used in the wr= iting of this message.)


=
Hey Seph,

This is basically how non-strict= mode works; there's no need for a cast. (I very rarely use strict mode,= so I was a little confused on why you'd ever want to do this)

=E2=80=94 Rob
<= div>
Aaaand, I just discovered ctrl-enter sends the email.=

But to continue on with what I was saying, cas= ting is relatively dangerous (which is why I stay away from strict mode)= .


vs.

=

=E2=80=94 = Rob
--53648ebd49c74e2096d94e60b917caa2--