Jock Documentation
  • Introduction to Jock
  • Getting Started
  • Language Basics
  • Operators and Expressions
  • Functions
  • Control Flow
  • Data Structures
  • Classes and Objects
  • Compiler
  • Hoon Interface
  • Nock Interface
  • Language Reference
    • ASCII
  • Tutorial
Powered by GitBook
On this page
Export as PDF

Hoon Interface

Jock supplies a foreign function interface (FFI) to Hoon. Thus, Hoon functions may be accessed from within Jock. In fact, this is how many basic operations in Jock (such as arithmetic operators) are implemented.

The basic pattern is to invoke the name from the hoon namespace:

let a:@ = 5;
let b:@ = 37;

hoon.add(a b)

(You must therefore follow Hoon's expectation about argument signature and function arity.)

Certain operators also automaticaly desugar to the appropriate Hoon. This is subject to revision as the type system grows in sophistication.

4 + 5

Hoon operations are available under the hoon namespace, e.g. hoon.dec(5) will yield 4 . A limited subset of operations are available through operators, such as + and - for add and sub, respectively.

The Hoon implementation is a slight extension of /lib/tiny, which contains essentials for calculations but omits the parser and compiler, among other extensions.

hoon.dec(5)

Hoon functions specialized to work with data types like lists can also be accessed:

let numbers = [1 2 3 4 5];
hoon.lent(numbers)

Importing Libraries

Hoon libraries can be imported using the import keyword. At the current time, only hoon can be (and is automatically) imported, pending better support for arbitrary files in choo.

PreviousCompilerNextNock Interface

Last updated 26 days ago