Watt, Volt's Standard Library
Watt is a collection of modules that are useful enough, and used often enough, that they are shipped with the Volt compiler. Together they make up Volt's standard library.
The library is divided into modules and packages, described below.
Package watt.*
The watt
package contains all other packages, and is home to some modules that are very widely used.
watt.algorithm contains functions implementing fundamental algorithms, and often used utility functions, like
max
andmin
.watt.conv contains functions dealing with converting strings to integers, integers to strings, integers to different types of integers, and so on.
watt.path assists in dealing with paths; finding the path to the currently running executable, returning the extension of a filename, getting a full path from a relative path, and so on.
watt.http is a package module (a package that can be imported as if it were a module) that provides a simple interface for using HTTP.
watt.process is a package module that provides facilities for spawning new processes, reading environmental variables, running and capturing the output of a command.
watt.json is a package module that contains a DOM and SAX parser for JSON text.
watt.markdown is a package module that contains a CommonMark Markdown parser.
Package watt.io.*
The watt.io
package contains modules that deal with input and output intended for use or consumption by humans.
watt.io.file contains simple functions for dealing with files. Functions for reading an entire file into memory, check if a file exists, deleting a file, searching a directory for a file, and so on.
watt.io.monotonic contains functions for getting precise timing information from the OS.
watt.io.seed contains the function
getHardwareSeedU32
, that gets a random seed number from the OS that is suitable for seeding a random number generator.watt.io.std contains the declarations of the standard output, input, and error streams, and some global shortcut functions for dealing with them, like
writeln
andreadln
.watt.io.streams is a package module that provides a stream interface (interfaces for reading and writing to things, one character at a time), and provides implementations based on C's
FILE
pointers, and posix file descriptors.
Package watt.math.*
The watt.math
package contains modules that deal with numbers.
watt.math.floating is imported by
math
's package module, and contains most of the 'normal' math constant and functions;sin
,sqrt
,PI
, etc.watt.math.introspection is imported by
math
's package module, and contains some functions for detecting 'special' floating point values like infinity, and NaN.watt.math.random contains a psuedo-random number generator.
Package watt.text.*
The watt.text
package contains modules that process text of various formats and purposes.
watt.text.ascii contains functions that classify characters that fall in the ASCII range.
watt.text.demangle contains functions for demangling Volt symbols.
watt.text.diff processes two strings and outputs the difference between the two.
watt.text.format contains the function
format
, a function that allows a string to be formatted according to input and a format string.watt.text.getopt contains a suite of functions for processing command line arguments in a simple way.
watt.text.html contains some functions for dealing with HTML text.
watt.text.path is a module that normalises file path strings.
watt.text.semver is a module that provides facilities for parsing Semantic Versioning strings.
watt.text.sink provides a facility for building long strings of text efficiently.
watt.text.source contains a
Source
class intended for computer language processing applications' parsing/lexing phases.watt.text.string has multiple functions dealing with simple string processing operations, like stripping, replacing and finding substrings, and so on.
watt.text.utf has functions for decoding and encoding UTF-8 strings and characters.
watt.text.vdoc has functions for dealing with vdoc (Volt's documentation comment syntax) strings.