Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:68040 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37298 invoked from network); 3 Jul 2013 12:46:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jul 2013 12:46:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=terence.copestake@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=terence.copestake@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.171 as permitted sender) X-PHP-List-Original-Sender: terence.copestake@gmail.com X-Host-Fingerprint: 209.85.223.171 mail-ie0-f171.google.com Received: from [209.85.223.171] ([209.85.223.171:34586] helo=mail-ie0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/D0-30639-70D14D15 for ; Wed, 03 Jul 2013 08:46:00 -0400 Received: by mail-ie0-f171.google.com with SMTP id qd12so207199ieb.30 for ; Wed, 03 Jul 2013 05:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=JewIjNiygc75a0dErnyAM41gPhk0lf6bbkVYWg8yIoQ=; b=NIA/U8W1Z9/kgDawT0lFlg/JmiixL6+dzo6luqbsd1xonM30THc19JRVgXhX9t/9JX IppApEiJUt5Onl5tsrouMPM/bAE1uXzkwsQXlYVmSSIayK2xruZZ4zQnjbpfib0jrqIm heXKU7AGXFxAyk02tWntNvOlBySyHhKqJCum4yLIGXkgwIJcSKb63IHbRFz5LnMxkRo4 RuHGM78/Hgrn4R1eKLviv0LNAhWoB/rO/9VB6Gqmp6XXhk5NH5LXXalo1mRPIE3f4CXi /Qew4eReqakIIUvY3/Bb84DH6BOtMINkpJsSAAiPOOAZIdVaMA9cRqsjQo/mpHsRCB4J +Y+A== MIME-Version: 1.0 X-Received: by 10.42.68.18 with SMTP id v18mr364669ici.87.1372855557236; Wed, 03 Jul 2013 05:45:57 -0700 (PDT) Received: by 10.50.95.138 with HTTP; Wed, 3 Jul 2013 05:45:57 -0700 (PDT) Date: Wed, 3 Jul 2013 13:45:57 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=20cf303636d9d1314e04e09ad787 Subject: New feature: sequential constructors From: terence.copestake@gmail.com (Terence Copestake) --20cf303636d9d1314e04e09ad787 Content-Type: text/plain; charset=ISO-8859-1 Hello, all. On one or two occasions I've encountered a problem when designing a base class, where I wish to implement important set-up functionality in the constructor, but am limited in how to ensure that the base constructor functionality is unmolested whilst not restricting any inheriting classes in their use of a constructor, as would be the case when using the final keyword. I also don't feel 100% comfortable trusting the inheriting class to call the parent constructor. The idea I'm presenting for discussion here is to have some kind of (keyword-driven?) hierarchy for constructors, whereby it's possible to have for example sequential constructors, using syntax similar to: ... public sequential function __construct($ ... In this scenario, constructors defined as sequential are, as the name implies, called in sequence. If the introduction of a new keyword is problematic, perhaps this same behaviour could be enacted in cases where an inheriting class has a constructor and the base class' constructor is defined as final i.e. rather than causing an error, the final constructor is executed first, followed by any other constructors in the hierarchy. If this keyword is introduced, perhaps it this idea could also be expanded to allow for sequential methods in general, which would behave similarly - and may be a gateway to function overloading (or similar behaviour). I'm open to people pointing out design flaws/implementation difficulties with this; pull no punches. Thanks. --20cf303636d9d1314e04e09ad787--