Yep, I agree with this. We'll check but I'm pretty sure we're not corrupting EG(This) (which in any case is an implementation detail and too relevant to this discussion). As in PHP, you can't change the $this pointer, I do think we should have a message about this. I'd suggest an E_WARNING because it's for the same reason as over writing $this that you'd want to take a reference, you shouldn't really do it. We can also mention in the warning that this support will be deprecated in future versions...

Andi

At 08:11 AM 10/3/2005, Rasmus Lerdorf wrote:
Andi Gutmans wrote:
> Assigning to it will break "this" in the symbol table, or EG(This)? If
> it's the latter then it is a problem (and it's the reason I didn't
> support it to begin with).

Given that:

  class foo {
    function bar() {
      $this->a = 1;
      $ref = &$this;
      $ref->b = 2;
      $ref = null;
    }
  }
  $x = new foo;
  $x->bar();
  echo $x->a, $x->b;

Outputs 12 and doesn't appear to cause any major badness internally, I
don't really see any reason to disallow it.  If an E_STRICT could be
raised without affecting performance too much that would be good since
it is a useless assignment.  Given the lack of badness on the php5 side
and the high level of goodness for php4 portability, I say leave it as
it is now.

-Rasmus


Zend/PHP Conference & Expo
Power Your Business with PHP
October 18-21, 2005 - San Francisco
http://zend.kbconferences.com/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to