CSC/ECE 517 Fall 2010/ch1 1b YL: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


== Introduction ==
== Introduction ==
Before discussing semantic and implementation differences of closure implementation in different languages, closures should be discussed first.
<blockquote>A closure is a first-class function with free variables that are bound in the lexical environment. Such a function is said to be "closed over" its free variables. [http://en.wikipedia.org/wiki/Closure_%28computer_science%29 Closures:Wikipedia]</blockquote>
Now in this definition first-class function is nothing but the function which is treated as first-class objects. <blockquote>Specifically, this means that the language supports constructing new functions during the execution of a program, storing them in data structures, passing them as arguments to other functions, and returning them as the values of other functions. [http://en.wikipedia.org/wiki/First-class_function]</blockquote>


== Different implementations of closure ==
== Different implementations of closure ==

Revision as of 04:13, 7 September 2010

Closures in Ruby vs. closures in other languages

Introduction

Before discussing semantic and implementation differences of closure implementation in different languages, closures should be discussed first.

A closure is a first-class function with free variables that are bound in the lexical environment. Such a function is said to be "closed over" its free variables. Closures:Wikipedia

Now in this definition first-class function is nothing but the function which is treated as first-class objects.

Specifically, this means that the language supports constructing new functions during the execution of a program, storing them in data structures, passing them as arguments to other functions, and returning them as the values of other functions. [1]


Different implementations of closure

Closures in Ruby

Closures in Lisp

Closures in ML

Closures in C

Closures in C++

Closures in Java

Closures in Javascript

Comparison

Conclusion