FAQ

[PHP-INTERNALS] Closures: $this support removed for 5.3 beta 1 (but NOT in HEAD!)

Christian Seiler
Jan 26, 2009 at 11:20 pm
Hi,

as Lukas and Johannes have requested, I have removed $this support from
Closures in PHP 5.3.

Technical details on the changes can be found here:

http://wiki.php.net/rfc/closures/removal-of-this

(I didn't have time to write new tests for everything, I just removed
those tests which didn't make sense at all and changed the rest in order
to accommodate the current semantics.)

I'd like to add that the Reflection part was really quite a mess.
Marcus's property-calling-patch was not correctly revoked from the
Reflection part (there was still quite a bit of code there in
php_reflection.c). Also there were (independent of that) some changes to
my original proposal that - as far as I know - were never discussed
on-list. Which in this case caused two problems: Inconsistencies (see
ReflectionParameter part in the above page) and there were some memory
management issues (which don't occur if you keep your objects always
around at least as long as the reflection objects themselves - and thus
not during simple tests - but nevertheless issues). I don't want to
assign blame here to anyone (the errors are errors I could have *easily*
made myself), I just want to point out that if the changes had actually
been discussed beforehand, this could have been avoided.

I recognize that not everybody will be 100% happy with the changes I
made to reflection even in light of the $this removal. However, in the
few days it took until the beta1 freeze (today) I think I have found the
sanest consistent solution for the problems. I do however acknowledge
that we may need to tweak some minor things wrt. reflection here and
there after beta 1.

Also: I have NOT changed HEAD. This is only in the PHP_5_3 branch. I
have also NOT ported the MM fixes to HEAD. It is far less trouble to
simply wait until we have figured out $this in closures.

---------------------------- snip -------------------------------------

In light of everything that went wrong with Closures and OOP due to
people wanting to improve something, I'd like to propose the following:
Whenever *any* change is made to either the language core itself or to
Reflection - that is not just a simple bugfix but rather a change in
certain semantics - there should be an RFC page in the wiki for this
purpose with LOTS of userland example code to demonstrate the semantics
and to be able to think it all through more thoroughly. And only after
an on-list discussion the changes should be made. And a page in the wiki
should really be required instead of a simple mail (and the wiki page
should actually be updated) because when it really comes down to it, you
don't find the mail again.

With Closures and OOP we had the situation that changes were committed
both to Reflection and core where only later other people actually saw
what they meant and this caused a discussion after the code was in a
half-baked state. Also, there was not enough userland example code
available from all sides for quite a while so that the discussion
remained on the same spot for too long. I really would like to avoid
that in the future and thus I think the above idea would be really helpful.

To sum it up again: For every non-bugfix change to core or Reflection
[*] that affects semantics: proposal in the wiki, lots of userland
example code to demonstrate the change, discussion on-list.

[*] Possibly more extensions. Reflection is especially tricky since it
has to reflect the PHP core quite well on the one hand and on the other
hand has to be very self-consistent which is quite hard due to all the
inter-dependencies. It took me the last few days to figure the above
changes all out and to make them consistent.

Regards,
Christian
reply

Search Discussions

1 response

  • Lukas Kahwe Smith at Jan 26, 2009 at 11:35 pm

    On 27.01.2009, at 00:19, Christian Seiler wrote:

    as Lukas and Johannes have requested, I have removed $this support
    from
    Closures in PHP 5.3. Thx!
    Technical details on the changes can be found here:

    http://wiki.php.net/rfc/closures/removal-of-this

    (I didn't have time to write new tests for everything, I just removed
    those tests which didn't make sense at all and changed the rest in
    order
    to accommodate the current semantics.)
    So please everybody hammer these changes hart.
    I'd like to add that the Reflection part was really quite a mess.
    Marcus's property-calling-patch was not correctly revoked from the
    Reflection part (there was still quite a bit of code there in
    php_reflection.c). Also there were (independent of that) some
    changes to
    my original proposal that - as far as I know - were never discussed
    on-list. Which in this case caused two problems: Inconsistencies (see
    ReflectionParameter part in the above page) and there were some memory
    management issues (which don't occur if you keep your objects always
    around at least as long as the reflection objects themselves - and
    thus
    not during simple tests - but nevertheless issues). I don't want to
    assign blame here to anyone (the errors are errors I could have
    *easily*
    made myself), I just want to point out that if the changes had
    actually
    been discussed beforehand, this could have been avoided.

    I recognize that not everybody will be 100% happy with the changes I
    made to reflection even in light of the $this removal. However, in the
    few days it took until the beta1 freeze (today) I think I have found
    the
    sanest consistent solution for the problems. I do however acknowledge
    that we may need to tweak some minor things wrt. reflection here and
    there after beta 1.

    <snip>

    thx for this summary and proposal .. its important that we continuesly
    seek ways to optimize this often asynchronous development sprints by
    the various people across the world .. since I do not have the
    expertise to comment I will leave it to others to reply.

    regards,
    Lukas Kahwe Smith
    mls@pooteeweet.org

Related Discussions

Discussion Navigation
viewthread | post