Friday, December 5, 2008

more on let blocks

So as an aside the two are equivalent:

$func = let($x = 10){
[$y | $x = $x*$y];
}

$func = [$x | [$y | $x = $x*$y]] x:10;

The let block is obviously more readable as you understand you are creating a binding for $x and then using that binding in the let block (in this case to return a function which closes over $x).

So to leverage the power of multiple-transmogrifications the system first translates let blocks to be square lambdas and then the square lambda transmogrification can just handle everything else (including closures). I think it's dope.

No comments: