Re: private, protected, readonly, public
| From: | Stanislav Malyshev | Date: | Wed, 17 May 2006 09:00:32 +0000 |
| Subject: | Re: private, protected, readonly, public | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23520@lists.php.net to get a copy of this message | ||
AG>>Probably because private variables do often have getters and setters,
AG>>whereas something which is marked as read-only (like a harddrive)
AG>>tends to be read-only always.
I think that by itself returning writable reference to such variable
voluntarily is undesirable, but not fatal - i.e., in most cases the advice
would be "just don't do it" but if you think you know what you are doing,
you may do it.
What I'm concerned about, however - and that is somehow related to what
Andi is saying I think - is that this concept would not sit well with PHP
semantics. The thing here is that PHP has some cases where writable zval
reference is taken without really knowing how it would be used. And in
these cases we might find out we actually have no good way to insert the
check. I remember we had to do various tricks to make get/set handlers
work in all cases where writable zval is required and I'm not sure there's
no bordercases even now when it doesn't do exactly what one might expect
it to do - but we might get a lot of additional problems when we add
non-trivial semantics like denying writes on top of this.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115