Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-12 Thread Larry Garfield
On Fri, Sep 8, 2023, at 1:12 PM, Lanre Waju wrote: > Dear PHP Internals, > > I am writing to propose a new feature for PHP that introduces the > concept of structs. This feature aims to provide a more concise and > expressive way to define and work with immutable data structures. Below > is a

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-09 Thread Robert Landers
On Sat, Sep 9, 2023 at 1:09 AM David Gebler wrote: > > On Fri, Sep 8, 2023 at 2:12 PM Lanre Waju wrote: > > > Dear PHP Internals, > > > > I am writing to propose a new feature for PHP that introduces the > > concept of structs. This feature aims to provide a more concise and > > expressive way

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread David Gebler
On Fri, Sep 8, 2023 at 2:12 PM Lanre Waju wrote: > Dear PHP Internals, > > I am writing to propose a new feature for PHP that introduces the > concept of structs. This feature aims to provide a more concise and > expressive way to define and work with immutable data structures. Below > is a

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread tag Knife
On Fri, 8 Sept 2023 at 14:12, Lanre Waju wrote: > Dear PHP Internals, > > I am writing to propose a new feature for PHP that introduces the > concept of structs. This feature aims to provide a more concise and > expressive way to define and work with immutable data structures. Below > is a

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread someniatko
Hi internals! I think it can be useful for structured data obtained from decoding JSONs or from a relational database. However, maybe there is an even better idea, which combines the best of two worlds: the world of your structs RFC, and native PHP arrays - something like "array shapes". For

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread Lanre Waju
I really like the idea of making structs opaque in that sense, definitely going to put it to vote in the RFC. I agree with the decision to exclude methods from structs, as they are intended to be pure data types and If methods are required, classes can be used instead. I guess based on the

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread Matthew Weier O'Phinney
On Fri, Sep 8, 2023, 9:15 AM Lanre Waju wrote: > Allowing Methods in Structs: > Initially, I suggested that readonly structs have no methods besides the > constructor. However, upon further consideration, I believe it may be > beneficial to allow methods in structs. Even PHP enums allow methods,

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread Olle Härstedt
2023-09-08 15:12 GMT+02:00, Lanre Waju : > Dear PHP Internals, > > I am writing to propose a new feature for PHP that introduces the > concept of structs. This feature aims to provide a more concise and > expressive way to define and work with immutable data structures. Below > is a detailed

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread Lanre Waju
If you want a new data object with slightly different values struct Data2 extends Data { {string $t, array $meta} $title; // Overwrite parent type Status $status; {int $x, int $y} $inlineAnonymous = {x: 1, y: 2}; } Regarding array functions and serialization, there are two

Re: [PHP-DEV] RFC Proposal: Readonly Structs in PHP

2023-09-08 Thread Robert Landers
On Fri, Sep 8, 2023 at 3:12 PM Lanre Waju wrote: > > Dear PHP Internals, > > I am writing to propose a new feature for PHP that introduces the > concept of structs. This feature aims to provide a more concise and > expressive way to define and work with immutable data structures. Below > is a