Quilt·
Lesson 1 of 7

BIND — give a name to a value

BIND is the simplest opcode. It says: this name refers to this value. Like writing a variable in a programming language, except the binding is recorded in a journal so you can replay it, time-travel through it, and roll it back.

01The shape of BIND

BIND takes two arguments: a name and a value. The name becomes a cell. The cell holds the value. The journal records the binding with a timestamp.

substrate.bind("greeting", "hello, world");
// journal: [
//   { op: "BIND", id: "greeting", value: "hello, world", t: 0 }
// ]

Try it below. Type your own BINDs in the editor on the left. The journal on the right shows what happened.

02Try it

lesson-1.js
Journal · cells: 0

03The law: idempotence

BIND is idempotent. If you bind the same name to the same value twice, only one event is recorded. This is not an optimization — it's a law. It means the journal is a set of facts, not a sequence of changes. Replaying the same journal produces the same state, every time.

sub.bind("x", "hello");  // event 1
sub.bind("x", "hello");  // no event (idempotent)
sub.bind("x", "world");  // event 2 (different value)

Why does this matter? Because it means your code is safe to retry. If a network call fails partway through and you re-run the same BINDs, the state doesn't get corrupted. The journal stays clean.

04What you can build with just BIND

A key-value store. That's it. BIND is enough. Every other feature — pub/sub, version control, time travel, search — is built by combining BIND with the other 4 opcodes.

The /apps/kv page is a working key-value store with a BIND-only backend. It's 30 lines of code. The whole thing.

05Next

A name without a relationship is lonely. Let's draw some arrows. Lesson 2: LINK →