]> hydra-www.ietfng.org Git - dyna2/commitdiff
Add a placeholder tutorial section on errors
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 5 Jun 2013 06:31:04 +0000 (02:31 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Wed, 5 Jun 2013 06:31:04 +0000 (02:31 -0400)
docs/sphinx/tutorial/errors.rst [new file with mode: 0644]
docs/sphinx/tutorial/index.rst
examples/fib.dyna
misc/ghc-bootstrap.sh

diff --git a/docs/sphinx/tutorial/errors.rst b/docs/sphinx/tutorial/errors.rst
new file mode 100644 (file)
index 0000000..d3c01f8
--- /dev/null
@@ -0,0 +1,70 @@
+.. Tutorial chapter on errors
+   This file is enumerated in the toctree directive of /tutorial/index.rst
+
+.. index::
+   double: tutorial; errors
+
+When Things Go Wrong
+####################
+
+Impossible Requests
+===================
+
+What happens if a Dyna program attempts to divide by zero, as in::
+
+  a += 1 / b.
+  b += 0.
+
+If this is the entirety of the program and no changes are forthcoming
+(*e.g.*, we are not in interactive mode) then the semantics of this program
+include division by zero, and so must be an error.  What happens when we
+attempt to run it?  Our interpreter produces a chart with an annotation::
+
+  Charts
+  ============
+  a/0
+  =================
+  
+  
+  b/0
+  =================
+  b                              := 0
+  
+  
+  Errors
+  ============
+  because b is 0:
+      division by zero
+
+This last ``Errors`` display indicates that the answers available in the
+``Charts`` section is not reliable.
+
+.. caution:: Any error is potentially global!  While it might be possible
+   for some programs to more accurately track errors, currently our
+   implementation does not.  The net effect of this is that if ever the
+   interpreter produces an ``Errors`` section, then the entire chart must be
+   considered suspect.
+
+Non-Termination
+===============
+
+As mentioned before, Dyna2 currently uses *agenda-driven semi-naive forward
+chaining* for its reasoning.  This algorithm has several excellent
+theoretical properties, but suffers from a potentially show-stopping
+problem: *it might not stop*.
+
+A Dyna program which includes a definition of the Fibonacci numbers ::
+
+  fib(1) += 1.
+  fib(2) += 1.
+  fib(X) += fib(X-1) + fib(X-2).
+
+will compile and be accepted by the interpreter, but will attempt to prove
+a ``fib`` item for every positive natural number!  Clearly, this task is
+going to take a while.
+
+If your program goes away for longer than you expect, it is entirely
+possible that it is caught in such an infinite loop.  In that case, you may
+send it a ``SIGINT`` by hitting Control-C.  The interpreter will then print
+out the chart as far as it had determined it.  If this is far bigger than
+expected, your program probably has a productive infinite loop.
index bfd017d1247087077699b888337fbb23f93cf5c3..4a601e66cd75d237e063355e050b1a0b711a6f47 100644 (file)
@@ -8,3 +8,4 @@ Tutorial
 
    hello
    dijkstra
+   errors
index aad92b8a6c14fc6187e93d91607a70e4164e0f3f..413022ae6f232da13000b06c4bd1b8740963312d 100644 (file)
@@ -1,5 +1,5 @@
 % Fibonacci numbers
-f(1) += 1+0 .
-f(2) += 1+0 .
+f(1) += 1 .
+f(2) += 1 .
 f(X) += f(X-1) + f(X-2).
 
index d44a64b5653970d94932b160cf2b29fcdda46361..c7b0725e8825bed325dc7d8a8f14eef53cbdabe1 100644 (file)
@@ -61,7 +61,7 @@ case $CMD in
 
     run)
     export PREFIX=$HPATH
-    $@
+    "$@"
     ;;
 
     reinstall)