Posts Tagged closure

How Closures Work

Tags: , , ,

C#’s support for closures includes lambdas ((a, b) => a+b) and delegates (delegate(int a, int b){return a+b;}). They’re extremely handy tools that many developers use on a daily basis. For example, it’s really convenient when using List.Find to pass in a lambda like item => item.Id == IdToFind. They also make great callbacks for asynchronous operations. However you’re using them, understanding how they work behind the scenes will help you understand how they behave and give you insight when optimizing your code. Today’s article delves into the topic to gain just this understanding, so read on to learn some more about closures!

Read the rest of this article »

No Comments

Activation Objects

Tags: ,

Closures are a really nice feature of AS3 (and JavaScript and AS2) and I’ve shown their performance disadvantages compared to regular methods before. Today I’ll discuss a further performance downside to closures that can slow down your code, not just the function call itself.

Read the rest of this article »

2 Comments

Case Statements

Tags: , , ,

The lowly switch statement and its attendant case statements is a basic element of most C-style languages. Still, I was surprised by it recently when it seemingly ate one of my functions. Read on to see how.

Read the rest of this article »

7 Comments