Files
sakurac/docs/roadmap.md
T
2026-12-06 13:52:57 -06:00

9.3 KiB

Roadmap: a language that holds

Written 2026-10-20, when you chose the recommended answer to every decision it asked, and cut on 2026-10-29 to what's left. Steps 1 to 6 are built: extern and the system library, core, contracts, the checks, the rules settled, and properties as C# writes them, and the rule for references and values beside them. The CHANGELOGs keep what each did, and later.md what each left.

What's left: the way to a language that stops changing under the programs written in it.

  • Step 7, lambdas that own what they use, the last change to the syntax.
  • What else must be decided before the freeze, as it would refuse programs if done after.
  • Step 8, the freeze.

Plans that only add come after the freeze (decision 5): freestanding.md, the library plans (algorithms.md, benchmarks.md, linear.md, logging.md, random.md and tui.md), and the compiler's own speed. Each one built first puts the freeze further off, and none of them needs it to wait.

What "stable" means

From the freeze on, a program the compiler accepts:

  • is accepted by every later compiler;
  • means what it meant.

So a change after the freeze can only add:

  • modules, functions and types in std, core and system;
  • attributes and intrinsics;
  • warnings;
  • words that mean something only where they stand, as ensures does at the start of a statement;
  • accepting what was refused.

Adding a name can't break a program, since a program's own declaration hides a name of core's and a built-in type: a program's struct u32 hides the built-in one. A method a program declares on a type of core's wins over one core adds later with the same name, so adding a method is an addition too.

Anything that would refuse a program, or change what one does, comes before the freeze or not at all. Where it's unclear, refuse: accepting something later is an addition, but refusing it later is a break.

The freeze doesn't cover (decision 4):

  • std's modules and their names, which change as a library's do, std being a repository of its own, versioned apart from the compiler;
  • the compiler's options, IR and messages;
  • how an ordinary struct is laid out. An extern section's layout is promised, and so will be freestanding.md's @packed and @align;
  • the calling convention between Sakura functions;
  • speed.

Before the freeze

What Why it can't wait Where
How a lambda owns what it uses, and whether every lambda has a type of its own Giving every lambda a type refuses two lambdas given to one variable that isn't declared with a function type Step 7, below
Whether a constant may hold what's written through, as a string The compiler takes it, and the README refuses it later.md, What a constant may hold
Whether decl_of of a built-in type is refused The compiler gives a declaration, and the README refuses it later.md, decl_of of a built-in type
Whether a type that leaves a trait's default out meets the trait only by naming it It would refuse what passes today. The other way, defaults reaching every type meeting the trait, only adds later.md, A trait's defaults reach only the types naming it
Whether reading a moved local is an error It would refuse what builds today. As a warning, it can come any time later.md, Tracking moved locals

The rest of later.md adds, or is the compiler's, std's or the tools' own, which the freeze doesn't cover, so it can come after.

Lambdas that own what they use

Step 7, decisions 2 and 3, both decided (a). Its own plan measures and builds it, once you say to start.

What can't be written today:

  • a lambda that keeps state, returned;
  • a thread given a lambda that owns what it uses. A loop's variable goes through spawn_with;
  • a lambda kept in a function past the frame that made it.

Today the first and third take a functor, which is three declarations, and the second takes spawn_with:

struct counter : invokable<def(): i64> { var count: i64; }
def counter::invoke(&mut this): i64 { this.count++; return this.count; }
def make_counter(): function<def(): i64> { return function::new(counter{}); }

thread::spawn_with(def(i: i64) { work(i); }, i)

The direction (decision 2): the lambda's own values in its parameter list, declared as locals are. A parameter written val or var belongs to the lambda:

  • it's made where the lambda is written, from the scope around it;
  • it's kept from call to call;
  • a call doesn't give it.
def counter(): function<def(): i64> {
  return def(var count := 0): i64 { count++; return count; };
}

for i in 0..4 {
  val made := thread::spawn(def(val i := i) { work(i); }) else (e) { return; };
  handles.append(made);
}

var lines := read_lines(path);
thread::spawn(def(var lines := move(&mut lines)) { write_all(&lines); });

val scaled := def(x: i64, val k := factor * 2) => x * k;    # k is worked out once
lambda_param = ident [ ":" type ] [ "=" expression ]
             | ( "val" | "var" ) ident ":" [ type ] "=" expression ;   (* the lambda's own *)
  • The signature leaves them out: the lambdas above are def(): i64, def(): void and def(i64): i64. They come after the parameters a call gives.
  • There's no new word and no brackets. val, var and := already mean "a value made here", and a val can't change while a var can, as for locals.
  • A lambda with none of them is today's. It still refers to anything else it uses.
  • The parser is ready for it: a parameter starts with a name today, so val and var there are free.

What it needs:

  • A lambda that owns a value has a type of its own, a struct of what it holds that implements invokable<S>. In effect it's a functor the compiler writes. It can't be a function value, since a function value owns nothing.
  • It's moved, not copied, once it holds something that closes, and it closes what it holds.
  • Where a function<S> is expected, it becomes one. That's later.md's "Converting where a function is expected", now that core holds function.
  • spawn takes anything invokable. spawn_with and carrying go.
  • A lambda that refers to locals keeps today's rules, and today's warnings, which since 2026-10-29 follow it through a call whose parameter is @kept, as function::new's and spawn's are.

Every lambda has a type of its own (decision 3), converting to a function type wherever one is expected. Generic code then takes each lambda as its own type, so a lambda costs what a functor does:

  • the adapters, which cost 3 to 4 times functors today (later.md, "Lambdas given to adapters");
  • a sort's order, which no optimization reaches otherwise (algorithms.md, decision 4).

What it refuses is two lambdas given to one variable that isn't declared with a function type:

var pick := def(x: i64) => x + 1;
pick = def(x: i64) => x * 2;              # refused: two lambdas, two types
var chosen: def(i64): i64 = def(x) => x + 1;
chosen = def(x) => x * 2;                 # both convert

The cost is an instance of generic code for each lambda given to it, which the plan measures.

Probed on 2026-10-20:

  • There are about 340 lambdas in std, the compiler, its tests and its tools. Each refers to the locals it uses, and none can own a value.
  • std has eight functors: function, six adapters, and carrying<A>, which stands in for a lambda that owns what it's given, for spawn_with. The compiler's own sources start threads with spawn_with three times, and 13 test files write a functor by hand.
  • Every lambda the tree gives to an existing variable goes to one declared with a function type: fields of a def type, var fib: transform, a maybe<def(i64): i64>, and a val maybe: def(): int chosen by ?:. No array holds lambdas. So decision 3 refuses nothing in the tree.

Not chosen:

  • std's bind(f, values...), a functor holding the values and passing them by &mut ahead of the call's arguments, with no syntax. It could still be built beside the direction chosen, if a library wants it.
  • own val and own var in the body, which read like the body but run at a different time than the lines under them.
  • Functors, as now.
  • Turned down on 2026-10-19: a list in brackets, as C++ has, of initializers ([count = 0]) or of words ([move log, level]), and move def, as Rust has.

The freeze

Step 8, decision 4: additions only, from then on. Editions can come later without breaking it, since a file that names none would be of the first.

  • The README's grammar and rules are the language. A line says from which version.
  • A corpus of the grammar: a program for each rule of the README's grammar that none of tests/programs uses yet, each with its .out. A change that breaks one fails a test.
  • The bootstrap rule from then on:
    • the compiler's own sources use only the language and std of the release before;
    • a release is built in two steps: the release before, with its own std, builds a first stage from the new sources, and that stage, with the new std, builds the release.