CSC/ECE 517 Fall 2011/ch1 1d gs: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 8: Line 8:


To rephrase, a closure is a block of code which meets the following three criteria
To rephrase, a closure is a block of code which meets the following three criteria
1. It can be passed around as a value.
1. It can be passed around as a value.
2. It can executed on demand by anyone who has that value, at which time.
2. It can executed on demand by anyone who has that value, at which time.

Revision as of 02:44, 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?

==