Blueberry
Blueberry copied to clipboard
Add implicit variable capture on closures
As discussed in #29, right now the variable capture is pretty dumb, so there's a lot of room for better code generation.
I'm moving the topic to it's own issue for better organization.
Andrea's example explains this pretty well:
a = 3
b = 2
c = (z) -> z + b
should compile to
<?php
$a = 3;
$b = 2;
$c = function ($z) use ($b) { return $z + $b; };
The most fun case is nested closures.