Lambda closures - substitution of use keyword

Hi there,

unfortunately the search doesn't work on the forums atm, so sorry if this question has already been asked...

I'm looking for a way to write something like this in Zephir:

    public function once($event, callable $listener)
    {
        $onceListener = function () use (&$onceListener, $event, $listener) {
            $this->removeListener($event, $onceListener);
            call_user_func_array($listener, func_get_args());
        };
        $this->on($event, $onceListener);
    }

(It's basically a Zephir port of igorw/evenement)

Any advice is welcome!

Because the source is so tiny, I ended up refactoring the code.

For anyone in the same boat, the other option is to create closure objects to encapsulate the variables, but ofc that can be tedious. Looking forward for the implementation of the closure use feature! :]

Lajos,

Could you post a code example of you work around?

Thanks.