Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62264 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96983 invoked from network); 19 Aug 2012 18:16:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2012 18:16:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:62085] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/44-03087-B6D21305 for ; Sun, 19 Aug 2012 14:16:12 -0400 Received: by lahl5 with SMTP id l5so3005611lah.29 for ; Sun, 19 Aug 2012 11:16:08 -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=YyZZtfqPKQD38RforABI8S5Z2LIYGchMMylqeY/nmDs=; b=cA3R7N9Iq2fsDg6OD9Ql2Ro3f7nm4Ci0kYAfuBf7H5HpG3sZdjGewdzjrtjxBjGbkl R/h2PVwyuY9iJZpdgyIbkx2hHGgyPEBZu99sV4AX3pUHsnrTqqO6B2Ls6eRcLqWCMXZQ F649wNwoLeFAvVDlLjRVFZfZNtkCU7Lj5/f5y8VCHzyoW4KeAK9tk4nDdN8FIiXabPXA 2aRRJT8MlXp0Q+554r/S/KJAA6oX1zojyWO2zLrOzguIpvFwWQFca4HWvgfWvM/jwudX GeDGUy9MmqGDBqXBDnmLR50dKc2MQ4MhUeJO5lRMEAqI8TCYDkjsyqBtRWD7Eqc+I6hp cejA== MIME-Version: 1.0 Received: by 10.112.10.198 with SMTP id k6mr5162701lbb.83.1345400168592; Sun, 19 Aug 2012 11:16:08 -0700 (PDT) Received: by 10.152.122.51 with HTTP; Sun, 19 Aug 2012 11:16:08 -0700 (PDT) In-Reply-To: References: <5010138D.5050804@ajf.me> <501015B9.6050704@ajf.me> <501058B9.5050004@lsces.co.uk> <501249B6.5070507@lsces.co.uk> <50128825.4020902@lsces.co.uk> <50231FAD.40104@garfieldtech.com> <50306B5E.7050106@sugarcrm.com> Date: Sun, 19 Aug 2012 20:16:08 +0200 Message-ID: To: Derick Rethans Cc: Stas Malyshev , Sherif Ramadan , Larry Garfield , "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Re: Generators in PHP From: nikita.ppv@gmail.com (Nikita Popov) On Sun, Aug 19, 2012 at 6:03 PM, Derick Rethans wrote: > On Sun, 19 Aug 2012, Nikita Popov wrote: > >> On Sun, Aug 19, 2012 at 6:28 AM, Stas Malyshev wrote: >> > >> >> For PHP we would need to have some similar behavior. PHP's current >> >> exception model is incompatible with GeneratorExitException >> >> (because PHP does not have BaseExceptions). So what I'd probably do >> >> instead is monkeypatch a ZEND_RETURN opcode at the current >> >> execution position and >> > >> > Patching opcodes is not a good idea, since opcodes could be cached, >> > and the cache can be shared between different processes. >> >> Patching a single opcode should be okay, because it does not require >> modification of the op_array. Only execute_data->opline has to be >> changed (and the execute data is not shared). The exception handling >> mechanism currently uses the same technique. It patches an >> ZEND_HANDLE_EXCEPTION opcode into the current position. > > Please do not modify opcodes for running code. That is a ginormous hack > and it *will* cause problems with some code. I don't see how it can cause problems (exception handling works after all), but I agree that it's better to avoid. Thinking about it again, there shouldn't be necessity for it. But right now I'm waiting for laruence to refactor the finally handling code. After that's done I'll see how to best implement it ;) Nikita