On Wed, Jul 3, 2013 at 11:10 PM, Sanford Whiteman <swhitemanlistens-softw...@cypressintegrated.com> wrote: > > > Not that it would be an argument but just for understanding: Do you know > > any scripting language which has this? > > Dropping the "scripting" part... IIRC, C++ calls ctors without > arguments automatically like in my 'sequentialBefore' napkin sketch. > > C# has language-level support for 'sequentialBefore' type logic in its > initialization list as well (which helps to smooth away the anti-ness > by keeping it out of the ctor code). > > Also, here's a fascinatingly stupid bug-as-feature in AS3 (which I > don't remember anything about, having used it basically procedurally > along time ago) > http://blogs.adobe.com/cantrell/archives/2008/09/be_careful_how.html. > (Call Super hoisting out of conditionals? How could that have seemed > like a good idea?) > > So there is precedent for Contractual Call Super. I don't think the > above implementations are ideal, though, so if someone did go down > this path I think it should be (a) not automatic but dependent on > keyword(s); (b) flexible as far as executing before/after; (c) > deeply-thought-through as far as its impact on class hierarchies that > expand and contract over time. > > -- S. > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >
Hello, I've been thinking about this for a bit and even if you are right about being nice to have a way to call a function always after constructor. It could happen. You could have a DB class and in constructor the user/pass/host/options and then a separate method for init(). But more often than not, I want to be able to dictate what the program is doing when I'm using libraries and so on that I'm extending, not the libraries do stuff on their own. In most of the cases, I know much better that the library author how I want to use the library for my use case. In your case, if you want to have a method always called then just document it properly. Except for cases when you don't have access to the source code, encrypted maybe?, I really don't see why just documenting this isn't enough. Think for a moment on the reverse of this: you have this nice feature in the language, but then the people start abusing it. Could you imagine yourself trying to use the latest XGreatLib v3.0 but you want to skip some constructor due the fact that you know better. What do you do then? And yeah, maybe the library authors are not that careless to use such an abusive functionality, but what if you have this in your code and you decide to remove the new keyword 'super' or whatever so that you can skip that constructor? Could it be that you just broke your whole app because of this? Please think of the downsides as well when thinking of new features like this, the implications for the whole eco-system could be huge for just wanting to skip some proper documentation. Cheers. ---- Florin Patan https://github.com/dlsniper http://www.linkedin.com/in/florinpatan -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php