Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98133 invoked from network); 3 Jul 2013 22:27:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2013 22:27:44 -0000 Authentication-Results: pb1.pair.com header.from=florinpatan@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=florinpatan@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.174 as permitted sender) X-PHP-List-Original-Sender: florinpatan@gmail.com X-Host-Fingerprint: 209.85.214.174 mail-ob0-f174.google.com Received: from [209.85.214.174] ([209.85.214.174:43224] helo=mail-ob0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/C2-15343-F55A4D15 for ; Wed, 03 Jul 2013 18:27:43 -0400 Received: by mail-ob0-f174.google.com with SMTP id wd20so821378obb.33 for ; Wed, 03 Jul 2013 15:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=7jj6Cw+1RWs70NJ49MHJKlYdC4t2sIiaZo7tfXsfMW0=; b=IpXZt4y4jaVw0Zgb1M6hHalx2e9ux5Zf0qh6FktK5mvhWPkQTx5QnNnQKw1n5mkldS YocG+wqaAbTJbA36ur24+ygym/fP/0KE5w+0JiUJ+i8nasPJ0/P7MpoaxF4AzIFveGoQ l7DnuZQedPo1/yx5EQNmVYE9SH2bCGm+rJQBYo9/oE5k8rqm4or4kvZoFP36nY/1HrwN HP6tDPlrqi1wczuMqWdxg+hE9ECfzK0/SjONqNQiwxA9q+NjEqnPuiXcswG5ZOAUlKvk aO6oB9yxh9oqt2cyg1zp6zHeWA4OqAJHTxCmWHqx65X97ztSl+6/xiY85N5ogo4PgzHm zuuw== X-Received: by 10.182.32.4 with SMTP id e4mr3154957obi.16.1372890460198; Wed, 03 Jul 2013 15:27:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.76.18.161 with HTTP; Wed, 3 Jul 2013 15:27:09 -0700 (PDT) In-Reply-To: <1233362173.20130703171037@cypressintegrated.com> References: <1668753851.20130703140514@cypressintegrated.com> <51D46981.7050902@b1-systems.de> <1579496223.20130703144829@cypressintegrated.com> <51D477C5.6020907@b1-systems.de> <1233362173.20130703171037@cypressintegrated.com> Date: Thu, 4 Jul 2013 00:27:09 +0200 Message-ID: To: Sanford Whiteman Cc: Ralf Lang Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] New feature: sequential constructors From: florinpatan@gmail.com (Florin Patan) On Wed, Jul 3, 2013 at 11:10 PM, Sanford Whiteman 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