Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126029 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 404E71A00BD for ; Thu, 21 Nov 2024 23:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732230639; bh=FkalFc3qw67yOpJevlQ0ROEWPM1L5RdtfiFiee3E4to=; h=Date:From:To:In-Reply-To:References:Subject:From; b=kNFI89g0zmxglTSeoy2vuu47GgmRpPjs8q3YvlMZyFdONQyNhAgBCQLOHhmYW4LpI qJ9gjywVdwoCNJKYnj8LrX4hwsb0mkIfQ7660NdNlYnn+4jlqXb41oJ0ZEiEFiMzgu MXWy2dzmFhuYkyYWQEOglAtz8KJ4My+D3SRu+pXvsZJ11zTuCtBtIdEESQXDy9pS9D 0GEmO2QiJFr4FrqHJ3wnHJcKxHDzSKOMfNR2x1Bj0fPaHZoeGVSBayFvFAMC9KfRJJ Qq8IYNNgNB9KzuALHHy+1Srms9jcjj81WZifyZ743plAeX914l2iCt5rCGbB0WMiej 5t1uXJQcIlhGQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6444D18004B for ; Thu, 21 Nov 2024 23:10:38 +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,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 ; Thu, 21 Nov 2024 23:10:37 +0000 (UTC) Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id C547C25400D2 for ; Thu, 21 Nov 2024 18:07:56 -0500 (EST) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-01.internal (MEProxy); Thu, 21 Nov 2024 18:07:56 -0500 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=fm2; t=1732230476; x=1732316876; bh=ZPzMB1k1Ed fFYzmcruO74vwlF563QtKS006aVe297+Q=; b=H4cEAg3e9649hh0R7my01CaNo3 ivY3esM8D/CcEzlUnAM1GzLFAHybrVBvL+gtzUPPzQWo6JiObZ1QJKaPR2DwYB2d iHI+hUo+STYvwcf2z04DuyRaOelBosjusX8/16JBPkC4yrW8D6qMcecPvYcS7MRs hL4GKam8NsMDE/HWO6uERJ++P/WRpE5UE0ai50mP66rj23vu2OXc1xSmQ1lKQNQm BZtolPyANDAiOVC3aPiqNqwfNHrzqth9SgioaRCjv97XbP1hN+nzZgSY4Hrhu2u7 yc/Q+JipgkxbJcujs2bqXA359wFPU9srMCQY4VyOLU8hBkfQ+k+IW38yrOCQ== 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=fm1; t= 1732230476; x=1732316876; bh=ZPzMB1k1EdfFYzmcruO74vwlF563QtKS006 aVe297+Q=; b=vXLGuVJuBnbH7iO5IOoq9bRU0Pw9JgqxlL9dYaZiiJgqtrBBDi4 MTIpN276Qkglk7BhobENwKJCC+7D8RhlckXW8Hec7REYQWgU9fCrFzbRdQvE1dGY SaHDYTUpaF8mbQ86/ULxTWFCiC9my0ZkXjSFOSPKxyYIHg92MRuJasbJEwsgoo+h mbRtiekcgIi/WNpERhYDMNfRaatbPumZb34ZYhIxLz2oXYHckrJXu2XJIPA0tIUH uNWAfa1EePAMiV/iuelt5dRP5emaYSOp3YsIPC6yuc0qjifdq57rxFLtv8u1XOJ0 TfvzCUVs26DA0X6fngv5SyO3YY9fubbDMkw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrfeejgddtiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdpuffr tefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecunecujfgurhepofggfffhvf fkjghfufgtsegrtderreertdejnecuhfhrohhmpedftfhosgcunfgrnhguvghrshdfuceo rhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrfgrthhtvghrnheptdeujedtte fhueelhfdtleeiudetlefftdduleehffegtdeihefhleeijefgveegnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhhosgessghothhtlhgvug drtghouggvshdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghp thhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 4503D780068; Thu, 21 Nov 2024 18:07:56 -0500 (EST) 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 Date: Fri, 22 Nov 2024 00:07:35 +0100 To: internals@lists.php.net Message-ID: <05db7ff5-0e80-4c5c-ac96-445053533ecb@app.fastmail.com> In-Reply-To: <68eba37e-1bfe-4509-af41-112bb196415c@app.fastmail.com> References: <68eba37e-1bfe-4509-af41-112bb196415c@app.fastmail.com> Subject: Re: [PHP-DEV] RFC: Records Content-Type: multipart/alternative; boundary=ede335cfa57f4f01952173c7437da583 From: rob@bottled.codes ("Rob Landers") --ede335cfa57f4f01952173c7437da583 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sun, Nov 17, 2024, at 08:21, Larry Garfield wrote: > I would far prefer assembling record-ish behavior myself, using the sm= aller parts above. Eg: >=20 > final readonly data class Point(int $x, int $y); >=20 > "final" prevents extension. "readonly" makes it immutable. "data" gi= ves it value-passing semantics. Any class can use an inline constructor= . "with" is designed to work automatically on all objects. Boom, I've = just assembled a Record out of its constituent parts, which also makes i= t easier for others to learn what I'm doing, because the features opted-= in to are explicit, not implicit. Sorry for the radio silence, but I found myself saying something was imp= ossible. This is software, anything is possible... Anyway, I think I figured out how to implement a "data" modifier, and it= is quite excellent (for the exact reasons you give). I'll break this up into multiple RFCs, pending some further tests to try= and break my proof-of-concept: - a "data" modifier on class for value semantics - an "inline constructor" As you mention, at that point, a "record" or "value" keyword can just be= shorthand for "final readonly data class". =E2=80=94 Rob --ede335cfa57f4f01952173c7437da583 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sun, Nov 17,= 2024, at 08:21, Larry Garfield wrote:
I would far prefer assembling record-ish beh= avior myself, using the smaller parts above.  Eg:
final readonly data class Point(int $x, int $y);

"final" prevents extension.  "readonly" makes it = immutable.  "data" gives it value-passing semantics.  Any clas= s can use an inline constructor.  "with" is designed to work automa= tically on all objects.  Boom, I've just assembled a Record out of = its constituent parts, which also makes it easier for others to learn wh= at I'm doing, because the features opted-in to are explicit, not implici= t.

Sorry for the radio silence= , but I found myself saying something was impossible. This is software, = anything is possible...

Anyway, I think I f= igured out how to implement a "data" modifier, and it is quite excellent= (for the exact reasons you give).

I'll bre= ak this up into multiple RFCs, pending some further tests to try and bre= ak my proof-of-concept:

- a "data" modifier= on class for value semantics
- an "inline constructor"

As you mention, at that point, a "record" or = "value" keyword can just be shorthand for "final readonly data class".

=E2=80=94 Rob
<= /body> --ede335cfa57f4f01952173c7437da583--