Hi Silvio,

I like the RFC.

* * *

I would like to see arrays allowed as immutable properties.

In <http://paul-m-jones.com/archives/6400> 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 contain only immutable values".

However, I think if the scanning happens at the C level it is not such a 
burden. John Boehr implemented it for the immutable ServerRequest object in 
ext-request <http://pecl.php.net/package/request> and it has worked well.

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.

* * *

Some further points to harden the implementation:

- I see that resources and references are disallowed (which is good). If you 
have not already done so, you may wish to disallow streams as well.

- You might want to disable setting of undefined public properties, so that you 
cannot "add" mutable public properties to the immutable object.

- Disable the constructor after it has been called, so the object cannot be 
"re-constructed" in place.

* * *

That's all I can think of for now. Thanks for putting this together.

Paul M. Jones

Modernizing Legacy Applications in PHP

Solving the N+1 Problem in PHP

PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to