tagged [closures]
C# - closures over class fields inside an initializer?
C# - closures over class fields inside an initializer? Consider the following code: ``` using System; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { ...
- Modified
- 15 Mar at 23:59
Closure allocations in C#
Closure allocations in C# I've installed the Clr Heap Allocation Analyzer extension and in a project I see something that I quite don't understand, I've got a method with a signature ``` public Task E...
Local variables with Delegates
Local variables with Delegates This appears like it wouldn't be a best practice. Can someone explain why it would not be a best practice or how this works? Any books or articles providing an explanati...
- Modified
- 13 Jun at 11:55
Closures in C# event handler delegates?
Closures in C# event handler delegates? I am coming from a functional-programming background at the moment, so forgive me if I do not understand closures in C#. I have the following code to dynamicall...
- Modified
- 9 Feb at 03:13
What is a practical use for a closure in JavaScript?
What is a practical use for a closure in JavaScript? I'm [trying](http://jsbin.com/ojuxo/edit) my hardest to wrap my head around JavaScript closures. I get that by returning an inner function, it will...
- Modified
- 22 Jul at 17:33
odd lambda behavior
odd lambda behavior I stumbled across [this article](http://www.float4x4.net/index.php/2011/05/loops-and-lambdas) and found it very interesting, so I ran some tests on my own: Outputs: --- ``
How can I capture the value of an outer variable inside a lambda expression?
How can I capture the value of an outer variable inside a lambda expression? I just encountered the following behavior: Will result in a series of "Error: x", where most of the x are equal to 50. Simi...
- Modified
- 15 Jun at 11:10
Making variables captured by a closure volatile
Making variables captured by a closure volatile How do variables captured by a closure interact with different threads? In the following example code I would want to declare totalEvents as volatile, b...
How should I call 3 functions in order to execute them one after the other?
How should I call 3 functions in order to execute them one after the other? If I need call this functions one after other, I know in jQuery I could do something like: ``` $('#art1').animate({'width':'...
- Modified
- 27 Aug at 08:8
How do closures work behind the scenes? (C#)
How do closures work behind the scenes? (C#) I feel I have a pretty decent understanding of closures, how to use them, and when they can be useful. But what I don't understand is how they actually wor...
Closures and Lambda in C#
Closures and Lambda in C# I get the basic principles of closures and lambda expressions but I'm trying to wrap my mind around what is happening behind the scenes and when it is/isn't practical to use ...
What is so special about closures?
What is so special about closures? I've been [reading this article about closures](http://www.devsource.com/c/a/Languages/Cigars-Lambda-Expressions-and-NET/1/) in which they say: - - - - So I made an ...
groovy: safely find a key in a map and return its value
groovy: safely find a key in a map and return its value I want to find a specific key in a given map. If the key is found, I then want to get the value of that key from the map. This is what I managed...
- Modified
- 2 Sep at 02:43
Exception: Serialization of 'Closure' is not allowed
Exception: Serialization of 'Closure' is not allowed So I am not sure exactly what I would have to show you guys, how ever if you need more code please do not hesitate to ask: So this method will set ...
- Modified
- 5 Dec at 23:12
perl closures and $_
perl closures and $_ One of the first things I try to learn in an unfamiliar programming language is how it handles closures. Their semantics are often intertwined with how the language handles scopes...
- Modified
- 5 Jul at 19:10
Access to disposed closure - mark methods as safe
Access to disposed closure - mark methods as safe This is about ReSharper's warning "Access to disposed closure" which usually appears when an object which is later disposed is used in a lambda. [Acce...
- Modified
- 23 May at 12:16
Anonymous inner classes in C#
Anonymous inner classes in C# I'm in the process of writing a C# Wicket implementation in order to deepen my understanding of C# and Wicket. One of the issues we're running into is that Wicket makes h...
- Modified
- 22 Jan at 19:55
Issue with closure variable capture in c# expression
Issue with closure variable capture in c# expression I have a function which creates a delegate using expression trees. Within this expression I use a variable captured from multiple parameters passed...
using yield in C# like I would in Ruby
using yield in C# like I would in Ruby Besides just using `yield` for iterators in Ruby, I also use it to pass control briefly back to the caller before resuming control in the called method. What I w...
Why Are Some Closures 'Friendlier' Than Others?
Why Are Some Closures 'Friendlier' Than Others? Let me apologize in advance - I'm probably butchering the terminology. I have a vague understanding of what a closure is, but can't explain the behaviou...
Closure semantics for foreach over arrays of pointer types
Closure semantics for foreach over arrays of pointer types In C# 5, the closure semantics of the `foreach` statement (when the iteration variable is "captured" or "closed over" by anonymous functions)...
Getting ConstantExpression.Value when actual value wrapped into DisplayClass because of closure
Getting ConstantExpression.Value when actual value wrapped into DisplayClass because of closure Below is a simple demonstration code of my problem. ``` [TestClass] public class ExpressionTests { [Te...
- Modified
- 23 Sep at 16:40
Is there a particular reason LinqKit's expander can't pick up Expressions from fields?
Is there a particular reason LinqKit's expander can't pick up Expressions from fields? I'm using [LinqKit](http://www.albahari.com/nutshell/linqkit.aspx) library which allows combining expressions on ...
- Modified
- 3 Jun at 10:57
Is this object-lifetime-extending-closure a C# compiler bug?
Is this object-lifetime-extending-closure a C# compiler bug? I was answering a [question](https://stackoverflow.com/questions/8417470/private-field-captured-in-anonymous-delegate) about the possibilit...
- Modified
- 23 May at 12:1