Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128725 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 9B8F71A00BC for ; Wed, 24 Sep 2025 22:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1758752438; bh=OAHI8FxzJMJzKvvljEcytj6wZV1+2rkEbhYxgp/i2pk=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=dkt4syMgytALyRk6ixqlQXD9fY5cM8ycOHYLC5CFAIcHV28CzpPdnarsBM1m521cZ gKA6zJxRP8Kz6MXp1FI14AdtQOLQ2N8ZY4DOeGnNs+T2pnsOt5utyb82p+e85QNLyL bkLsDLUC0pivoj+qVGyKYt/YpRCAWLWEIZKgy3seS1T3VjIpTo2mjWb8bmfToxBMCe eK7VmfIw5j7ubHorn2r7orda7nv32HKzyrE++AB7pliJiIrrvGLJLXzTaETp5lCQkv AVQ/75VryWo5an3IBqOEh6d7s16sb+SpVV6FcKF+FhZThw/MtGX88nuARQ7x8AprrS shIzdgwd+h5ew== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D5CF71804CF for ; Wed, 24 Sep 2025 22:20:37 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from outbound.mr.icloud.com (p-west2-cluster2-host6-snip4-10.eps.apple.com [57.103.68.243]) (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 ; Wed, 24 Sep 2025 22:20:37 +0000 (UTC) Received: from outbound.mr.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-west-2a-100-percent-11 (Postfix) with ESMTPS id 9CC0718004F8; Wed, 24 Sep 2025 22:21:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=commonground.systems; s=sig1; bh=zjL7cLCGeG0OoiwYu79rmAm/RdRoz4uoAkkobJSlgOM=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To:x-icloud-hme; b=auhzG8/B/J6Qpc9pNjrKtF0ZhbLwI1JD3Cbgt/CNX7zEJxUcz0qL4Hq+eKuu0M07+fH+DR850tIID2OMNTYlm2YjUxJYmDnBaVdRdM+HLEOqanKL++IUdzvSrzASsT6dHsCDFAQVb9knCQ+el/aofgQ9RS0BqKXawNGQCO5nzbgvhak95x3wsQ42kG2Khxej3dCdjmI3RdS3IahnUYcYB8jmtfQwuwpjYHom5GSsTCiO/2PnJneYes8YB3aQ0wDGj4o8JwB5UV/qyQ9Qc1jO3ejdEh6bFk40k53DIRhrR0yxDHR4CsxAyl7I8ARBwWqdBesUXGOqJs8u7lwAuN2Pyg== mail-alias-created-date: 1673482948617 Received: from smtpclient.apple (unknown [17.57.152.38]) by p00-icloudmta-asmtp-us-west-2a-100-percent-11 (Postfix) with ESMTPSA id 548B518004C1; Wed, 24 Sep 2025 22:21:55 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.100.1.1.5\)) Subject: Re: [PHP-DEV] [RFC] Add pack()/unpack() support for signed integers with specific endianness In-Reply-To: Date: Wed, 24 Sep 2025 15:21:44 -0700 Cc: Alexandre Daubois , =?utf-8?Q?Tim_D=C3=BCsterhus?= Content-Transfer-Encoding: quoted-printable Message-ID: <174662DC-C191-4CA9-8B50-4A91056FC5AB@commonground.systems> References: <327029177342d39a2a29051c3f28062b@bastelstu.be> To: PHP internals list X-Mailer: Apple Mail (2.3864.100.1.1.5) X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTI0MDE5OCBTYWx0ZWRfX+i5cvNTTqE7b Uhf0peEKH0nnNJCZeOquG0oGltmvyumIaqlJw3MnoNVDVxJDOnB4o1yfcPA/jLXdW1F6HojAx4e f9LqynqYPvCc3llGQhXpbhMmW7OPco8aMEdbbXsMIESG2omm4QGuSW8fq2oIG74v9AWbuvkgy/q 1aAUMmrvgkZhsmLnUkEDfWY5P9IgLx6V6lHRCy2qdyY5F6TdiUnO2i4aS8NklsKdyOwP3BPVl7a t5xzNbIL4io5RcxO3KN+ra6gK/B02sYCpA8AW38QtjWS4WKs/adbT+fiBroRhwID5Sb5KIC+E= X-Proofpoint-GUID: tYPZTNVlSn4ejKm2gqXN1ooOmJYow55z X-Proofpoint-ORIG-GUID: tYPZTNVlSn4ejKm2gqXN1ooOmJYow55z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-24_06,2025-09-24_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 clxscore=1030 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2506270000 definitions=main-2509240198 X-JNJ: AAAAAAABw1klmjmvfzEVbScIVlkDGODL0A77AzxDduSugu5L8hi1G8qwrBK8ifDQpNbf08cspFsWLCbfRA7sZHy+EqPUZWLD4ZdH1AIsoJKcX2/p4FjX4KSHQpqRlAsM9HJd9WvOGAkZYjVcE/uZH4FWkCE86VeHjmpaGWPuoLn7wOrMVwtJTDC84CM8T/5hlkR4ugpSzQwWmG9B6dJ9TL+FdJ4R+D7YwN9XsMfyW6eAjSLBEd4cCNM5SfsTMpFkH3KyMrTsRKRYliwJMKprUdCOnCoHLTiG9LnwsYooN+bjf8NZ0/E4xlcLoBnpMyZLkm48uJB27QhBDNMiXpEqFOUGRN5QkA1xFrv8uiBI0oVPd589ERdY/h8FRTVHMINeCCZy5lmHfCKOxVJ97sPZmOy2c/08dyo3ngDJqZVSR6yR22LiYX/mllQxmWsv/FtnRe+Vxe0JrwfVZtNN21bofd16I55vzd2JwM8Z+SOXYEs6B/gICThY+eR8H2uO6Unj/5aQmNjQeoJzAWmZbaocOzv6WRZDFnY/8uEsh1WJ5n/lRFMhHmWuOcRTSSbhtRIJ9iLEwWnbTQSgtlusT8+uyLsuoHqAWEk2DpRIOfZGPXn8gBezBXetbOTHQJxYAT0B7WGArP2KjYUyFCZTIxCkZhrJ4Zj6GKU= From: andrewf@commonground.systems (Andrew F) On Sep 24, 2025, at 00:28, Alexandre Daubois = wrote: > That would be an interesting addition. Given that only those 4 have > diverged from Perl, that could be great to sync them again. Let's wait > for other inputs to see if someone agrees with the idea before > potentially revamping the RFC. I personally like it. PHP's unpack() is already fundamentally divergent from Perl's in that it = returns an associative array, and requires its format string to be = formatted differently from the one used by pack(). For instance, in = Perl, one can write: $packed =3D pack("NNN", 123, 456, 789); ($x, $y, $z) =3D unpack("NNN", $packed); and have $x =3D 123, $y =3D 456, and $z =3D 789. In PHP, however, the following code does not work as expected: $packed =3D pack("NNN", 123, 456, 789); [$x, $y, $z] =3D unpack("NNN", $packed); Instead of returning a list of three integers, it returns an associative = array with one key called "NN"; the other two values aren't unpacked at = all. Instead, one must name each of the fields in the format string and = unpack them as an associative array: ["x" =3D> $x, "y" =3D> $y, "z" =3D> $z] =3D unpack("Nx/Ny/Nz", = $packed); I'd support changes to pack() and/or unpack() to allow them to be used = symmetrically, but that seems like a larger change than what is being = proposed here. -- Andrew F=