-
-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closure issue [$25] #888
Comments
Zephir does not support use() for closures. |
@Green-Cat Do you plan to support generators and coroutines? |
how could we convert that syntax to the correct one? For example I have this class Functional {
public static function array_map_recursive(callback, value)
{
if (is_array(value)) {
return array_map(function(value) use (callback) { return array_map_recursive(callback, value); }, value);
}
return call_user_func(callback, value);
}
public static function test_rec (item)
{
return item . " +1";
}
} Thanks. |
Use keyword is extremely useful. It allow us to inherit variables from the parent scope. Is there any plans to support it? |
Any news ? |
Is there any news on this issue yet? I'm currently doing a rather large project in Phalcon, but would like to use Zephir instead of PHP for development. However, this is kind of a major issue (for me personally). |
yeah ,its really useful . so many closure i use in my project. its will be very important feature! |
Right now it can't be added to zephir, becouse anonimus functions in zephir it is not return array_map(function(var item){ return item + 1; }, value); Zephir simple create new function with unredable name, like: function func_101193d7181cc88340ae5b2b17bba8a1(var item) {
return item + 1;
} and then use it like this return array_map('func_101193d7181cc88340ae5b2b17bba8a1', value); So anonimus functions in zephir it simple named functions. |
Could this be somehow implemented @sjinks ? Lately i added factories to phalcon so for example we can do something like: use Phalcon\Db\Adapter\Pdo\Factory;
$config = new Phalcon\Config\Ini('config.ini');
$di->setShared('db', Factory::load($config->database)); But obviously on this point it will create database adapter object, i just wonder if this could be implemented so i could add some method like
Or there is some other workaround for this? Is something like this gonna work:
? Well already can tell it won't work. |
use var dummy;
let dummy = new \stdClass();
let dummy->foo = "some variable";
(function(){
var dummy = <\stdClass> this;
echo dummy->foo;
})->bindTo(dummy); |
Should work in current development branch. Thank you for the contributing, and for helping us make Zephir better. Feel free to open a new in case of any issue. |
Zephir\ParseException: Syntax error in *******.zep on line 10
The text was updated successfully, but these errors were encountered: