Skip to content

About

Official documentation for the Nitpick language and compiler -- HTML, man pages and Markdown, built once the compiler is finished. Until then the specification lives in nitpick/meta/specs.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Nitpick documentation

Start with INSTALL.md for the source installation, LLVM tools, PATH setup and first program. Save the npkbuild helper from its first-program section. For hello.npk, use:

npkbuild hello
./hello

Read these guides in order, saving the driver guide (3) for after page 6:

  1. Quick start: a first program, bindings, functions and Result, errors and failsafe, control flow, structs, and a library import.
  2. Cheat sheet: short examples of calls, operators, types and literals.
  3. Driver guide: an advanced page, best read after page 6, once you know the language basics. It covers the SDK header, C build setup, library paths, and a Nitpick client with a C driver.
  4. Numbers: integer types, overflow and wrapping, tbb, wide integers, floats, frac, tfp, the two casts, and the rounding rules.
  5. Errors and failsafe: functions that can fail and their Result, ?|, ?!, raw and relay, setting a result aside, declaring errors, failsafe, and defer.
  6. Control flow: if and the is ternary, pick with ranges, guards and fall, the loops while, for, till, loop and when, labelled break and continue, exit, and which loop to use.
  7. Structs and enums: declaring and making a struct, fields, structs as parameters and results, fixed, a field with limit<Rules>, enums with tags or data, and why a pick over an enum must cover every variant.
  8. Strings and moves: a string owns its text, why = doesn't copy one, .clone(), comparing with .eq and ordering with .cmp, lending a string to a function, handing it over with move, and structs with a string field.
  9. Arrays and lists: fixed-size arrays and their length, reading and writing an element, looping over an array, an index out of range, the growable List<T>, arrays of plain structs, and passing arrays and lists to functions.
  10. Modules: a program in several files, the ways to import, what pub exposes and what stays private, re-exporting with pub use, sharing a struct and a rule, errors across modules, import cycles, and name clashes.
  11. Generics and traits: one function for several types, a struct for several types, when to write ::<T>, traits and their impl, bounds such as T: Shape, why a generic body may use only what its bounds give, and the refusals of common mistakes.
  12. Ternary and nonary numbers: balanced ternary and nonary digits and place values, the types trit, tryte, nit and nyte, their literals, arithmetic and ERR, three-valued logic, reading one digit, and casts.

The guides and examples come from the public documentation repository, on branch main, with the guides at its top level. Clone it beside the compiler clone, so that nitpick/ and nitpick-docs/ share a parent folder. For the hello example, work in examples/01_hello/: run npkbuild hello, then ./hello. See the driver guide for examples/02_driver/ and its build commands. See contracts for requires, ensures, and the checks Z3 can prove. See limits for rules on locals, parameters and struct fields. For further reading, see the reference files in meta/specs/ in the compiler clone (nitpick/). Editor highlighting for VS Code, nano, vim and Emacs is in nitpick-tools.

The guides were checked against compiler commit 64861f8, and again at 226ebb99 (the quick start, the cheat sheet, and the driver guide's caution note and example). The numbers and errors pages were checked at 3a45b7c4. Each example page names the commit it was checked against.

About

Official documentation for the Nitpick language and compiler -- HTML, man pages and Markdown, built once the compiler is finished. Until then the specification lives in nitpick/meta/specs.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors