Blueberry icon indicating copy to clipboard operation
Blueberry copied to clipboard

Add implicit variable capture on closures

Open gosukiwi opened this issue 9 years ago • 1 comments

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; };

gosukiwi avatar May 27 '15 01:05 gosukiwi

The most fun case is nested closures.

hikari-no-yume avatar May 27 '15 02:05 hikari-no-yume