The quick start gets a program running and the quick guide explains the ideas. This book is the language itself: every form you can write, what the compiler checks about it, and how you can tell by looking whether a piece of code will pass.
How to read it
Each chapter introduces a few forms, shows a complete program for them, and shows what the compiler says when you get one wrong. Everything on these pages was built and run with the kursal compiler. The error messages are real ones, with each path shortened to the file's place in its package, such as lib.kur:line:col or src/lib.kur:line:col.
Most chapters end with a short check by hand note: what you would look at to decide, without the compiler, whether the code is accepted. That is the habit the language is built around.
The book covers the language only. Examples use the standard library (print, Buffer!, range and so on; print(x) takes any value of a type with a Printable instance, and a Buffer! printed this way is freed) and say in a line what each piece does, but they do not document it. The full library reference will live at docs.kursal.dev.
kursal has not had a 1.0 yet. Where a feature is likely to change, the chapter says so.
Part 1: the everyday language
- Getting started: packages,
kursal build, the shape ofmain, files as modules. - Values and operators: numbers, bytes, strings, tuples, arrays, precedence and
as. - Bindings and control flow:
letandvar, functions,if,while,return,const,!. - Structs, enums and match: declaring data, building it, taking it apart.
- Methods:
impl,selfand&self, associated functions and constants. - Linear types: used exactly once, on every path.
- Generics and traits:
forall,where, instances, and when a call is resolved. - Option, Result and
?: absence and failure as values. - Closures and function values: captures, and what a linear capture does.
forand f-strings: two pieces of syntax that call a trait.- Modules, packages and encapsulation:
use,export, dependencies, and who may build a type.
Part 2: resources and contracts
- Places and lending:
¶meters, moving out and restoring, and why there are no references. - Brands and existentials:
'k,exists,pack, and values that belong together. - Capabilities in practice: handles that grant nothing, linear capabilities that grant access.
- Unsafe and raw pointers: one operation at a time, and the obligation each one carries.
- Calling C with extern: declaring, linking and calling foreign functions.
- foreach traversal: code that visits every field. Advanced, and likely to change.
- Concurrency: moving ownership into threads, and sharing through capabilities.
- How checking works: local checking, place state, and the independent core checker.
Appendices
- A. Keywords and operators: every reserved word, and operator precedence.
- B. Grammar summary: the surface syntax in one place.
- C. Glossary: the terms this book uses.