|
Posted by Chung Leong on 05/27/06 01:31
Oli Filth wrote:
> Hmm, I'd never thought about it like that. You're right of course.
> However, this logic applies to any use of a function/member/method at
> any point. Any time a symbol is used, PHP presumably has to interrogate
> some kind of symbol table to find whether that symbol exists in the
> current scope, and is legal.
Well, you would have to travel up the hierarchy to see if $this is
descended from the class. Not terribly expensive, but sort of pointless
given that the code would blow out anyway as soon as $this is accessed.
And if there's a check, you can't use such nice construct as this:
class A {
private $a = "Hello world";
public function Test() {
echo $this->a;
}
}
class B {
public $a = "The end is near";
public function Test() {
A::Test();
}
}
$b = new B();
$b->Test();
Totally unorthodox, but useful in some situations.
> Political connotations aside ( :) ), it's this kind of nonsense that
> makes me never want to use PHP again, at times! I know that some people
> see this as a useful "feature", but coming from a compiled-language
> background, I see this only as a development nightmare, and a massive
> limitation on language strictness, as you've already commented on...
> (Just in case; yes, I know that PHP isn't the only language that does this.)
One has to make a distinction between different environments though.
With PHP, you can very quickly see the result of a script. If there's a
bug in the code, it's usually quite obvious. You don't really need
warning from the compiler as much compared to a large C++ program.
Navigation:
[Reply to this message]
|