Tag Archives: C#

Fun(c) with C# 3.0

Looking through the list of predefined (or, in Microsoft’s parlance, standard) query operators defined in C# 3.0, there is one that stands out as missing: the ‘map’ function. However, with the new query expression syntax, this is trivial to define:

public static IEnumerable<T> Map<F,T>(Func<F,T> func, IEnumerable<F> source)
{
return
[...]

Lazy Lists in C#

I had the thought—while browsing through some old code—that the code I used to implement futures in C# would be useful for doing things lazily, if you just moved the evaluation phase to when the value was actually demanded… this started me off thinking about how to implement a proper lazily-evaluated list in C#.
A first [...]

NullPointerException

Why is this such an insidious error in Java? (An opinion piece!)
A Comparison
Firstly, I’ll show a short comparison between some Java code and some code from a language that doesn’t have NullPointerExceptions, but does have something that allows you to accomplish anything you might want to do with null pointers.
This Java code:
AnObject thing = someMethod();
is [...]

Implementing futures in C#

Why?
I was bored, and it didn’t seem to have been done before, so here’s some Future action in C#.
The Code

using System;
using System.IO;
using System.Reflection;
using System.Threading;
 
public class Future<T> {
public delegate R FutureDelegate<R>();
public Future (FutureDelegate<T> del) {
[...]