Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127939 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 F19931A00BC for ; Mon, 7 Jul 2025 16:41:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751906401; bh=aHjBkB4p/f+AnZpwgd+ADbAqyBXjmzBJWHzAxkwBgdg=; h=Date:From:To:In-Reply-To:References:Subject:From; b=I1+Udj0mIDJ1hpV4G7iPsafyPi6F9PNVNFmARihAObJgy0rcOyDC40l+wiBB81UMb U1Y4k3/8EMuuQXjUehkaRlVEWkcZd8HKcGjkz3a4i4s7gZc9IFNVSCEQAvg5wHdfeM ebUnVtoLmSv0Xb1Nec3YJ6wah5Ie4+09uAcbogCsyTBZ4FcBxljk/RhNk8mWpYtL44 A9eAHPKELzvXxgJJQo1kHoNyGQzHGz3hFa4MxJUDS+nzB6Ndpu/RcUFBAPaqFRLHpN uNOd2pmR+DRIEiF+1trL3Wt7Us53KGJevCm26fe80NoUisOzCAG4xK1bJ901Fqe/E6 Fm9XFjkHb53cQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F0A8F180074 for ; Mon, 7 Jul 2025 16:40:00 +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.1 required=5.0 tests=BAYES_50,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) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Jul 2025 16:40:00 +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 CF2447A0110 for ; Mon, 7 Jul 2025 12:41:50 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-05.internal (MEProxy); Mon, 07 Jul 2025 12:41:50 -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=1751906510; x=1751992910; bh=aHjBkB4p/f +AnZpwgd+ADbAqyBXjmzBJWHzAxkwBgdg=; b=QD4XV2XPGdLCv32qteu+xogRLU C0RAoI/9/7PWoSDXn9j5ItiOqlN72wVtHPU+KdBVvqUdIzKZROYD/2JOq+6qvt2w E/txD36R0u1YYPUqzmRtZpbZby/ANI8mblNYaWp4eDfjJPBHAGQEtw7WUWe/6fjo e7va3VgFRNW2yB2GW1jKychS9x8n8FnOEfvb45huRxfa98tdcKyJosFXYq8roxQl n7TJF89MuDj78BxmbtMikdKc9aVFUo0NAEIQENkGXAL6laHEtTIlZJjWbV30xXHA CTCpXYx6F3POxshpzkRFpRIe44Tr6MP0W7iULruzYlh3OCnYb8ZObaz/oQpg== 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= 1751906510; x=1751992910; bh=aHjBkB4p/f+AnZpwgd+ADbAqyBXjmzBJWHz AxkwBgdg=; b=UvV5me3ytVXEzYUhuz44uQx+puRUVE6OFEIraCdwAkDXbvSy6GE gECg0gOEvL8alFZwQPgP92bZwmh1HRc9AOlcL0RhSPt3V//VfkcT13mgYIifHRQY Dv7mdV5LUEvFMOTN2vINjuyuQvhbSamoP+JT+z72PoeKTChX9fa3VELxooxi30o3 7I+06KGRMsxanLPufrgORWZLnf/VlUh4HaIczn1E6Yq03dBjiLgcWrtXPNV/d2ER 9I9jzQfA7W6tOFzRxV4U0zQARVrXP69rQM+Jv2FBIO1C9hM0KfaxNS8wjeQli8HD lYgFMqoQmujiq/66yYTKr54ODSJUSK6mGXg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdefvdeftdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertd ejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdr tghouggvsheqnecuggftrfgrthhtvghrnheptdeujedttefhueelhfdtleeiudetlefftd duleehffegtdeihefhleeijefgveegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtg hpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghl sheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5919F2400098; Mon, 7 Jul 2025 12:41:50 -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:41:28 +0200 To: internals@lists.php.net Message-ID: <2030e2a6-6093-417b-89d0-0afc5724ab4d@app.fastmail.com> In-Reply-To: <9f14ae52-6c78-41a1-8d2a-7330fd92d1a9@app.fastmail.com> References: <9f14ae52-6c78-41a1-8d2a-7330fd92d1a9@app.fastmail.com> Subject: Re: [PHP-DEV] [Discussion][RFC Idea] Cast Variables by Reference Content-Type: multipart/alternative; boundary=77582df131e34cf3b6130f8de04d8623 From: rob@bottled.codes ("Rob Landers") --77582df131e34cf3b6130f8de04d8623 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 ano= ther=20 > type automatically so that I do not need to assign the variable to its= elf. >=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 togethe= r an=20 > RFC and work on the implementation myself, with guidance from an exper= ienced=20 > core developer. I have no experience with C/C++, other than a brief fo= ray=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 w= ho=20 > has made PHP what it is today!=20 >=20 > (**Note**: No AI was used in the writing of this message.) >=20 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 --77582df131e34cf3b6130f8de04d8623 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


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 
firs= t-time caller. I've had an idea rattling around in my noggin for a while=  
that I'd like your feedback on:

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

Instead of the followin= g:

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

va= r_dump($price); // Result: `float: 5.0123`
```

<= /div>
What if we could do this instead?

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

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

If everyone thinks this a good i= dea, I would be willing to put together an 
RFC and work = on the implementation myself, with guidance from an experienced 
core developer. I have no experience with C/C++, other than a br= ief foray 
more than twenty years ago, but I am willing t= o learn.

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

(**Note**: No AI was used in th= e writing of this message.)


Hey Seph,

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

=E2=80=94 Rob
--77582df131e34cf3b6130f8de04d8623--