Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ah, right, yes, that's true, I forgot about the Currying bit (I read up on it earlier, promptly forgot it).

I'm coming at this from a 'coders' perspective, not the mathematical side of it, so the code example is much appreciated, that makes it much easier to understand.

The function 'foo' returns a function that has already 'bound' 'x' to whatever value you put in, the 'scope' then allows you to fish out the right 'x' when you're in the inner function doing the multiplication.

So, does that mean that as far as the inner function is concerned 'x' is 'free' ?

So far when reading articles about the lambda calculus it seemed like the 'free' variables where somehow magically present in the scope of the function without a hint about where they came from.



I could easily be wrong, but here is my understanding. Consider this snippet of JavaScript:

  function foo (x) { return function (y) {
      return x*y;
  }}

  bar = foo(5);
Within bar, x is bound and y is free.

Does that make sense to you?


Ok, so now 'bar' contains a function where the 'x' is already bound to the '5', but the 'y' is still free because it has not yet been 'bound' to any parameter, is that what you mean ?

bar contains "function(y) { return 5*y; }"

The 'x' has been replaced by the '5' because of the function call. So 'binding' effectively pins down a function parameter and allows you to replace its instances in 'named' form with its value to reduce the expression ?


That is the way that I understand it. However you should be warned that I have never made a detailed study of the lambda calculus, and so might have basic misconceptions about it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: