[Mono-devel-list] Embedding Mono in a Virtual World

Joe Ante joe at otee.dk
Fri Feb 11 06:20:46 EST 2005

> I've started trying this approach out using yields and
> think it might well work, although with yields strange
> things happen mixing them with recursion. I'm not sure
> how generally a call graph can be mapped to a state
> machine, especially in the presence of recursion.
We are using C# style yield in our game engine.
I doubt that you really need the ability to yield from recursive functions
or function calls within the coroutine.
What you really need is a good scheduling system and the ability to start
another coroutine and wait for it's completion.

The main advantage of coroutines is being able to write single function
scripts which wait for engine implemented conditions eg.

MoveTowards ( door);
yield return new NearObject (door);
OpenDoor (door);
yield return new WaitForSeconds (1F);
yield return StartCoroutine ("WalkAroundInRoom");
Console.WriteLine ("Finished walking around")

We have used yielding for quite a few different purposes now and i never
really had a need to yield from inside a recursive function or function call
from inside the coroutine.

Even if you implement it by messing the stack ptr you probably want to keep
recursion down because it gets more expensive the deeper the stack is.

Joachim Ante

More information about the Mono-devel-list mailing list