Re: [RFC][DISCUSSION] Immutability

From: Date: Fri, 23 Feb 2018 14:47:08 +0000
Subject: Re: [RFC][DISCUSSION] Immutability
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-101911@lists.php.net to get a copy of this message
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 runtime check on assignment? > First two proposals are valid points. Regarding disabling constructor, that > would fail as soon as you try to write properties in constructor since > object is already "locked". You lock the object after the constructor has been called, not afterwards. If you don't do that, your objects won't be immutable. I like the RFC, but generally I think value objects that are passed by-value instead of by-reference are the better way to solve the problem. Regards, Niklas

« previous php.internals (#101911) next »