Don Box offered a few answers to my questions in his
latest post, but I am
still unsatisfied.  Here’s why.

First of all, the various comments on our respective blog entries taught me
that C# doesn’t really support continuations, which explains the awkward
return yield
syntax.  This particular C# feature
is probably closer to generators, which are themselves a more restricted form of
closures (but still more useful than anything we have in Java).

Don’s answer to the question "how useful are continuations?" is the
following:

I’ve been programming in C# 2.0 for over a year now. I regularly find myself
using the following two pre-defined delegates from mscorlib in my programs:

namespace System {
public delegate bool Predicate<T>(T item);
public delegate void Action<T>(T item);
}

I am quite puzzled by this code snippet which doesn’t seem to have much to do
with continuations.  Don’s remaining text is a pretty convincing argument
of the usefulness of delegates in C#, something I am in full agreement with. 
Years ago, when Microsoft came up with its own JVM and IDE, my fondness for
delegates was immediate.  They appeared to me as a typesafe and reasonably
object-oriented way to provide method callbacks.

Back then, I spent hours on emails and discussions trying to convince Java
developers around me (including at JavaSoft, and more particularly on the Swing
team) that we should have delegates in Java.  But
my words fell on deaf ears, creating cascades of flame wars that never
accomplished anything.  The problem
was, of course, that the reactions were clouded by politics and not driven by
pragmatism.  So Java drifted away from delegates and will probably never
recover.  This is quite sad and probably the cause for thousands of wasted
objects every day as we create and destroy interfaces for every click of a
button.

Anyway.

Don shows a pretty good example of predicates and first-order logic that
allows him to neatly isolate logic between callers and callees. It’s a fairly
common idiom that you also find in many places in Java (comparators, file
filters, etc…).  If you are not familiar with this kind of trick, I strongly
encourage you to read up on the STL
(Standard Template Library) which, even though it is written in C++ and makes heavy use of
advanced template techniques, contains a lot of very important concepts that you
will undoubtedly find useful in your daily Java programming.

So I’m back to my original question:  how useful are continuations,
really?  I can’t shake off the idea that they are nothing more than a
glorified way to do goto.  A cleaner way, sure, since it remembers contexts
and frames, but I am still looking for this one example where a
continuation-based code is more readable than a loop-based one.

Will anyone take up the challenge?