Language Basics
Jock is a high-level, general-purpose, functional programming language which targets the Nock ISA. Jock supports basic programming control constructs and data types, as well as cross-compatibility with Hoon (a powerful lower-level language also targeting the Nock ISA). Jock's syntax is similar to Python, Swift, Ruby, and other scripting languages.
Every Jock expression must result in a value, and values must be composed together in a “sensical” way. As a language which is functional-as-in-Lisp-like, Jock can emit side effects, but typically is conceived of as a pure function operating on input.
The simplest possible Jock programs are, therefore, simply data literals, like 5
. We call bare values like these atoms and collections of them cells (pairs) or tuples (general n-ary).
Atoms
Jock currently supports the following data types:
A noun is the most general type, being either an atom or a cell; the type is written
*
.1.000
is a numeric atom 1000 or 1,000 (German-style delimiters); the type is written@
orAtom
orUint
.0xdead.beef
is a hexadecimal atom; there is not yet a type marker.'this is å message'
is a string atom; there is not yet a type marker.true
/false
are loobeans; the type is written?
.%txt
is a text constant or symbol.
Containers
Containers are collections of other containers and/or atoms.
Cell/Tuple
The simplest container is a cell (Nock pair) or a tuple.
(1 2) // a pair of atoms
(1 2 3) // a 3-tuple of atoms
((1 2) (3 4)) // a pair of pairs of atoms
The next simplest container is a list (null-terminated tuple), which has its own syntax.
[1 2 3] // a list of atoms (resolves to Nock [1 2 3 0]
[1 2 (3 4)] // a list of atoms and cells
Jock also supports Set
s, collections of unique elements.
{1 2 3 4 5} // a Set of atoms
Expressions
Expressions in Jock may be as simple as data literals (as above), ranging up to function calls and operator expressions.
(5 * 12) / 6 // an expression resolving to 10
hoon.met(3 'hello') // count the bytes (2³) in 'hello'
Statements
Statements involve Jock keywords and must adhere to Jock syntax.
let a = [1 2 3]; // a list of atoms
hoon.lent(a) // the length as an atom, 3
Most statements end with a required ;
“mic” to denote the program's continuation. Only terminal expressions (expressions that result in a value to be returned out of the evaluation tree) do not end in a ;
“mic”.
Variables
Variable names (including method names) are snake-case.
let a_1 = 5;
a_1
Type names start with a single upper-case letter.
type Foo {
// ...
}
Last updated