Jeff Moore wrote:
On May 16, 2006, at 7:28 PM, D. Dante Lorenso wrote:
I'm not familiar with this OOP concept from any other language.
Perhaps it exists, but if it doesn't, is there a reason why?
Its hard to find a major OO language that does not have
property/accessor method support.
It's not the p, p, p, __get or __set I was unfamiliar with. It's the
'readonly' construct that I had not seen in any other language.
The Pandora's box of complexity was opened when PHP got __get and
__set. readonly or readable is just a bandaid that fixes one use case
of one problem, but does it in a way that doesn't help fix any of the
other problems in the future. There is nothing wrong with simple
properties in PHP just the way they are now. There is also nothing
wrong with __get or __set. They work well when you truly need virtual
properties, such as for an active record or a proxy class.
Sounds like you are against adding 'readonly'.
What PHP is missing is a way to associate individual accessor methods
with individual properties ...
Isn't that what you do when you define the class without using __get and
__set?
class A { private $x; public $y; protected $z; function x() { return
$this->x; } ... }
$A = new A();
To associate an 'accessor method' with a property other than using the
$A->x syntax, you just put () at the end of the call as in: $a->x() and
now you have a method call. Seems like we don't need anything new in
the language for that.
I thought this thread was about wanting to create some new hybrid
visibility/access level other than p/full, p/full, and p/full.
Something along the lines of declaring different levels of access to
variables based on visibility such that:
* public readable, but also protected readable/writable
* protected readable, but also private readable/writable
Although that sounds like fun, I'm all about duplicating what other
languages have and find useful than inventing new oop concepts for the
fun of academic exercise.
Dante
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php