Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61686 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1728 invoked from network); 24 Jul 2012 14:37:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2012 14:37:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.49 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qa0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:59373] helo=mail-qa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/57-17533-113BE005 for ; Tue, 24 Jul 2012 10:37:05 -0400 Received: by qabj40 with SMTP id j40so2061892qab.8 for ; Tue, 24 Jul 2012 07:37:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=E/VN7aqLd9N418W1KYadBG0HSO/26bYrfvRkzFXmpOQ=; b=CBY9lHnk1jCLBMxxGj4YyDdzy3yjjSxZh6exksmoYp38yeynp32r90W5ShYnFc06mz sxRXgkEDYBOKbAH5MQLv39fpLPU2OdQ5LyIyMdhC6FxEoJpB/i63SE4/BcnDE0AhWcHt 0xO6cIGJAhwS413AJlfyGnimhyk7HF2r9788hoGWuGSD9xiB1zpSJz3W+S9eYtvJM8zn +TvOjQt0ZR0IVKNDa7KIyas9fnxWXdYUdZ8ORF3ctyNfOMDGTV5/2M3Hi7tyY52YyesM ZMxnFZ6EDurFjwrjYdpYAVAe68xgKTj0b/wsrBzg8iah4GdcF9+3rcmiPRQmunHPN6mO qZQg== MIME-Version: 1.0 Received: by 10.224.194.137 with SMTP id dy9mr31010157qab.67.1343140623062; Tue, 24 Jul 2012 07:37:03 -0700 (PDT) Received: by 10.229.182.4 with HTTP; Tue, 24 Jul 2012 07:37:02 -0700 (PDT) In-Reply-To: <1343137723.2084.301.camel@guyrush> References: <1343137723.2084.301.camel@guyrush> Date: Tue, 24 Jul 2012 10:37:02 -0400 Message-ID: To: =?ISO-8859-1?Q?Johannes_Schl=FCter?= Cc: Laruence , PHP Internals Content-Type: multipart/alternative; boundary=20cf300fb503b8964504c5944b56 Subject: Re: [PHP-DEV] [RFC] Supports 'finally' keyword for PHP exceptions From: ircmaxell@gmail.com (Anthony Ferrara) --20cf300fb503b8964504c5944b56 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Johannes, On Tue, Jul 24, 2012 at 9:48 AM, Johannes Schl=FCter wrote: > On Tue, 2012-07-24 at 19:20 +0800, Laruence wrote: > > Hi: > > As the previous threads disscussed, I make a implemention. > > > > here is the RFC: https://wiki.php.net/rfc/finally > > > > any suggestions? > > > > thanks > > As PHP has destructors there is less need for "finally" compared to > other languages. What are the cases where an extra language construct is > needed? (i.e. one can also use C++-like RAII things ...) > I'm not sure I agree with that statement. Finally is a routine level cleanup tool, while destructors are object level cleanup tools. So while it is possible to make every routine into an object, at some point it just becomes ridiculous. That means that every method that allocates resources would need to be a first-class object, which could get quite messy very fast. If you went by "possible", half the proposals for the language wouldn't be accepted (password hashing, generators, goto, Class name to scalar resolution, T_AS for closures, type hints, call-time dereferencing, traits, classes, etc). All of that behavior is possible without the language sugar that they bring. The main drive for adding them is that it makes a developers life a lot easier. Rather than dealing with yet another level of abstraction to add an object, adding a simple finally clause would make implementing that sort of cleanup FAR easier. Additionally, the destructor isn't called until the object goes out of scope. That could be after the method call (a scope block higher). So the only way to fully emulate the finally block would be to construct the object inside of the method in question. So it's not as simple as "just put it in a destructor and you'll be fine"... My $0.02 at least... --20cf300fb503b8964504c5944b56--