Top "Closures" questions

A closure is a first-class function that refers to (closes over) variables from the scope in which it was defined.

Are nested functions a bad thing in gcc ?

I know that nested functions are not part of the standard C, but since they're present in gcc (and the …

c gcc closures nested-function
Swift Closures - Capturing self as weak

I am trying to resolve a closure based strong reference cycle in Swift. In the code below, object is retained …

swift closures weak-references
Fibonacci closure in go

I am following the go tour on their official website and I have been asked to write a Fibonacci generator. …

go closures fibonacci
Javascript function challenge add(1,2) and add(1)(2) both should return 3

A friend of mine challenged me to write a function that works with both of these scenarios add(2,4) // 6 add(2)(4) // 6 My …

javascript function closures challenge-response
What exactly is contained within a obj.__closure__?

Beazley pg 100 mentions: >>>python.__closure__ (<cell at 0x67f50: str object at 0x69230>,) >>&…

python closures python-internals
Scala return statements in anonymous functions

Why does an explicit return statement (one that uses the return keyword) in an anonymous function return from the enclosing …

scala return closures anonymous-function
Closure with typed arguments in Groovy

I'd like to be more explicit about my closures regarding their argument types. So I would write something like List&…

groovy closures static-typing groovy++
php closures: why the 'static' in the anonymous function declaration when binding to static class?

The example in the php documentation on Closure::bind include static on the anonymous function declaration. why? I can't find …

php closures bind
Lexical scope/closures in javaScript

I understand functions in 'js' have lexical scope (i.e. functions create their environment (scope) when they are defined not …

javascript closures lexical-closures
How to declare a lifetime for a closure argument?

I would like to declare a lifetime for a closure in Rust, but I can't find a way to add …

closures rust lifetime