CSC/ECE 517 Fall 2011/ch1 1d gs: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 5: | Line 5: | ||
==Closures== | ==Closures== | ||
A closure is a kind of routine that can be assigned to a variable or passed as a parameter to another routine. It can access the local state (local variables, parameters, methods, and instance variables) which is visible in the place it was defined. | |||
To rephrase, a closure is a block of code which meets the following three criteria | |||
1. It can be passed around as a value. | |||
2. It can executed on demand by anyone who has that value, at which time. | |||
3. It can refer to variables from the context in which it was created. | |||
==Why do we need closures and what are its uses?== | ==Why do we need closures and what are its uses?== |
Revision as of 02:43, 8 September 2011
Closures for Statically Typed Languages
Introduction
This wiki gives an introduction to language constructs called closures, it’s usage and discusses about challenges involved in implementing them in statically typed languages.
Closures
A closure is a kind of routine that can be assigned to a variable or passed as a parameter to another routine. It can access the local state (local variables, parameters, methods, and instance variables) which is visible in the place it was defined.
To rephrase, a closure is a block of code which meets the following three criteria 1. It can be passed around as a value. 2. It can executed on demand by anyone who has that value, at which time. 3. It can refer to variables from the context in which it was created.
Why do we need closures and what are its uses?
==