Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-06 Thread Ilija Tovilo
Hi Rowan On Fri, Apr 5, 2024 at 12:28 AM Rowan Tommins [IMSoP] wrote: > > On 03/04/2024 00:01, Ilija Tovilo wrote: > > Regardless of the implementation, there are a lot of interactions we will > want to consider; and we will have to keep considering new ones as we add to > the language. For

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-04 Thread Rowan Tommins [IMSoP]
On 03/04/2024 00:01, Ilija Tovilo wrote: Data classes are classes with a single additional > zend_class_entry.ce_flags flag. So unless customized, they behave as > classes. This way, we have the option to tweak any behavior we would > like, but we don't need to. > > Of course, this will still

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-04 Thread Kévin Dunglas
Data classes will be a very useful addition to "API Platform". API Platform is a "resource-oriented" framework that strongly encourages the use of "data-only" classes: we use PHP classes both as a specification language to document the public shape of web APIs (like an OpenAPI specification, but

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-03 Thread Ilija Tovilo
Hi Larry On Wed, Apr 3, 2024 at 12:03 AM Larry Garfield wrote: > > On Tue, Apr 2, 2024, at 6:04 PM, Ilija Tovilo wrote: > > > I think you misunderstood. The intention is to mark both call-site and > > declaration. Call-site is marked with ->method!(), while declaration > > is marked with "public

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Ilija Tovilo
Hi Rowan On Tue, Apr 2, 2024 at 10:10 PM Rowan Tommins [IMSoP] wrote: > > On 02/04/2024 01:17, Ilija Tovilo wrote: > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > I'm not sure

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Ilija Tovilo
Hi Niels On Tue, Apr 2, 2024 at 8:16 PM Niels Dossche wrote: > > On 02/04/2024 02:17, Ilija Tovilo wrote: > > Hi everyone! > > > > I'd like to introduce an idea I've played around with for a couple of > > weeks: Data classes, sometimes called structs in other languages (e.g. > > Swift and C#). >

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Larry Garfield
On Tue, Apr 2, 2024, at 6:04 PM, Ilija Tovilo wrote: >> What would be the reason not to? As you indicated in another reply, the >> main reason some languages don't is to avoid large stack copies, but PHP >> doesn't have large stack copies for objects anyway so that's a non-issue. >> >> I've

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Deleu
On Tue, Apr 2, 2024 at 1:47 PM Larry Garfield wrote: > > * Data classes protect from interior mutability. More concretely, > > mutating nested data objects stored in a `readonly` property is not > > legal, whereas it would be if they were ordinary objects. > > * In the future, it should be

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Rowan Tommins [IMSoP]
On 02/04/2024 01:17, Ilija Tovilo wrote: I'd like to introduce an idea I've played around with for a couple of weeks: Data classes, sometimes called structs in other languages (e.g. Swift and C#). Hi Ilija, I'm really interested to see how this develops. A couple of thoughts that

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Rob Landers
On Tue, Apr 2, 2024, at 20:51, Bruce Weirdan wrote: > On Tue, Apr 2, 2024 at 8:05 PM Ilija Tovilo wrote: > > > Equality for data objects is based on data, rather than the object > > handle. > > I believe equality should always consider the type of the object. > > ```php > new

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Bruce Weirdan
On Tue, Apr 2, 2024 at 8:05 PM Ilija Tovilo wrote: > Equality for data objects is based on data, rather than the object > handle. I believe equality should always consider the type of the object. ```php new Problem(size:'big') === new Universe(size:'big') && new Problem(size:'big') === new

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Niels Dossche
On 02/04/2024 02:17, Ilija Tovilo wrote: > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > In a nutshell, data classes are classes with value semantics. >

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Ilija Tovilo
Hi Larry On Tue, Apr 2, 2024 at 5:31 PM Larry Garfield wrote: > > On Tue, Apr 2, 2024, at 12:17 AM, Ilija Tovilo wrote: > > Hi everyone! > > > > I'd like to introduce an idea I've played around with for a couple of > > weeks: Data classes, sometimes called structs in other languages (e.g. > >

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Robert Landers
On Tue, Apr 2, 2024 at 2:20 AM Ilija Tovilo wrote: > > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > In a nutshell, data classes are classes with value semantics.

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Larry Garfield
On Tue, Apr 2, 2024, at 12:17 AM, Ilija Tovilo wrote: > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). *gets popcorn* > In a nutshell, data classes are classes with

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Ilija Tovilo
Hi Alexander On Tue, Apr 2, 2024 at 4:53 AM Alexander Pravdin wrote: > > On Tue, Apr 2, 2024 at 9:18 AM Ilija Tovilo wrote: > > > > I'd like to introduce an idea I've played around with for a couple of > > weeks: Data classes, sometimes called structs in other languages (e.g. > > Swift and C#).

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-02 Thread Ilija Tovilo
Hi Marco On Tue, Apr 2, 2024 at 2:56 AM Deleu wrote: > > > > On Mon, Apr 1, 2024 at 9:20 PM Ilija Tovilo wrote: >> >> I'd like to introduce an idea I've played around with for a couple of >> weeks: Data classes, sometimes called structs in other languages (e.g. >> Swift and C#). >> >> snip >>

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-01 Thread Alexander Pravdin
On Tue, Apr 2, 2024 at 9:18 AM Ilija Tovilo wrote: > > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > ```php > data class Vector { > private $values; > >

Re: [PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-01 Thread Deleu
On Mon, Apr 1, 2024 at 9:20 PM Ilija Tovilo wrote: > Hi everyone! > > I'd like to introduce an idea I've played around with for a couple of > weeks: Data classes, sometimes called structs in other languages (e.g. > Swift and C#). > > In a nutshell, data classes are classes with value semantics.

[PHP-DEV] [RFC][Concept] Data classes (a.k.a. structs)

2024-04-01 Thread Ilija Tovilo
Hi everyone! I'd like to introduce an idea I've played around with for a couple of weeks: Data classes, sometimes called structs in other languages (e.g. Swift and C#). In a nutshell, data classes are classes with value semantics. Instances of data classes are implicitly copied when assigned to