debug — Debugging functions

This module provides functions which help with debugging and testing software.

Warning

Mars is, fundamentally, a pure language. Normally, functions cannot perform input/output unless they declare themselves to be “io”.

The functions in this module break that purity by allowing functions to produce output, even if they do not declare themselves as io. They should not be considered part of the language semantics, and are only intended for use in debugging and testing software (not as part of the normal operation of the software).

trace_char(char :: Num) :: Num

Writes char as a byte to standard error. It is an error if char is outside the range [0, 255]. Returns 0.

This is the same as put_char, except that a) it writes to standard error (rather than standard output), and b) it can be called from a non-io context.

trace(string :: Array(Num)) :: Num

Writes string to standard error. This calls trace_char on each element of string. It is an error if any element is outside the range [0, 255]. Does not print a newline.

This is the same as print_string, except that a) it writes to standard error (rather than standard output), and b) it can be called from a non-io context.

Previous topic

prelude — Common functions

Next topic

impure — Impure functions

This Page