[r6rs-discuss] Laziness Features - reentrancy
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Wed Oct 18 14:39:47 EDT 2006
AndrevanTonder <andre at het.brown.edu> writes:
> However, I would like to suggest a bullet option allowing
> implementations to throw an exception for reentrant promises,
> reading as follows:
> - An implementation may raise a runtime contract violation
> if a promise refers to its own value, i.e., if forcing a
> promise may cause the promise to be forced a second time
> before the value of the first force has been computed.
I agree; this could even be mandatory.
In a language with concurrency the desired effect of many cases of
promises, when evaluated concurrently by separate threads, is for
other threads to wait until the value gets computed by the thread
which started it first.
If the thread wanting the value is the same as the thread which is
computing it, letting it wait for itself would be sound but pointless,
it would just deadlock. This generally signifies a bug in the program
where a value depends on itself. A more useful behavior is signalling
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
More information about the r6rs-discuss