Q: How does ANI resolve the fundamental issue of deadlock in parallel programming? How does the Dining Philosophers example on the main page work?
A: In ANI, under the hood, pipes implicitly enforce total resource orderings for acquiring data. Somewhat surprisingly, deadlock theory guarantees that there will be no deadlock if this condition is met.
The compiler attempts to figure out a static ordering for most data acquisition, but this is not possible with array elements; thus, array elements are resource-ordered using metadata annotations at runtime. Where the compiler cannot come up with a total resource ordering for data, and it comes across a dependency that it knows it won't be able to fully resolve with run-time ordering annotations, it will reject the program as unsafe, pointing out the dependency chain what causes the problem. Since this is dataflow programming, such analyses are very natural to do.
In the case of the Dining Philosophers program, a runtime resource ordering will suffice to ensure each philosopher (even the last one) will pick up the chopstick on their left first; the runtime will in this case allow for the chopstick acquisition order to be dynamically swapped as necessary.
Of course, this is rather technical and the point is that in most cases, programmers don't need to care about these details -- that's the compiler's burden! The one case where programmers will see them is when their program is provably unsafe and the compiler can't figure out a sensible way to fix the issue. Such a situation is at best an indication of a highly confusing flow of data, and at worst a nasty parallel programming bug; in both cases, the compiler would do well to flag an error, and that's exactly what it does.
----
Not unique to this toy language, such problems have been solved before, e.g.
http://en.wikipedia.org/wiki/Fastflow_%28Computer_Science%29
__________________
Orbis terrarum delenda est