Re: using $this-> implicitly inside same class
[email protected] wrote:
I really do not see the need to keep telling php I'm refering to the properties and method of the class I'm already in, when php 5 should be able to deduce this from the context of the class I'm coding in.
This would turn all local variables into global ones in regards to an object instance. One of the big benefits of PHP is that the default for variables is that they are local, you never have side-effects unless you specify it, i.e. you can safely introduce local variables without clashing with properties or global variables. Without $this-> you'd have to either ensure manually that you never have name clashes or introduce a declaration for local variables a la "my $var" in Perl. Neither is desirable. Ruby chose to replace "this->" by "@" but the basic concept is the same as in PHP.
Bottom-line: While you're proposal seems to improve the simple case it would introduce a big draw-back for everything a bit more complex, i.e. where you have temporary local variables - which isn't _that_ far fetched :-).
- Chris
Thread (6 messages)