Russ Abbott wrote:
I'd be interested in your thoughts on http://cs.calstatela.edu/~wiki/index.php/Courses/CS_460/Fall_2005/What_programmers_should_know_about_Oz#Thread_bombs <http://cs.calstatela.edu/~wiki/index.php/Courses/CS_460/Fall_2005/What_programmers_should_know_about_Oz#Thread_bombs> and the example that follows it. It seems like a nice way to use thread-encapsulated suspension to implement go/no-go constraints.
This is the basic requirement for the implementation of a constraint: it must be checked when all its variables are determined.
The idea is embed a constraint in a thread that will fail and kill off the computation if the constraint fails. Now that I'm beginning to know about ByNeed and value.Failed, should this be written differently? This version seems to do the job.
Constraints are usually implemented by "eager" threads, so that they fail as soon as possible. ByNeed is more appropriate to functional style programming.
Value.failed is used to "transmit" an exception from one thread to another. As exception handling is non-declarative, it is rarely used in logic or constraint programming contexts.
Cheers, raph _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
