Quantcast
Channel: This is an EX blog...
Browsing latest articles
Browse All 26 View Live

COIL and COILettes

Douglas Crockford started a minor war when he observed that JavaScript's object initialisation syntax provides a neat way to persist hierarchical data, maybe more suitable to some situations than...

View Article


Asynchronous Sockets with Yield Return of Lambdas

Update: More in-depth stuff about thisI just watched this video of Jeffrey Richter demonstrating his AsyncEnumerator...

View Article


More on Jeffrey Richter’s AsyncEnumerator and Functional Programming

If you do asynchronous programming (or have been put off it in the past by the complexity) and you haven’t already looked at this, then you really...

View Article

Other Examples of Iterators and Async IO

The idea of returning functions via yield return to simply asynchronous IO programming has a precedent in Microsoft's Concurrency and Coordination...

View Article

Optimizing Aggregate for String Concatenation

Linq lets you think in a very generally applicable way and solve a very wide variety of problems with a few key concepts. That’s a great thing. But it’s irritating when the elegant solution doesn’t...

View Article


The Maybe Monad in C#

The Maybe Monad is extremely simple. It represents a value that might be there, but might not, and also provides a neat way of working with such values.This Haskell-related page makes it pretty...

View Article

Ora Stories

I've written an add-in for Visual Studio called Ora. You can read more about it via that link but here's some background to it.It's designed to replace a common use of regions - though I'd call it a...

View Article

Linq to C++0x

Updated 2009-01-28 - completely different approach to get a fluent interface.Updated 2009-05-22 - See new post with decltype goodness!C++ has long had some functional-styled things in its standard...

View Article


Using Collection Initializers with Immutable Lists

The Incomparable Mr Skeet mentions how irksome it is that collection initializers assume that the collection is mutable.Suppose we defined an "immutable-yet-initializable collection" as any type that...

View Article


Further Muddying the ForEach Waters

ForEach is regularly proposed as a missing feature in the BCL but has been rejected in the past apparently because it wouldn't be "functional" enough, doesn't return anything so calls cannot be chained...

View Article

A functional replacement for the using statement

The using-statement is just that: a statement. Why does this bug me?The FileStream object has a Length property. Assuming I have a function Open that returns a FileStream ready for us, it is awfully...

View Article

Displaying a nested evaluation tree from Expression

Updated: The downloadable source (see link below) is now tidied up a bit, and also displays any embedded string comparisons in a similar way to NUnit.This might be useful as a way to write Assert...

View Article

General Theory of Resources

Having blogged the other day about a different way of doing automatic cleanup, I’ve been mulling it over and also answering a question on StackOverflow, and decided that I need to assemble a taxonomy...

View Article


What's Wrong With C# 4.0's dynamic Keyword, and How I Think It Should Be Fixed

Update: Exactly what I want, already implemented, complete with caching of the call site. Also, Microsoft's Mads Torgersen responds to this suggestion here. C# 4.0 proposes to add the dynamic keyword...

View Article

Fatal Exceptions, and Why VB.NET Has a Purpose!

There’s a feature in the CLR that is exposed in VB.NET and not in C#. Apparently this is a deliberate decision made by the C# team, which so far they’ve stuck to. Unfortunately, it’s a pretty important...

View Article


Making Lambdas and Iterators Play Nicely Together

The major problem with this idea is in my favourite feature of C#. In an iterator (a function containing the yield keyword), the code is transformed into a state machine represented by a class. It has...

View Article

JavaScript Invaders!

Click in the small text field in the top left corner to give allow the game to receive keyboard events.Z = left X = right M = fire

View Article


Readonly Fields and Thread Safety

In C# you can mark the fields of a type as readonly (indeed you generally should if it's a struct). By doing so, you make it illegal to change the fields except in a constructor of the type.The...

View Article

General form of C# Object Initializers

C# has a language feature that allows several properties of an object to be assigned to as a suffix to a new expression, namely the object initializer:var myObj = new MyClass { SomeProperty = 5,...

View Article

When to use Stored Procedures?

No coding blog would be complete without an overly-simplistic salvo fired into this bloody online battlefield, so here's mine.What if you're writing an application that will make heavy use of an...

View Article

Recovery

If you want your application to be able to recover from a crash, it would NOT be ideal for it to restore the exact state it was in immediately before the crash, because then it would just crash...

View Article


VC++16 has decltype in Beta 1 (so Linq to C++0x looks a little nicer)

This post has moved to my new(er) blog and can be found here: http://smellegantcode.wordpress.com/2009/05/22/vc16-has-decltype-in-beta-1-so-linq-to-c0x-looks-a-little-nicer/A while ago I wrote up a...

View Article


Lazy Sequence Generation without using Yield Return

C# has the yield return feature, which makes it easy to write state machines as if they were plain old methods:class Program { static IEnumerable<int> SomeNumbers() {...

View Article

Generic Value Object With Yield Return

Inspired by this and this, here's my version.Jan Van Ryswyck is right to use static reflection, and to do that he "registers" the properties in a list. On the other hand, assuming you'd have a lot of...

View Article

Chain – a LINQ operator for dealing with Linked Lists

I don’t think there’s anything in LINQ that will do this, though I expect I’m wrong - I have a tendency to write my own extension method to do something and then discover that LINQ already provides a...

View Article

Browsing latest articles
Browse All 26 View Live