Re: [PHP-DEV] RFC: Records

2025-07-21 Thread Rob Landers
On Mon, Jul 21, 2025, at 13:02, Nick wrote: > >> On 17. Nov 2024, at 06:14, Rob Landers wrote: >> >> Hello internals, >> >> I'm ready as I'm going to be to introduce to you: "Records" >> https://wiki.php.net/rfc/records! >> >> Records allow for a lightweight syntax for defining value objects.

Re: [PHP-DEV] RFC: Records

2025-07-21 Thread Nick
> On 17. Nov 2024, at 06:14, Rob Landers wrote: > > Hello internals, > > I'm ready as I'm going to be to introduce to you: "Records" > https://wiki.php.net/rfc/records! > > Records allow for a lightweight syntax for defining value objects. These are > superior to read-only classes due to hav

Re: [PHP-DEV] RFC: Records

2025-07-16 Thread Rob Landers
On Tue, Jul 15, 2025, at 19:05, Nicolas Grekas wrote: > Not sure it's really a contribution to the discussion but in case you missed > it, you can make public properties "public(set)": > > final readonly class Response { > public function __construct( > public public(set) int $statusC

Re: [PHP-DEV] RFC: Records

2025-07-16 Thread Nick
> On 15. Jul 2025, at 01:22, Rob Landers wrote: > >> 5. Inline constructor isn’t necessary and could be proposed separately. I’ve >> thought recently about this feature > > I will probably remove this, to be honest. It was for nesting records inside > classes or other records, but this featur

Re: [PHP-DEV] RFC: Records

2025-07-15 Thread Nicolas Grekas
Le lun. 14 juil. 2025 à 20:26, Rob Landers a écrit : > Hey Dmitry, > > Please remember to bottom post! > > On Mon, Jul 14, 2025, at 11:16, Dmitry Derepko wrote: > > Hi, Rob! > > I'm just wondering, why the implementation differs from a regular class? > > Record makes a "class" immutable and uniqu

Re: [PHP-DEV] RFC: Records

2025-07-14 Thread Rob Landers
Hey Dmitry, Please remember to bottom post! On Mon, Jul 14, 2025, at 11:16, Dmitry Derepko wrote: > Hi, Rob! > > I'm just wondering, why the implementation differs from a regular class? > > Record makes a "class" immutable and unique, using field value comparison > instead of object refs. It

Re: [PHP-DEV] RFC: Records

2025-07-14 Thread Dmitry Derepko
Hi, Rob! I'm just wondering, why the implementation differs from a regular class? Record makes a "class" immutable and unique, using field value comparison instead of object refs. It has a custom `with` method which is similar to the new `clone` operator accepted recently. I'd suggest not intr

Re: [PHP-DEV] RFC: Records

2025-07-13 Thread Nick
> On 17. Nov 2024, at 06:14, Rob Landers wrote: > > Hello internals, > > I'm ready as I'm going to be to introduce to you: "Records" > https://wiki.php.net/rfc/records! > > Records allow for a lightweight syntax for defining value objects. These are > superior to read-only classes due to hav

Re: [PHP-DEV] RFC: Records

2024-11-21 Thread Rob Landers
On Sun, Nov 17, 2024, at 08:21, Larry Garfield wrote: > I would far prefer assembling record-ish behavior 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-p

Re: [PHP-DEV] RFC: Records

2024-11-19 Thread Larry Garfield
On Tue, Nov 19, 2024, at 5:56 AM, Michał Marcin Brzuchalski wrote: > Hi Larry, > > niedz., 17 lis 2024 o 08:24 Larry Garfield > napisał(a): >> ... >> I can see the benefit of an inline constructor. Kotlin has something >> similar. But I can see the benefit of it for all classes, even service

Re: [PHP-DEV] RFC: Records

2024-11-19 Thread Michał Marcin Brzuchalski
Hi Larry, niedz., 17 lis 2024 o 08:24 Larry Garfield napisał(a): > ... > I can see the benefit of an inline constructor. Kotlin has something > similar. But I can see the benefit of it for all classes, even service > classes, not just records. (In Kotlin, it's used for service classes all > t

Re: [PHP-DEV] RFC: Records

2024-11-19 Thread Michał Marcin Brzuchalski
Hi Rob and Ilia Thank you both for your detailed proposals and the efforts you put into shaping this important feature for PHP It is clear a lot of thought has gone into both approaches and I appreciate the opportunity to share my thoughts. niedz., 17 lis 2024 o 01:17 Ilija Tovilo napisał(a): >

Re: [PHP-DEV] RFC: Records

2024-11-17 Thread Rowan Tommins [IMSoP]
Hi Rob, I'm torn on this one. On the one hand, it does look like a nice solution for adding custom value objects to the language; on the other hand, it's a lot of things that are "just slightly different" for users to get used to. On 17/11/2024 21:30, Rob Landers wrote: One of the main reaso

Re: [PHP-DEV] RFC: Records

2024-11-17 Thread Rob Landers
Hello Ilija and Larry, You both touch upon some interesting and similar thoughts, and it may be worth sharing how I arrived here; at least so we have some shared context: Personally, I feel that classes are quite bloated with features and what feature works with what is quite confusing for new

Re: [PHP-DEV] RFC: Records

2024-11-16 Thread Larry Garfield
On Sat, Nov 16, 2024, at 5:14 PM, Rob Landers wrote: > Hello internals, > > I'm ready as I'm going to be to introduce to you: "Records" > https://wiki.php.net/rfc/records! > > Records allow for a lightweight syntax for defining value objects. > These are superior to read-only classes due to havin

Re: [PHP-DEV] RFC: Records

2024-11-16 Thread Ilija Tovilo
Hi Rob On Sun, Nov 17, 2024 at 12:15 AM Rob Landers wrote: > > Hello internals, > > I'm ready as I'm going to be to introduce to you: "Records" > https://wiki.php.net/rfc/records! Thanks for your proposal. I very much agree that value semantics are a highly desirable feature. I sent out my con

[PHP-DEV] RFC: Records

2024-11-16 Thread Rob Landers
Hello internals, I'm ready as I'm going to be to introduce to you: "Records" https://wiki.php.net/rfc/records! Records allow for a lightweight syntax for defining value objects. These are superior to read-only classes due to having value semantics and far less boilerplate, for most things deve