home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 264,012 of 264,096   
   Lawrence =?iso-8859-13?q?D=FFOlivei to All   
   Re: New PHP kits available (and a progra   
   02 Jan 26 03:44:11   
   
   From: ldo@nz.invalid   
      
   On Thu, 1 Jan 2026 20:51:57 -0500, Arne Vajhøj wrote:   
      
   > function test($v) {   
   >      echo "B1 ($v)\n";   
   >      $v = Fiber::suspend(123);   
   >      echo "B2 ($v)\n";   
   >      $v = Fiber::suspend(456);   
   >      echo "B3 ($v)\n";   
   >      return 789;   
   > }   
   >   
   > echo "A1\n";   
   > $ctx = new Fiber('test');   
   > $v = $ctx->start('ABC');   
   > echo "A2 ($v)\n";   
   > $v = $ctx->resume('DEF');   
   > echo "A3 ($v)\n";   
   > $v = $ctx->resume('GHI');   
   > if($v === null) $v = $ctx->getReturn();   
   > echo "A4 ($v)\n";   
      
   Python version (produces same sequence of output values):   
      
       def test(v) :   
           print("B1", v)   
           v = yield 123   
           print("B2", v)   
           v = yield 456   
           print("B3", v)   
           return 789   
       #end test   
      
       try :   
           print("A1")   
           coro = test("ABC")   
           v = coro.send(None)   
           print("A2", v)   
           v = coro.send("DEF")   
           print("A3", v)   
           v = coro.send("GHI")   
       except StopIteration as ret :   
           print("A4", ret.value)   
       #end try   
      
   Note this doesn’t even need a coroutine function (async def); a simple   
   generator will do.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca