Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85366 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34683 invoked from network); 21 Mar 2015 13:15:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2015 13:15:06 -0000 Received: from [127.0.0.1] ([127.0.0.1:24612]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id CD/C2-18917-9DE6D055 for ; Sat, 21 Mar 2015 08:15:05 -0500 Authentication-Results: pb1.pair.com header.from=contact@geolim4.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=contact@geolim4.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain geolim4.com designates 212.129.18.216 as permitted sender) X-PHP-List-Original-Sender: contact@geolim4.com X-Host-Fingerprint: 212.129.18.216 houblon.geolim4.com Received: from [212.129.18.216] ([212.129.18.216:33162] helo=houblon.geolim4.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B4/F0-18917-D806D055 for ; Sat, 21 Mar 2015 07:14:10 -0500 Received: from mail-qg0-f43.google.com (mail-qg0-f43.google.com [209.85.192.43]) (Authenticated sender: contact@geolim4.com) by houblon.geolim4.com (Postfix) with ESMTPSA id 854D2EC006A for ; Sat, 21 Mar 2015 13:14:01 +0100 (CET) Received: by qgew92 with SMTP id w92so38048043qge.2 for ; Sat, 21 Mar 2015 05:14:00 -0700 (PDT) X-Received: by 10.55.20.213 with SMTP id 82mr150618656qku.46.1426940040522; Sat, 21 Mar 2015 05:14:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.90.36 with HTTP; Sat, 21 Mar 2015 05:13:30 -0700 (PDT) Date: Sat, 21 Mar 2015 13:13:30 +0100 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a11400b2a3b3f1a0511cb5e79 Subject: RFC: Nested enclosing returns From: contact@geolim4.com ("Georges.L") --001a11400b2a3b3f1a0511cb5e79 Content-Type: text/plain; charset=UTF-8 Hi php internals, After some long and deep research i finally decided to write my first RFC about a feature i'd be interested to be improved in the php core: *Nested enclosing returns* The main purpose, as the title say, is to have the possibility to nest multiple return like we can do currently with break/continue. I thinks it'll being better with a scheme: function foo($foo = true) { if(!$foo) { return false, 3;// Please note the second return argument is the return nesting level } else { return true;// Default nested return argument is always equal to 1 (if not specified, current) } } function bar($foo = true) { foo($foo); // Some stuff that will never be executed if $foo == false and nested return argument = 2 echo 'Hi jon !'; } function baz($foo = true) { echo 'Hi bertie !'; foo($foo); // Some stuff that will never be executed if $foo == false and nested return argument = 3 echo 'Hi freddy !'; } baz(true); // Display: // Hi bertie ! // Hi jon ! // Hi freddy ! baz(false); // Display: // Hi bertie ! Benefits: -Wont break compatibility -May improve code interpretation speed due to part of code skipped by the nested return. -Allow "dynamic" return expressions. Inconveniences: -May complicate debug/backtrace Regards, Georges.L --001a11400b2a3b3f1a0511cb5e79--