Runs a computation under a budget and returns its value, or the report of the budget that
stopped it.
A budget stops a run by throwing a private signal, and attempt is the only function that
catches the signal. The package uses an exception for an expected failure in this one
place. An algorithm such as an Earley parser or a saturation loop charges its budget deep
inside nested loops, and a Result threaded through every loop would hide the algorithm.
So the algorithm charges as if a charge always fits, and its caller receives a Result
here.
The function handles a stop of budget or of one of its descendants. A stop of an
ancestor passes through to the attempt on that ancestor, and every other error is
rethrown. A run that returns a generator finishes before the generator charges anything,
so a caller consumes the generator inside the run.
Runs a computation under a budget and returns its value, or the report of the budget that stopped it.
A budget stops a run by throwing a private signal, and
attemptis the only function that catches the signal. The package uses an exception for an expected failure in this one place. An algorithm such as an Earley parser or a saturation loop charges its budget deep inside nested loops, and aResultthreaded through every loop would hide the algorithm. So the algorithm charges as if a charge always fits, and its caller receives aResulthere.The function handles a stop of
budgetor of one of its descendants. A stop of an ancestor passes through to theattempton that ancestor, and every other error is rethrown. A run that returns a generator finishes before the generator charges anything, so a caller consumes the generator inside the run.