[thelist] another php question: object reference syntax
Jonathan_A_McPherson at rl.gov
Jonathan_A_McPherson at rl.gov
Wed Jul 17 17:09:01 CDT 2002
Jackson,
> If you think having to type '->' instead of '.' is annoying though, wait
until
> you write your own PHP classes. Instead of variables defaulting to class
> scope in methods, you have to explicitly specify class scope by placing
> $this-> in front of the variable name. [g] If the PHP designers ever
start
> adding polymorphism, templates, or multiple inheritance, I'd hate to see
what
> the syntax would look like then.
Many programmers (myself included) actually consider the mandatory $this->
to be a desirable feature. Many "newer" languages force you to specify class
scope with a "this" pointer when you're in a method, so that there is no
risk of confusion between local method scope and class scope.
The author of the Python language states[1]:
"There is no shorthand for referencing data attributes (or other methods!)
from within methods. I find that this actually increases the readability of
methods: there is no chance of confusing local variables and instance
variables when glancing through a method."
[1] http://www.python.org/doc/current/tut/node11.html
--
Jonathan McPherson, LMIT/SD&I
Software Engineer & Web Systems Analyst
email / jonathan_a_mcpherson at rl dot gov
More information about the thelist
mailing list