[Mono-list] Re: Continuations and Closures
Peter Sestoft
sestoft@dina.kvl.dk
Mon, 1 Mar 2004 22:15:42 +0100 (CET)
P. Oscar Boykin <boykin@pobox.com> wrote:
> The anonymous delegates in C# 2.0 seem to look a lot like closures, and
> the "yield" statement in the Iterators looks a lot like a continuation.
>
> Are there any changes to the bytecode that support continuations and
> closures at a very low level in .Net?
No. These C# extensions are implemented using the existing bytecode.
For each iterator method -- one containing a yield return or yield
break statement -- the C# compiler creates a new class. An instance
of such a class is a small state machine that simulates a simple form
of coroutines, neither general coroutines nor full continuations.
Providing the full power of continuations in an efficient manner would
have wide ramifications for the CLR machine model. On the other hand,
the yield statement considerably simplifies life for the programmer
yet adds no extra complexity to the runtime.
Peter
--
Department of Mathematics and Physics * http://www.dina.kvl.dk/~sestoft/
Royal Veterinary and Agricultural University * Tel +45 3528 2334
Thorvaldsensvej 40, DK-1871 Frederiksberg C, Denmark * Fax +45 3528 2350