Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-26 Thread Crocodile
Nice one by Andreas Hennings, I think! I personally have also question on deserialization of immutables. Is it going to be possible at all? Another thing is that PDO will probably not be able to use FETCH_CLASS with immutables, because of the way it initializes properties. On Mon, Feb 26, 2018 at

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-26 Thread Andreas Hennings
Hello, my thoughts. For me personally the proposed feature would not be very useful. i like immutable objects. But for me the pattern of choice is private properties + constructor + optional "wither" methods. The "wither" methods create a clone of the object, then set a property value on the clone

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-26 Thread Silvio Marijić
Currently the build is failing in some parts of the codebase that are obviously affected in some way. I ran valgrind for couple of failing tests and I got numerous reports about memory leaks and conditional jumps over uninitialized values. Not sure what is the reason for that, I had merge conflict

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-26 Thread Silvio Marijić
Yes, I've also took that into consideration when choosing keyword. On Feb 26, 2018 11:35 AM, "Crocodile" wrote: > Is "value" or "immutable" going to become a new reserved word? Ain't we > going to have some BC breaks because of that? If so, then "value" is going > to bring more BC breaks then "i

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-26 Thread Crocodile
Is "value" or "immutable" going to become a new reserved word? Ain't we going to have some BC breaks because of that? If so, then "value" is going to bring more BC breaks then "immutable". On Sun, Feb 25, 2018 at 8:02 PM Paul Jones wrote: > > > > On Feb 25, 2018, at 12:59, Silvio Marijić > wrot

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Paul Jones
> On Feb 25, 2018, at 12:59, Silvio Marijić wrote: > > Here is link to tweet > https://twitter.com/SilvioMarijic/status/965564630071300096 After having read that, I think "immutable" is still perfectly reasonable. -- Paul M. Jones pmjo...@pmjones.io http://paul-m-jones.com Modernizing Leg

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Silvio Marijić
Here is link to tweet https://twitter.com/SilvioMarijic/status/965564630071300096 2018-02-25 19:53 GMT+01:00 Paul Jones : > > > > On Feb 25, 2018, at 11:29, Silvio Marijić > wrote: > > > > I had discussion on Twitter regarding semantics of keyword 'immutable'. > > Can you link to the discussion?

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Paul Jones
> On Feb 25, 2018, at 11:29, Silvio Marijić wrote: > > I had discussion on Twitter regarding semantics of keyword 'immutable'. Can you link to the discussion? I am interested to read it. -- Paul M. Jones pmjo...@pmjones.io http://paul-m-jones.com Modernizing Legacy Applications in PHP http

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Silvio Marijić
I had discussion on Twitter regarding semantics of keyword 'immutable'. I am considering now to replace keyword 'immutable' with 'value'. How would you compare those two, which one is more suitable here? On Feb 25, 2018 6:24 PM, "Silvio Marijić" wrote: > Hi Dan, > > So far that is still only a

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Silvio Marijić
Hi Dan, So far that is still only assumption made based on the fact that most of the code for protecting state is composed of bit checks but I am definitely interested to see benchmark for this RFC. Best regards, On Feb 25, 2018 5:49 PM, "Dan Ackroyd" wrote: On 23 February 2018 at 13:47, Silvi

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-25 Thread Dan Ackroyd
On 23 February 2018 at 13:47, Silvio Marijić wrote: > In addition to your question about impact on the performance, there is > none. Have you actually measured that there is no performance impact, or is that an assumption from what affect the code should have? cheers Dan -- PHP Internals - PHP

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Silvio Marijić
I agree that for any real world applications it wouldn't affect performance, I just didn't want to leave any holes in implementation. Ill test couple of solutions for arrays to see how it works. Yeah, checks are also in place for multiple constructor calls. Regarding your suggestion to draft RFC

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Niklas Keller
Hey, > Problem with checking array on assignment is that it could be N dimensions > deep and one would have perform check for each item in each dimension for > mutable values which could have some performance implications. if you want to enforce that in userland now, you have even higher performa

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Silvio Marijić
Hi Niklas, Problem with checking array on assignment is that it could be N dimensions deep and one would have perform check for each item in each dimension for mutable values which could have some performance implications. Regarding constructor call, upon first initialization of object, you are al

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Niklas Keller
Hey, > I do have rough idea how to go about arrays possibly without recursive > scan, I have to try couple of things, it could work if some checks are > moved to zval level. For now it is in the future scope unless I manage to > handle the within week or two. What's the issue with a one-time runt

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Niklas Keller
Hey, > If you do allow arrays, they would have to follow the same rules as the > immutable object. > > Alternatively, perhaps an ImmutableArrayObject would be a good addition or > followup to the RFC. That would just move the problem and doesn't have any benefit over directly allowing arrays, r

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Silvio Marijić
Thanks Paul, I do have rough idea how to go about arrays possibly without recursive scan, I have to try couple of things, it could work if some checks are moved to zval level. For now it is in the future scope unless I manage to handle the within week or two. First two proposals are valid points.

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Paul Jones
Hi Silvio, I like the RFC. * * * I would like to see arrays allowed as immutable properties. In I wrote that arrays are "probably not practical in most situations" because you have to "recursively scan through array properties to make sure that they con

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Silvio Marijić
In addition to your question about impact on the performance, there is none. As there is no special tracking of those references just control check when you try to write by reference. 2018-02-23 14:40 GMT+01:00 Silvio Marijić : > Hi Rowan, > > I agree that RFC needs a bit refinement which I hope

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-23 Thread Silvio Marijić
Hi Rowan, I agree that RFC needs a bit refinement which I hope to do during ongoing discussion here. Originally you couldn't assign following types to an immutable property - *Resource* - *Instance of none-immutable class * Now I had to resort to also add *array* to that list. Regarding

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-22 Thread Rowan Collins
On 20 February 2018 at 11:25, Nikita Popov wrote: > On Tue, Feb 20, 2018 at 12:20 PM, Silvio Marijić > > wrote: > > > Hi, > > I am starting this discussion again after a year since this RFC was > > created. From discussions with people in the community some suggestions > > came up regarding issu

Re: [PHP-DEV][RFC][DISCUSSION] Immutability

2018-02-20 Thread Nikita Popov
On Tue, Feb 20, 2018 at 12:20 PM, Silvio Marijić wrote: > Hi, > I am starting this discussion again after a year since this RFC was > created. From discussions with people in the community some suggestions > came up regarding issues that were main reason that development on this RFC > stopped. RF