Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60797 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 31236 invoked from network); 11 Jun 2012 21:12:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2012 21:12:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.160.170 mail-gh0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:34243] helo=mail-gh0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 57/47-18025-52F56DF4 for ; Mon, 11 Jun 2012 17:12:06 -0400 Received: by ghbg2 with SMTP id g2so3287206ghb.29 for ; Mon, 11 Jun 2012 14:12:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-gm-message-state; bh=y3kZN2rK/Sln66Owjp2bpiLJJqz18jBwo8RdiUBo5Os=; b=eF8Kn+Sk7+kTEOCqc5JWOIIwFidsCt/pO9zCajUxmblocOPBVkI9/49Hxchu/Gsb8k az9SD79nTC9tde/DxPOKj8vrFUIgbfF4n6/4yF9gFIUhsPu/cqiP9yo9qv3uCBTOCfV4 GdUyN89++FkeVNJIVYAPjC6VZQYaO2TSWEl4IuKNpX44GJ8kTl2OBYNapKvtLxE/pbhh UCb1Gj4mlIuw72M42P6YMUPHT9VsGv1f0duUFQnjQ9sN9KU9JxAPTm+Ig2yBgezm9TqW aDHu37ZvwlPYISqEGoKTWsA/bgn3fPn7qnfYanfKmHnCHeY67qyNJ9f7TJdiCHDSnQMq CxVA== MIME-Version: 1.0 Received: by 10.236.73.6 with SMTP id u6mr23645744yhd.31.1339449123296; Mon, 11 Jun 2012 14:12:03 -0700 (PDT) Received: by 10.101.54.13 with HTTP; Mon, 11 Jun 2012 14:12:03 -0700 (PDT) In-Reply-To: <18e2afd236c1f0c5901824fa6ab5e9f5.squirrel@webmail.klapt.com> References: <18e2afd236c1f0c5901824fa6ab5e9f5.squirrel@webmail.klapt.com> Date: Mon, 11 Jun 2012 17:12:03 -0400 Message-ID: To: ab@php.net Cc: Laruence , Nikita Popov , PHP internals Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQl7k3sYL9hUJOXeSDaFITjHxBzD6Df641GQRz6hclUtdpStjfZZR7ijmErcqWp20IBu8Iuy Subject: Re: [PHP-DEV] Generators in PHP From: tom@punkave.com (Tom Boutell) Can you really use setjmp and longjmp in that way safely? I thought it was only safe to longjmp "back," not "forward" - you can use them to fake exception support but that's it because you'll smash the stack otherwise. Something like that... OK, I'm thinking of this: "Similarly, C99 does not require that longjmp preserve the current stack frame. This means that jumping into a function which was exited via a call to longjmp is undefined.[6] However, most implementations of longjmp leave the stack frame intact, allowing setjmp and longjmp to be used to jump back-and-forth between two or more functions=97a feature exploited for multitasking." It does not sound like something that can be done in portable C. On Mon, Jun 11, 2012 at 4:13 PM, Anatoliy Belsky wrote: > Hi, > > it'd be really cool if the implementation would do the "real" context > switch in c, which would be the true basis for spl_coroutine. The current > implementation seems not to do that. > > Context switch in c would be comparable with threads. In fact coroutines > would be a comensation for lacking threads functionality in php, as they > are already implemented on most popular platforms. However, it would > require some platform specific libs (fibers on windows, setjmp and longjm= p > on unix(like)). > > Coroutines in c are per se thread safe, so implementing them once would > not hurt both ts and nts. Additionally, in some cases coroutines can even > have advantages over the "usual" preemptive threads. > > Regards > > Anatoliy > > Am Mi, 6.06.2012, 04:42 schrieb Laruence: >> On Wed, Jun 6, 2012 at 10:27 AM, Laruence wrote: >>> On Wed, Jun 6, 2012 at 10:15 AM, Laruence wrote: >>>> Hi Nikita: >>>> >>>> =A0 =A0the most important part to me is how did you implemented `yield= ` >>>> keyword, =A0 is there a whole patch file I can look into? >>> Nervermind, =A0I will check the branch out later >>> >>> thanks >> >> After a quick look, =A0I think the main idea should goes to two parts: >> >> 1. implement yield (Zend) >> 2. implement spl_generators but not generator class (Spl) >> >> then we can implement spl_coroutine later base on this. =A0what do you >> think? >> >> thanks >>>> >>>> =A0 =A0what will happen if you use a `yield` in a normal function? >>>> >>>> =A0 =A0actually, =A0I tried to implemented coroutine, but since I coul= d not >>>> find a way to make zend_execute interruptable, then I didn't make it. >>>> >>>> =A0 =A0so, I am really interesting of this tech-specific :) >>>> >>>> thanks >>>> >>>> On Wed, Jun 6, 2012 at 1:35 AM, Nikita Popov >>>> wrote: >>>>> Hi internals! >>>>> >>>>> In the last few days I've created a proof of concept implementation >>>>> for generators in PHP. It's not yet complete, but the basic >>>>> functionality is there: >>>>> https://github.com/nikic/php-src/tree/addGeneratorsSupport >>>>> >>>>> The implementation is outlined in the RFC-stub here: >>>>> https://wiki.php.net/rfc/generators >>>>> >>>>> Before going any further I'd like to get some comments about what you >>>>> think of adding generator support to PHP. >>>>> >>>>> If you don't know what generators are you should have a look at the >>>>> "Introduction" section in the above RFC or in the Python documentatio= n >>>>> at http://wiki.python.org/moin/Generators. >>>>> >>>>> Nikita >>>>> >>>>> -- >>>>> PHP Internals - PHP Runtime Development Mailing List >>>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>>> >>>> >>>> >>>> >>>> -- >>>> Laruence =A0Xinchen Hui >>>> http://www.laruence.com/ >>> >>> >>> >>> -- >>> Laruence =A0Xinchen Hui >>> http://www.laruence.com/ >> >> >> >> -- >> Laruence =A0Xinchen Hui >> http://www.laruence.com/ >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com