Re: [RFC] Default constructors

From: Date: Mon, 24 Nov 2014 15:24:28 +0000
Subject: Re: [RFC] Default constructors
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-79127@lists.php.net to get a copy of this message
Dmitry Stogov wrote on 24/11/2014 09:56:
However, I thought about one more inconsistent. Your patch works fine for "parent::" methods but not for "grandparents::" In the following code "default constructor" won't work. class A { } class B extends A { } class C extends B { function __constructor() {
     A::_constructor(); // this won't work
} }
I guess some inconsistency like this is hard to avoid unless the default constructor is actually added to the class's method table, because the code has to specifically check for each case that is to be supported. At risk of flogging a dead horse, this is why I was arguing for the lazy evaluation with new keyword to be abandoned, because it seems like that's the primary compatibility issue with adding a "real" default definition. Reflection would show the method as either "internal" or inherited from some implicit base class. From a user's point of view there should really be no difference between "no constructor" and "constructor which does nothing", IMHO. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#79127) next »