Wump the Wumpus
Apologies for the long hiatus between newsletters. Before the website went up, these were sent from a personal e-mail account to the small list of Avail insiders. But the website is now a more appropriate venue, so please look for newsletters here. There is no commitment to a particular frequency yet, but having said that, hopefully there will be a newsletter every week so that interested parties can stay current with Avail developments.
Wump it Good
This week, Wump the Wumpus, an Avail adaptation of Gregory Yob's 1972-3 text adventure classic, Hunt the Wumpus, was published to the source repository. The project-relative path to the codebase is examples/Wump the Wumpus
. To actually play the game, build examples/Play Wump the Wumpus
. While the game is meant to amuse for a few minutes or hours at most, the primary value resides in its source code. Wump the Wumpus is a pedagogic exercise in developing a nontrivial application in Avail.
Unfinished Business
The exception handling machinery now supports unwind protection. The method formerly named "Guard|guard_«intercept_»"
is now "Guard|guard_«intercept_»«ensure_»"
. The first argument is the guarded function, the second argument is a tuple of exception handlers, and the (new) third argument is an optional unwind handler. Whether a guarded function runs to completion or is curtailed by an exception, the associated unwind handler always runs. This functionality is equivalent to the try/catch/finally
control structure from Java or C#, the try/except/finally
control structure from Python, or the begin/rescue/ensure
control structure from Ruby. The unit test, new-avail/Avail/Foundation Tests/Exception Tests
, is rife with examples that should demonstrate the nuances of exception handling.
If At First You Don't Succeed…
The standard library now supports computational backtracking. Backtracking is the technique of checkpointing the execution of an algorithm so that it is possible to abandon a path of computation and proceed along a different path that diverges at a checkpoint. To use backtracking, first establish a dynamic fence with "Backtracking fence_"
. The argument is a function within which backtracking primitives may occur. There are two classes of backtracking primitives: those which establish checkpoints and those which resume checkpoints. In the former class are "first try"
, which establishes a checkpoint and then answers true
; "trial`#of_"
, which establishes a checkpoint and then answers 1
; and "trial element of_"
, which establishes a checkpoint and then answers the first value from its argument tuple or set. In the latter class is "Try again"
, which causes the most recent checkpoint to resume and answer a different value. Following "Try again"
, a previous "first try"
will resume and answer false
; a previous "trial`#of_"
will resume and answer the next natural number less than or equal to its argument; a previous "trial element of_"
will resume and answer the next element from its argument. If a checkpoint has already returned every possible value because of repeated sends of "Try again"
, then it becomes invalid and the next most recent checkpoint is resumed. If no checkpoints are active within the nearest "Backtracking fence_"
, then "Try again"
raises a no-checkpoint exception
. Use of a backtracking primitive outside of a function dynamically guarded by "Backtracking fence_"
will raise a no-backtracking-fence exception
. The unit test, new-avail/Avail/Foundation Tests/Backtracking Tests
, includes the archetypal N queens problem, a classical example of the immense power of backtracking:
Many more things are cooking. More on those as they become ready for consumption.
Return to Newsletters | | | Next › |