97a23e5ea7
Updates continuations to allow yielding of a key-value pair from a generator. Adds bytecode instructions (PackContK, ContKey) for using the new feature, and adds IR instructions (ContUpdateIdx, ContIncKey) to help get it down to the metal (in particular, ContIncKey attempts to keep the current use-cases as fast as possible).
14 linhas
172 B
PHP
14 linhas
172 B
PHP
<?php
|
|
|
|
function foo() {
|
|
$i = 0;
|
|
foreach (range("a","e") as $letter) {
|
|
yield $letter => ++$i;
|
|
}
|
|
}
|
|
|
|
foreach (foo() as $k => $v) {
|
|
var_dump($k);
|
|
var_dump($v);
|
|
}
|