Scriptor/pharen — pull request #41 by francescoagati (2012-08-22 13:35:01+00:00)
Title: Plambda

this pull request add support for php 5.3 closure with this form:

```
(def x 100)
(def y 100)
(def sum (plambda (a b) (+ a b x y)))
(def sum3 (plambda (a b) (+ a b)))
```
a closure is callable in this form (like variable string that is referred to a function):
```($sum 1 2)```

bind of variables inside the closure is made from pharen scope so this form

```
(def x 100)
(def y 100)
(def sum (plambda (a b) (+ a b x y)))
```

is compiled in php
```
$__scope_id = Lexical::init_closure("plambda", 129);
$x = 100;
Lexical::bind_lexing("plambda", 129, '$x', $x);
$y = 100;
Lexical::bind_lexing("plambda", 129, '$y', $y);
$sum = function ($a, $b){
$x = Lexical::get_lexical_binding('plambda', 129, '$x', isset($__closure_id)?$__closure_id:0);;
$y = Lexical::get_lexical_binding('plambda', 129, '$y', isset($__closure_id)?$__closure_id:0);;
return ($a + $b + $x + $y);
}
```