Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62263 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90849 invoked from network); 19 Aug 2012 16:06:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Aug 2012 16:06:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 64.22.89.133 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 64.22.89.133 oxmail.registrar-servers.com Received: from [64.22.89.133] ([64.22.89.133:45323] helo=oxmail.registrar-servers.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D5/73-03087-6EE01305 for ; Sun, 19 Aug 2012 12:06:00 -0400 Received: from [192.168.0.200] (5ad4bfa0.bb.sky.com [90.212.191.160]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by oxmail.registrar-servers.com (Postfix) with ESMTPSA id 9D7FB758013; Sun, 19 Aug 2012 12:05:53 -0400 (EDT) Message-ID: <50310EC5.7010107@ajf.me> Date: Sun, 19 Aug 2012 17:05:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Derick Rethans CC: Nikita Popov , Stas Malyshev , Sherif Ramadan , Larry Garfield , "internals@lists.php.net" 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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Generators in PHP From: ajf@ajf.me (Andrew Faulds) On 19/08/12 17:03, 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 can't say much about this in particular, but using hacks and kludges to implement language features is probably not the best of ideas. > Derick > -- Andrew Faulds http://ajf.me/