A place to keep my thoughts on programming

Tag Archives: lambda

Func/Action vs. Delegate

A while back I wrote that you really never have to write another delegate again, since any delegate can easily be expressed as an Action or Func. After all what's preferable? This: var work = worker.ProcessTaskWithUser(delegate(Task t, User u) { … Continue reading

January 5, 2011 .net, geek , , ,

Promise: Method slots and operators

Before getting into method slots, here's a quick review of the Promise lambda grammar: lambda: [<signature>] <expression>; signature: (<arg1>, … <argN>[|<return-type>]) arg: [<type>] <argName>[=<init-expression>] expression: <statement> | { <statement1>; … <statementN>; } A lambda can be called with positional arguments … Continue reading

August 13, 2010 geek, Promise , ,

Promise: Lambdas

Lambdas in Promise, like other languages, are anonymous functions and first-class values. They act as closures over the scope they are defined in and can capture the free variables in their current lexical scope. Promise uses lambdas for all function … Continue reading

July 11, 2010 .net, geek, Promise , , , , ,

Don’t blow your stack: C# trampolining

A couple of weeks ago someone posted two links on twitter suggesting the trampolining superiority of Clojure to C#. (Can’t find that tweet anymore, and yes, that tweet was what finally motivated me to migrate my blog so i could … Continue reading

July 5, 2010 .net, geek , ,

Boolean Algebra for Tag queries

Currently working on a tag query engine and couldn’t find anything all that useful in the published approaches. I want to do arbitrary boolean algebras against a set of tags in a database, which seems to be out of scope … Continue reading

September 2, 2009 .net, geek , , , ,

Setting up mocks for an inner autofac container

This is definitely an edge case testing scenario, so i don’t know how useful this utility class is in general, but i thought it was kinda fun deferred execution stuff, so why not post it? Here’s my scenario. I’ve built … Continue reading

August 24, 2009 .net , , ,

LINQ: Immutability vs. Deferred execution

The last couple of nights I’ve been playing with some Linq to Sql and a whole lot of Linq to Objects and I have to say where coming up with complex Regular Expressions used to be one of my favorite … Continue reading

February 1, 2008 .net , ,

More Deferred Execution Fun: foreach and delegation scope

This is closely related to my last post on deferred execution gotchas and its basically more “if you inline delegated code, you may easily overlook scope side-effects”. This time it’s about dealing with foreach and using the local each item … Continue reading

January 11, 2008 .net , , ,

The dangers of deferred execution

I recently wrote about Action & Func, which along with Lambda expression let you do easy inline callbacks like this: Utility.ActionDownloader.Download( Configuration.GetAssetUri(dto.Url), (Downloader d) => { FloatContainer c = (FloatContainer)XamlReader.Load(d.ResponseText); c.Initialize(dto); }); i.e. I can call a downloader and inline … Continue reading

December 30, 2007 .net , ,

Action & Func: Never write another delegate

With lambda expressions in C#, the Func generic delegate and it's variations have been getting a lot of attention. So naturally, you might think that the lambda syntax is just a shortcut for creating anonymous delegates, whether they return values … Continue reading

December 14, 2007 .net , ,