Language Guide: Page 7
A crash course in the particular workings of microscheme
Runtime Exceptions
Like Scheme, microscheme is strongly, dynamically typed. Exceptions are semmantic errors that arise at runtime. Microscheme makes use of the Arduino's built-in LED on digital pin 13 to give on-device indications of these situations. Generally, exceptions are not recoverable, and the device will need to be reset if an exception is raised. While it is possible to use digital pin 13 for general input and output, it is highly recommended to leave it free for exception indication.
Status | Meaning | Indication |
---|---|---|
RUN | Program Running | No Light |
NVP | Not a Valued Procedure | Single Flashes |
NAR | Number of ARguments | 2 Flashes |
NAN | Not A Number | 3 Flashes |
NAP | Not A Pair | 4 Flashes |
NAV | Not A Vector | 5 Flashes |
OOB | Out Of Bounds | 6 Flashes |
DBZ | Divide By Zero | 7 Flashes |
ERR | Custom Exception | Continuous Flashes |
HALT | Program Completed | Continuous Light |
Exception Details
NVP: A procedure application takes the form (proc X1 X2 ... Xn) where proc is an expression. At the time of application, if proc does not evaluate to a (valued) procedure, such as the result of a (lambda …) form, or a variable bound to a procedure, then NVP will be raised.
NAR: A procedure application takes the form (proc X1 X2 ... Xn) where X1 X2 ... Xn are arguments. At the time of application, if proc evaluates to a procedure taking m arguments, but m ≠ n, then NAR will be raised.
NAN: Indicates that an arithmetic operator (+, -, *, /, div, mod) received an argument that did not evaluate to a number.
NAP: Indicates that a pair operator (car, cdr, set-car!, set-cdr!) received an argument that did not evaluate to a pair.
NAV: Indicates that a vector operator (vector-ref, vector-set!) received an argument that did not evaluate to a vector.
OOB: Indicates that a vector operator (vector-ref, vector-set!) received an index that was outside the dimensions of the vector given.
DBZ: Indicates an attempt to divide by zero.
ERR: This exception is raised manually by the programmer. See (error) and (assert expr) in the language guide.