Vivian Steller writes:

> hello,
> talking about php5, i'm missing "read-only" attributes/variables for
> classes/objects. i.e. this would be very useful for implementing the new
> DOM Level 3 Interfaces as given in http://www.w3.org/TR/2003
> CR-DOM-Level-3-Core-20031107/idl-definitions.html .

...

> If anybody has an acceptable fake-solution, please let me know...
> thanks

I don't think there's a good reason not to have read-only members.
Java and C++ don't either, but Eiffel does.  You fake it by declaring
them private and writing a get_foo() method for each one.  Done this
way it it is tedious and ugly, but by overloading member access with
the __get( $name ) method, you can achieve the same functionality with
fewer lines of code and a cleaner interface to client classes.  See
under overloading in http://www.php.net/zend-engine-2.php for
examples.

-- 

    __o    Alex Farran
  _`\<,_   Analyst / Programmer
 (_)/ (_)  www.alexfarran.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to