Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100353 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88972 invoked from network); 2 Sep 2017 12:19:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2017 12:19:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.52 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.52 mail-wm0-f52.google.com Received: from [74.125.82.52] ([74.125.82.52:37078] helo=mail-wm0-f52.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/71-04538-9E1AAA95 for ; Sat, 02 Sep 2017 08:19:53 -0400 Received: by mail-wm0-f52.google.com with SMTP id u26so14032184wma.0 for ; Sat, 02 Sep 2017 05:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:cc:from:message-id; bh=TvPLwlVCwlnmjwdrRwDvXbptp7QfTcHQ07OFHJgFoFY=; b=pW3OhzIq815duQoEclBhVo2lkgilKjQ7VojIO2u4eKIlkgh4LG7t4lMKTi1JXO9Md9 8MEXlsnFwYSW5vkra9wR4AJUjfHLwfATgKHGnLUsBm2gQNS1+0u/1ofHo4IuR5Op1nbd lUgvLDJjz5vzBtKb367bzpovb5fpT/Gi6ikT5Sh+rbJ1Lk9baVC/C/TOCgAomT7MRUch yllFTiC79HlN1pxlzqVAFeW9pS2ZzmqoLcSAmFN1Bncu8i/NlXTjw95WjLvJ7vfv3lE8 ciozeChOw2n0zKwZNFvCAHW1qbVqgO03TkMaQGbDbYSsnma6EbCVGHzvZkZSl1+huX6M hxNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:cc:from:message-id; bh=TvPLwlVCwlnmjwdrRwDvXbptp7QfTcHQ07OFHJgFoFY=; b=gWj6B61Kq2w27ivLNzw5z265vVojfBewPXFiB3DREjNYW9UBtzVobPqXp+lugiXXut t/llYSTjD7r1/0KoYa7GxhuE+V2D+1d/FAEz2fTLpN3MCp3DAIYhSEnIwmAr0y2q0i3L 9n/1xUFzHx0FXiukbdGw23DOf7P5TsBGMhawGEqyCYgIhIMQN/Lv3VARfol/HXbCGWNu YUqeJJUpInxbvaQGjjRmgYmY1LLjWaC+gt+0JDHRuPz2NedjnSPoGBye228Gp5Dt4wAs aSZ1Dk4HGKPCMDy7BDgjhoi2YeDWYRrhJGmscotRTFEVhGYTQPhy82etPoXDNXGfO9KP 5UQg== X-Gm-Message-State: AHPjjUglSpO503sxDz3DweAS+QmWy9Z0WwiVqaRoWWizp0MX726QPc3N fn7ENbJJyq20vElh X-Google-Smtp-Source: ADKCNb4G0L+zv2xbwXDAUL0CCp1mok3IC6wqdqmAKOqMpP3Eve/ihWYPMcwJgkuixzEBkFCnBCeJUQ== X-Received: by 10.28.184.211 with SMTP id i202mr915576wmf.6.1504354790073; Sat, 02 Sep 2017 05:19:50 -0700 (PDT) Received: from ?IPv6:2a00:23c4:4b81:ae00:9c1f:2a03:8ab6:1274? ([2a00:23c4:4b81:ae00:9c1f:2a03:8ab6:1274]) by smtp.gmail.com with ESMTPSA id c56sm4816907wrc.1.2017.09.02.05.19.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Sep 2017 05:19:49 -0700 (PDT) Date: Sat, 02 Sep 2017 13:19:46 +0100 User-Agent: K-9 Mail for Android In-Reply-To: <8DB5D7F2-CB7A-4324-AB9F-D9934DD9C108@lvht.net> References: <7E991FBB-C115-4AB9-B904-EBE7C0F24089@lvht.net> <8DB5D7F2-CB7A-4324-AB9F-D9934DD9C108@lvht.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable CC: internals@lists.php.net Message-ID: Subject: Re: [PHP-DEV] add Fiber (sackful coroutine) support From: rowan.collins@gmail.com (Rowan Collins) On 1 September 2017 14:02:29 BST, Haitao Lv wrote: > >Fiber is a lightweight thread=2E Please see >https://en=2Ewikipedia=2Eorg/wiki/Fiber_(computer_science) >And ruby support Fiber=2E Please see >https://ruby-doc=2Eorg/core-2=2E4=2E1/Fiber=2Ehtml Ah, thanks, that makes more sense now=2E I note that the examples there all implement it not as a keyword, but as a= library function, which maybe makes more sense: whereas "yield" turns a fu= nction declaration into a generator declaration, "Fiber\yield", as we might= call it, is just a function call which can happen anywhere and manipulates= some global state=2E The choice of "await" also feels odd: you're not awaiting the thing on the= right-hand side of the keyword, you're sending it somewhere and awaiting s= omething else=2E > You can see the await as a resumable return=2E The value after it >will be returned and the function >will be paused=2E Again, this explanation doesn't make sense if you can call foo() without a= ny Fiber code=2E If there isn't an active Fiber to pause, the "await" line = can't "return" anything; it will presumably throw an error of some sort=2E function foo($x) { $y =3D Fiber\yield($x); return $x + $y; } echo foo(1); The 1 isn't "returned" to the echo, it's passed off to a global function f= or further processing=2E This makes much more sense to me than implying tha= t foo() is no longer a normal function=2E >> Your ->resume() doesn't seem to do anything a normal generator can't, >except that the yield is nested deeper=2E > >The await is a nested deeper yield! Yes, I understand that, but that seems to be completely unrelated to the A= PI design of having resume() act as start, continue, and final result all r= olled into one=2E As I say, I didn't entirely follow the reasoning for allo= wing return in generators, but if Fibers are used for the same purpose, I w= ould expect the same concerns to arise=2E However, I think the comparison to generators may be more distracting than= useful, as they seem to be very different solutions to the same or related= problems=2E Regards, --=20 Rowan Collins [IMSoP]