Operators and Expressions
Statements and Expressions
One of the first details that you may notice when perusing a Jock programming is how the statements are sometimes terminated with semicolon ;
“mic”. Jock uses ;
“mic” to separate statements that are “composed” together in Nock. Thus their usage is not random, but similar to Rust describes statements that do not result in values.
For instance, this program imports a library, defines some variables, and results in a final atom:
The earlier statements modify the execution context, or subject, of the final value, and as such as marked with ;
“mic”.
In contrast, statement which sit “together” (as the methods in a class
) are not delimited by ;
“mic”.
Jock commonly relies on the compose
pattern (as above) to explicitly include a data structure in the appropriate execution context (subject).
Arithmetical Expressions
Parentheses ()
"pal”/“par” are furthermore used to collect terms for operators in arithmetic. Right now, Jock binds to the right (like APL), although we expect to implement a more intuitive operator precedence later.
Built-in arithmetic is supported for unsigned integer operations only.
+
→ Hoonadd
-
→ Hoonsub
*
→ Hoonmul
/
→ Hoondiv
**
→ Hoonpow
%
→ Hoonmod
These will be expanded and support for floating-point operations added at a later release.
Logical Expressions
Built-in comparisons
<
→ Hoonlth
>
→ Hoongth
<=
→ Hoonlte
>=
→ Hoongte
==
→ equality, Nock 5!=
→ inequality
These apply to atoms only, except for ==
and !=
which can be used for any two nouns.
Code Blocks
While {}
“kel”/“ker” generally denote sets, braces are also used to mark collected code blocks for certain keywords such as if
and match
. In cases where these need to result in a set, the braces are doubled.
Contrast that result, which is a bare atom, with the result of the following:
This results in a Set(@)
or set of atoms with a single member, 72.
(Note further that if
and else
are always paired—there is no standalone if
.)
Last updated