Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

One way to look at the currying process is to say that the returned lambda of make-addX "captures" the value of "x" at the moment that it is created.   This capturing process will become very important later on when we have more complicated algorithms where we will want to clearly delineate parameters that are variant in one part of the code but invariant in another.   The use of lambdas and their ability to curry variables will become one of our most powerful tools as the semester progresses!

Another way to think of currying is that it creates a scoping that lasts for longer than the lifetime of the function in which it is defined.   That is, the returned function from make_addX retains the scoping defined by the running of make_addX long after make_addX has finished executing.

 All of this is part of the notion of a function's "closure", a topic we will discuss more formally very soon,

...