Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Dev/Prod Split

Type checks and contracts are safety tools. They catch bugs during development. They cost cycles in production. Lykn lets you have both.

The Flag

# Development — all assertions emitted
lykn compile src/app.lykn

# Production — assertions stripped
lykn compile --strip-assertions src/app.lykn

What Gets Stripped

FeatureDev mode--strip-assertions
:args type checksEmittedRemoved
:returns type checkEmittedRemoved
bind type checks (DD-24)EmittedRemoved
:pre contractsEmittedRemoved
:post contractsEmittedRemoved
type constructor validationEmittedRemoved
Multi-clause dispatch checksEmittedKept

The last row is critical: multi-clause dispatch checks are not assertions. They’re runtime semantics — they determine which clause runs. Stripping them would change the function’s behaviour, not just its safety. The compiler keeps them.

The Tradition

This follows a well-established pattern. Eiffel introduced assertion monitoring levels in 1986 — you could enable preconditions, postconditions, or both, independently, per class. Clojure’s *compile-asserts* flag toggles spec-based validation. Common Lisp’s (declare (optimize (safety 0))) tells the compiler to skip type checks.

The principle is consistent across all of them: contracts are a development tool, not a production tax. You write them once, they protect you during development, and they vanish when performance matters.