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

730 lines
41 KiB
Markdown

# Later
What the built plans left for later, and the problems they found and didn't fix. Each item
was checked against the compiler and std on 2026-10-28, and is still open unless it says
what's left of it. What was built since went, as did the records of what was built, which
the CHANGELOGs keep.
The plans not yet built keep their own "Later" lists: [algorithms.md](algorithms.md),
[benchmarks.md](benchmarks.md), [freestanding.md](freestanding.md), [linear.md](linear.md),
[logging.md](logging.md), [random.md](random.md) and [tui.md](tui.md).
[roadmap.md](roadmap.md) says what's left before the language's freeze, and which items
here must come before it.
## The language
### Lambdas that own what they use
A lambda only refers to the locals it uses. Whatever must outlive its frame is a functor
written by hand, or a `function` holding one. Capture lists, or a `func` that owns what it
captures, would let a lambda be returned or given to a thread. You set both aside when
the memory plan was built ("for now"). A `function` holding such a lambda would own what
it captured with nothing in `function` changed. It's the roadmap's last step, with
directions that avoid a list in brackets ([roadmap.md](roadmap.md#lambdas-that-own-what-they-use)).
### References and values: what the rule left
What the rule "where a value goes says what happens to it", built on 2026-10-22, left:
- **Only named functions are adapted.** A lambda whose parameter types are written,
as `def(s: &string)` given where `def(&mut string)` is asked, and a function value
held in a variable, must still match. A lambda with its types left out takes them
from where it goes.
- **A copy of `T` in generic code is refused only per instance.** `val x := v[i]` in a
generic over `T` copies, and an instance whose `T` closes reports it, as C++ would.
A bound saying "closes nothing" would let the template report it once.
- **`&&T` still exists inside instances.** Where a type parameter is a reference,
`&x` of a `T` refers to the variable holding it, as the template means. Only
generic code sees such a type; a function given where one is asked is adapted.
- **A reference variable is pointed elsewhere by a reference written as one**, `r =
&y`, as C++'s pointers are and its references aren't. Refusing it would match
C++'s references, but chains walked by reassigning a reference need it.
- **An overloaded member named with its type's arguments**, as `box::<i64>::get`,
is the first overload, not the one the type expected chooses. Named without them,
`box::get` chooses.
- **`for x` copies each element**, which for a large struct costs a copy that
`for &x` avoids. How often the optimizer removes it hasn't been measured; for a
256-byte struct at `-O2`, it did.
### Joining text with `+`
`string + strview`, with `+=` as an `add_assign` that appends in place, which a compound
assignment calls since 2026-10-20. The compiler refuses `+` today: "`string` has no `add`
taking a `&strview`, which `+` calls."
### More operator traits
- Traits for mixed operands, as `scales<S>` for a vector times a number, once programs
show which ones they need.
- A partial order for floats, so generic code can say what NaN does.
- There is no `bitwise` trait, by decision: a program's own trait gives `&`, `|` and the
shifts to generic code.
### `strview` has no order
`strview::compare` takes the other view by value, so `strview` isn't `ordered`, and
`v < w` of two views is refused: "`strview` has no order". So the note refusing `s < v` of
a `string` and a view, which asks for `s.span`, leads to a second refusal.
### A trait's defaults reach only the types naming it
A method a trait writes a body for is its default, which a type may leave out. The compiler
counts a type as meeting the trait by its methods, whether or not it names the trait, but
only one naming it gets the defaults. So a struct with only `put` passes `where S: sink`
for a `sink` asking for `put` and giving `done`, and `S is sink` is true of it, and the
instance then fails where the generic calls `done`: "`plain` has no field, property, or
method `done`. (In `finish<plain>`)". Either the defaults should reach every type meeting
the trait, or a type leaving a default out should meet the trait only by naming it. The
first would let `writable` give a `flush` that does nothing, so `flushable` could go with
`if const S is flushable` in `std::io::writer`. A constant a trait gives a value is a
default the same way, since 2026-11-19, taken only by a type naming the trait.
### Named constants without a type
`const pi := 3.14` is an `f64`, and `const k := 7` an `i64`, so `val x: f32 = pi` is
refused, where the literal would fit. `std::math`'s constants are `f64` for that reason,
and f32 code writes `math::pi as f32`.
### What a constant may hold
```sakura
const b: box<i64> = box::new(3);
const s: string = string::from("abc", nothing {});
```
The compiler takes both, and a `vector<i64>` made by a function, on the machine, under
`--checks` and in executables. The README says a constant holds what is only read, "so a
`span<T>` works and a `string` doesn't". Which is the language isn't decided, and refusing
them later would break programs, so it comes before the freeze ([roadmap.md](roadmap.md)).
### `decl_of` of a built-in type
`decl_of::<i64>()` gives a declaration named `i64`, whose kind is `target::all`, 65,535, so
`decl_of::<T>().kind == target::structs` is false of it but
`(kind & target::structs) == target::structs` is true. The README says `decl_of` takes "a
type a declaration makes, so not a reference or a number". Refusing it, as "`i64` is built
into the language, so there is no declaration of it to describe.", would break programs
later, so it comes before the freeze too.
### `type_of(f)::name()`
It doesn't parse: "Expected `)` to close the arguments. Found `::`." `std::args` works
around it with generic helpers, as `switched::<type_of(f)>()`, `is_command` and
`shape_of`.
### Documentation as a reflection intrinsic
An intrinsic giving a declaration's `#!` comment would let `std::args` print a field's
documentation as its help, rather than `help = "..."` repeating it. Only the language
server reads those comments now.
### Thread-local variables
`@thread_local var`, reached through the thread's record at `gs:[offset]`.
### 128-bit integers
Their multiplication would serve `fma` and hashing.
### Tracking moved locals
A local moved on every path needn't be closed at all, and reading one after a move could
be an error. The checker doesn't track moves: a moved-from value is left zeroed and
closed as usual.
### `equatable` and `hashable` for `void`
They'd take methods the compiler gives, and nothing needs them yet. So `dict<void, V>`
fails at `hash<void>` and `equals<void>`.
### Refused for now
What the rules settled on 2026-10-20 refuse, where accepting it later is an addition:
- **A function ending in `while true` with no `break`:** "The function can end without
returning a value."
- **A lambda's types inferred through overloads,** as `go(def(a) => a + 1, 2)` where two
`go`s take a function: "The call fits more than one overload of `go` as well". Merging
`spawn` and `spawn_with` waits on it ([Threads](#threads)).
- **A variable declared through a generic type,** as `var holder::count: i64 = 0;` for a
`holder<T>`.
- **A property of a type rather than a value.** Every property is a value's. If one's
wanted, it's better marked in the declaration, as `get()` with an empty list, than
inferred from whether a body uses `this`, which a trait's `{ get; }` has no body to
tell by.
### What `match const` left
Built on 2026-11-16, with `core`'s traits naming a type's parts (`pointer`, `reference`,
`array`, `generic`), `T is vector`, and packs of types walked and indexed; then aliases
of it standing for what they choose, branches and arms ruling out what they don't fit,
a body checked once for each case, and trait constants as constants; then the shapes of
`T: array` and `T is vector`, `C ? A : B` types, what follows a leaving branch checked
per case, and a trait ruling out what implies it; then shapes of generics taking packs,
bounded as the generic bounds them, `*x` of a `T: pointer`, and branches naming a type
checked within the generic; then tests of types, calls, and `==` choosing types, each part
of a condition resolved with what the parts before it proved, constants only an instance
decides worked out for each, and generic types' own variables and constants; then values
given as types not chosen yet, or used, checked in each way those can be chosen; then
ternaries choosing by constants naming type parameters, `match const` of values, and
`T: reference` as a reference. Left:
- **Patterns that name parts,** as `pair<type A, string>` or `type L[const N]`. The style
is settled: a name a pattern declares is written `type A`, or `const N` for a constant,
only where a known type could stand too, so parameter lists keep `<L[N]>` and
`<def(Ts...): R>` bare. Today such a shape is a trait arm and a test within it, as
`pair => if const T::args...[1] is string { ... }`, which leaves the arms after it
untried. `match const` refuses `type` there now, so it's an addition.
- **`C ? A : B` takes a name, `!` of one, a call, a name tested with `is` or compared
with `==` or `!=`, or `( expression )`, and what `&&` and `||` join to those,** so
`N > 4 ? A : B` needs its parentheses, since `<` and `>` are a type's arguments; `!`
takes only a name, so `!small(N) ? A : B` needs them too; after `as` or `is`, `?` is
the expression's; and among type arguments, `M ? K1 : K2` of two constants' names is
read as types, where `(M ? K1 : K2)` is a constant, and `!M ? A : B` is read as a
value.
- **`if const A && B` checks `B` before `A` proves anything,** so `if const T is pointer
&& T::target is integer` reports `T` having no `target`, twice, where a type's
condition resolves `T::target` with what `T is pointer` proved. Within an instance,
`T::target` as a value's path, as the left of `is`, is refused where `T` is given a
pointer, though the type `T::target` is found through `pointer`.
- **A fault working out a constant for an instance doesn't say which,** so `split<0>` of
`type split<const N: u64> = halves(N) ? u8 : u64;` reports "Evaluating `<value>`
stopped: Division by zero." at `halves(N)`, with nothing of `N` being 0.
- **A note a value of a type not chosen yet gives where it converts says its type
whole,** as "Expected `u32`, but the value is `N == 4 ? u32 : uint`." of `return w +
1;` within `def f<const N: u64>(w: word<N>): u32`, where a note said in one way of what
uses it says which way. A way that only says what fails says nothing of it either, as
`T` not converting to `&T` where `T` is neither a reference nor a pointer, said
without "(Where ...)".
- **`match const` of values takes values written in place as patterns,** as `4`, `-1`,
`'a'`, or `true`; a named constant or an enum's member is read as a type there, so
`match const N { MAX => ... }` reports no type `MAX`. Such a pattern would be read as
the constant it names where the subject is a constant.
- **A `match const` value whose arms share no type is an error** within a generic's own
body, where a ternary choosing so is of a type chosen as its condition chooses, as `M
? u8 : strview`.
- **What follows a guard testing a value of a type not chosen yet** names what the test
names as the first way the type can be chosen does, so after `if !(h is some(x)) {
return 0; }` of a `W ? maybe<u64> : maybe<u8>`, `x` is a `u64` in what follows,
where each instance has its own.
- **A `match const` value's type in an instance** is the one its arms share in the
generic's own body only where that body is checked first, as it is for a program's
generics; otherwise it is the chosen arm's.
### What sealed traits left
Built on 2026-11-19: `@sealed` traits, whose constants and types are their own, read
through the trait given its arguments, and trait constants' values as defaults. Left:
- **A sealed constant in a condition says what its value tests only of a type parameter
given for one of the trait's own,** as `owns::<T>::value` does. Given a type holding
one, as `owns::<&T>::value`, it says nothing within the generic's own body, so a branch
it guards is checked knowing nothing, and each instance decides it. Its value says
something only through `is` tests, `&&`, `||`, `!`, and other sealed constants, as
`if const` does.
### What pack fields left
Built on 2026-11-19: a struct's field holding a pack, `items: Ts...`, `core`'s
`tuple`, and a pack's type at an index worked out from constant parameters,
`Ts...[I]`. Left:
- **A pack given whole to a parameter,** as `take(args)` of `take<T>(x: T)`, gives `T`
the pack, which each instance then refuses with "A pack is passed on among type
arguments written `Ts...`". The call should be refused where it is written, as a pack
bound to a local now is.
- **A field's pack is written a value at a time,** or given whole by a literal: `t.items
= args` is refused as a mismatch rather than writing each value.
- **`tuple` names no traits,** since a struct names its traits for every instance and
none can be named only where each of its types implements them. So a tuple is copied
byte for byte where nothing in it closes, and no `copy_of`, `move_of`, `equals`,
`hash`, or `compare` reaches through one.
- **No destructuring,** as `val (a, b) := t`, and `t[0]` is not `t.items[0]`.
- **A known pack at an index only a template knows,** as `pick::<J>(1, true, 2u)`
within `def outer<const J: u64>()`, is a type parameter bounded by nothing there, so
returning it as a `bool` is refused even where each instance made gives a `bool`. A
`match const` over the index's values would check it as each way instead.
- **`for const` over a field's pack reached through `&this`** reports a write to its
variable once for each of the pack's types in each instance.
### Contracts
What the contracts plan left for later:
- **Contracts on a trait's methods,** checked for every type implementing it.
- **`old` of what closes,** copied and closed after the check.
- **A type's invariant,** checked after each of its `pub` methods.
- **The checker proving contracts:** warning where one always fails, and leaving out one
it proved, from what it already knows of bounds.
- **Levels,** as `--contracts expects`, keeping pre-conditions only.
### Calling C
What the ffi plan left for later:
- **C's variables,** as `errno` or `environ`: a `var` in an extern section is a Sakura
global of its own.
- **Variadic C functions,** as `printf`. A parameter written `i64...` passes a span.
- **A C name that isn't a Sakura name,** as a keyword: a name given to the symbol apart
from the declaration's.
- **The machine calling C on Linux,** with System V's convention, so a program calling C
runs without being built. It stops where it reaches one, or a C function's address: "Program
uses a construct that cannot be compiled."
- **`system::macos` and `system::freebsd`.** macOS needs `libSystem` and a Mach-O writer.
## The compiler
### Addresses made numbers while evaluating
- **`remove_at`, `extend` and `string::append` in a constant.** std's containers work in
a constant, but `memcpy` (`core/mem.sakura`) turns two addresses into numbers to compare
them where it moves 8 bytes or more, so evaluating stops there: "Function does not run
while compiling. at memcpy". Comparing the pointers themselves (`p < q`, `q - p`) runs
in a constant, so `memcpy` could do without the numbers.
- **The note doesn't say why.** Evaluating says only "Evaluating `k` stopped: Function
does not run while compiling.", with a trace, where it could say that an address is
only known where the program runs, so pointers and integers don't convert while
compiling.
### Small unions as values
A union of two or three words, as `maybe<u64>`, would be held as words and returned in
`rax`, `rdx` and `rcx`, so a range's `next` gives its `maybe` in registers. It's returned
in memory now. The iterators plan's numbers held without it.
### Lambdas given to adapters
`v.iter().filter(lambda).map(lambda).sum()` costs 3 to 4 times what functors do: 565 to
599 ms against 144 to 190 ms over ten million elements at `-O2` (`tools/iterators.sakura`).
The adapter is built by 16-byte copies, and its lambdas are called through `call_value`,
so they aren't inlined, even one whose function is known as a constant. Reading words
through wide copies, or a type of each lambda, would fix it.
### `box` within 10% of `raw_allocate`
The memory plan asked for it. `tools/memory.sakura` gives `box` 1.31 to 1.38 times
`raw_allocate`. What's left:
- walking a list through a `maybe<&T>` picks the next node with a `select` that the
loop's exit also reads;
- every `move` of a value that closes writes the zeroes its source is left with.
### Atomics
- **`lock add`, `lock or` and the like where the result isn't used,** as
`_ = hits.fetch_add(1)`, which is `lock xadd`. `fetch_and`, `fetch_or` and `fetch_xor`
would lose their `lock cmpxchg` loops.
- **Two-word atomics through `cmpxchg16b`,** for a pointer with a count beside it. The
oldest x86-64 processors lack it.
### What the vector work left
- **`%` of lanes is a loop over them,** as no instruction divides integers.
- **The least and greatest of real lanes, and the product of integer ones,** are loops.
`smallest` and `largest` work real lanes from lane 0, as which NaN or zero they give
depends on the order, which the instructions' pairs of lanes don't keep.
- **`scatter` writes a lane at a time.** Only AVX-512 has an instruction for it.
- **64 bytes, AVX-512's,** were checked only by disassembling what's built, as this
machine has no AVX-512. On one that has it, native's test
`vectors_of_64_bytes_give_the_same_bits_at_every_level` works each operation with the
instructions, and `tests/programs/simd_lanes_agree_everywhere_2`, built and run, does
too; the corpus itself runs on the machine. Such a vector is held in its
slot, never a register, and read a quarter at a time; a mask of one is a vector, and
`k1` holds it only within an operation. 64 bytes of 8-bit lanes aren't allowed, as their
mask's bits wouldn't fit a `u32`. The least and greatest of real lanes go a half or a
quarter at a time, and the sums across the lanes, `shuffle`, and changing the lanes'
type or size a lane at a time.
- **A struct of a size not a multiple of 16,** as three `f32` fields, is built a field at a
time: merging stores fills 16 bytes from a multiple of 16 only.
- **32-byte vectors go through memory a half at a time** in a function working several,
as `geometry`'s frustum test of eight planes as one `f32x8` did: each `select`'s and
splat's result was stored whole and read back as two halves, and each splat was two
shuffles where `vbroadcastss` is one. It ran no faster than a plane at a time, and in
one build twice as slow, where two `f32x4`s run twice as fast, so `geometry` uses those.
- **A vector's lanes read as numbers,** as `vec3::dot` adds its products' lanes, made
`geometry`'s rays two to three times as slow as the same dot worked a number at a time,
though `linear`'s bench of `dot` alone finds the two even. `geometry` works its dots a
number at a time.
### What the analyzer's tables left
What making the analyzer's tables smaller and its passes quicker left, as checking the
compiler's own sources measured it:
- **Vectors made for each call checked.** `arg_kinds`, `try_candidate`, the five vectors
`begin_inference` makes, and `check_args_bounds`'s copy of the parameters are made for
each call, about 1% of checking. They nest, as checking an argument checks its calls,
so a scratch column would need marks, as `type_table::substitute`'s has.
- **Rows for nodes that have no results.** A result table has a row for each node, but
many are never written: statements, type names, and declarations. Of a file's rows, 72%
are of nodes with results checking the compiler, and 15% checking a corpus program,
whose libraries are mostly not reached. Numbering only those nodes, as the analyzer's
rework built and took out, saved 1.5% of the instructions, and the peak resident memory
rose. It would pay where the rows of what isn't reached are never made, as with bodies
parsed when reached.
- **Evaluating what checking left.** Evaluating now runs while checking, where checking
asks (1% of checking the compiler), but what the compiler needs that nothing asked for,
the values of the constants it lowers, is still worked out after checking, in
`compile_time::finish`: 6.8% of checking the compiler, almost all of it lowering what
those constants call. It wasn't looked into.
- **Words written a field at a time.** `zeroed_cells` counts a word as written only where
one store covers it whole, so a cell built field by field, of fields narrower than a
word, is zeroed though every byte of it is written. Following 4-byte halves would catch
most structs.
### What the analyzer's rework left
What building the changes of "If we were to rewrite the analyzer" left, as checking the
compiler's own sources measured it (1,261M instructions after the rework, from 1,462M):
- **Instances checked again whole.** An instance checks every node of its template again,
about 15% of checking the compiler. Of its templates, 21% of the top-level statements,
which hold 53% of their nodes, depend on no type parameter, so an instance could read
those from its template's table. Built, it left lowering an instance recursing without end,
and it was taken out.
- **Bodies parsed when reached.** Of a corpus program's library bodies, those never reached
are 59% of the tokens, 19,529 in generic bodies and 15,680 in others; of the
compiler's, 7%. A generic's instance table covers its template's nodes in one run, so
its body is parsed with it; the checker holds the syntax's columns by address while it
checks, which nodes added while checking would move; and the resolver finds the
modules a body names from its paths, so a body skipped would have its paths read from
its tokens. The other bodies would save at most about 4M of a corpus program's 67M.
- **Bodies checked on threads.** Checking bodies is 48% of checking the compiler, but
bodies write what they all share: they make 6,157 of the 14,391 types, 3,241 of the
3,246 instances, 291 of the 903 knowns, and 3,987 of the 4,300 tables, and reach 8,195
of the 9,249 declarations checked. Those IDs reach what the compiler builds, so a build
that's the same every time needs them given in an order threads don't change, as in
declaration order once the bodies are checked, with each body's own new types, knowns
and instances held apart until then. The evaluator runs on one thread too.
- **Notes as data.** A note could be a code, a node, and a few IDs, its text made when
it's shown, once something reads its IDs, as the server offering fixes would. Today
the text made for notes left out is 0.01% of checking the compiler, `sakurac` shows
notes from another thread while checking goes on, which can't read the checker's
tables, and 85 notes write lists or numbers that a few IDs don't hold.
- **`quiet`.** What's checked for its results alone is checked with its notes left out: a
type written for `this`, an attribute's type as reflection reads it, a template's branch
where `if const` names what a parameter is, and an editor's query. Each could ask for
what it needs without checking, so no note is made to be left out.
- **IDs of their own types.** An enum can't be an ID's type, since a value cast to one
must be one of its members, and a struct of one `u32` is kept in memory, not a
register, so declarations, types, names and instances are still bare `u32`s; only a
file's nodes and a table's are told apart, by `file_node` and `table_node`. Either
needs the compiler to change first.
- **One more than an index.** The analyzer holds none, but `id_index` keeps an ID as one
more within its words, and the compiler holds many: `flows`' links, `reader_next`,
`program`'s `niche` and `adapted`, and a report's place.
- **Two records of an `if const`.** The checker records whether an `if const`'s condition
holds as the condition's value, and evaluating records it again in `decisions`, which
the compiler reads.
### What `@inline` left
- `@inline` on `checker::unalias`, a test of a type's flags and a call where it fails,
made the compiler 312 KB larger across its 342 calls, about 900 bytes each, and ran no
fewer cycles, so it isn't marked. What a copy takes at each call is worth seeing.
- std's own helpers called in its loops over text aren't marked, std being a repository
of its own: `json`'s `plain_stops` and `is_json_space`, and `yaml`'s `comment_ends`.
- At `-O0` a copy still writes each argument into its cell and reads it back, and each
span a copy returns waits on the stores that built it, so a chain of copies waits on
memory as a chain of calls does. Marked, `span::sub` and `span::over`, `find_byte`,
`find_last_byte` and `count_byte`, and `bytes8::upper` and `lower` were slower at `-O0`
(`find_byte` at `-O2` too), so they aren't. `swar::load_last` and `u8::digit_value`
gained only at `-O2`, by 4%, so they aren't either.
### aarch64
There's no aarch64 back end. Atomics would be `ldar`, `stlr` and `ldaxr`/`stlxr` loops or
LSE there, which is why an atomic's order is a value as the program runs, and `simd`
would be NEON.
### The command's name
`sakurac check --help` says `usage: sakura check`, and a wrong option says "Try
`sakura build --help`", the name the compiler had.
### Checked executables
`build --checks` makes the checks of a checked program, as indexes, and none of
`run --checks`' of memory. A runtime with a shadow map, as AddressSanitizer has, would
check an executable's references and pointers, and the bytes nothing wrote.
### Guard pages for the stack
A page nothing may touch below each stack would report an overflow from the fault, and
the prologue's compare with the stack's end could go. The compiler already leaves that
compare out of small leaf functions.
### Fresh pages taken as zero
The compiler's result tables read zero as "nothing yet", so they grow by zeroed
elements, a file at a time, and every byte is cleared. A vector grown into pages fresh
from the system could take them as zero without clearing them, if `raw_resize` said
which bytes it gave fresh. Only a vector's first allocation does that today.
### Reading libraries
What the std plan left for later:
- **The checked `core` kept between runs.** It's the same for every program, so the time
checking it takes could be read from a file the compiler wrote, rather than checked
again.
- **`core` written into the compiler whole.** It needs the compiler to take a file in
while compiling, as an `embed` intrinsic, which it can't now.
- **An index of a library's modules,** written by blossom where it fetches a package, if
a library's folders ever grow too many to list. The resolver lists each folder once,
but a module's files may be in any folder within its own, so finding the files of a
library's first module, as `std` where `--lib std=` names the whole repository, lists
every folder of it: the 403 folders of std's YAML test suite cost a corpus program 8M
instructions of 67M. blossom names each module's library, as `std::io`, which lists
none of them.
### Large blocks kept at one size
The runtime keeps up to 64 large blocks given back, 32 MB in all, but hands one out again
only for as many bytes as it was, so the token and node vectors the lexer and parser trim
to fit leave their old blocks resident, and so do the vectors that grew past them. Checking
the compiler peaks at 48 MB resident where the analyzer's tables hold 28 MB.
### What the race checker leaves
- **Two reads a word.** Of each word it keeps the last write and the last reads of two
threads, so a write racing a third thread's read, while two others read too, can go
unseen.
- **Atomics against plain reads and writes.** An atomic operation orders threads but isn't
kept as an access, so a plain write racing an atomic load of the same word isn't seen.
- **What only the frame reaches.** A cell no reference to which is taken is never watched,
which is right, as no other thread can reach it; one reached through a pointer made by
arithmetic on another cell's address is missed.
- **Executables.** It's the machine's; `build --checks` checks no races, as it checks no
memory (see [Checked executables](#checked-executables)).
### What overflow checks leave
- **Shifts and narrowing.** `<<` past the bits of a type, and `as` narrowing an integer,
wrap as they always do.
- **Negating an unsigned number** wraps, so `x & -x` works; Rust refuses `-x` of one.
- **Tests that wrap on purpose.** blossom gives a test run on the machine `--checks`, so a
test's own arithmetic is checked: `linear`'s and `geometry`'s fold their bits with
`mix` for that. std's `thread` tests seed a generator by wrapping, which stops only
where they're run with `--checks` by hand, as blossom runs them natively, unchecked.
### The machine interrupting waits
`system` has no signal to spare on the machine. While threads run, a futex wait without a
time lasts 0.1 s and std's waits wait again, a read blocked forever isn't interrupted, and
the first thread waits up to 3 s for the others as `main` ends. With a thread blocked
reading, `run` takes about 3.7 s, where the executable ends at once.
## std
### `function`
`core`'s `function`:
- **Converting where a `function` is expected,** so `val f: function<S> = functor;`
needs no `function::new`. The compiler would have to know the type by name, and the
conversion allocates where the callable doesn't fit.
- **`function::bound(&mut x, T::m)`,** binding a method to a value.
- **More held in place,** through a constant parameter for the buffer's size, for code
that must never allocate. Callables of 24 bytes or fewer are held in place now.
- **An allocator for the box,** once `box` takes one as the containers do.
- **Constants.** A constant keeps the buffer's words but not the function a function
value among them names, so `function::new` reaches its buffer through its address as a
number, which refuses every constant `function`. A functor that holds no function
value could be allowed.
- **C functions,** which `function` holds, but no test covers: the machine can't take a C
function's address.
### Threads
- **A pool of threads taking tasks, and a parallel `for`.** The compiler's own crew
(`compiler/workers.sakura`) could seed one.
- **Read-write locks, semaphores and barriers.** `std::thread` has a mutex, a condition,
a channel and `once`.
- **Waiting on several channels at once.**
- **Calling C from any thread, on Linux.** Threads started by `clone` keep the first
thread's `fs`, so libc's state for each thread, as malloc's caches and `errno`, is
shared. Five threads calling `malloc` and `free` 200,000 times each abort in glibc
every time, and nothing warns. Windows starts threads through `CreateThread` and is
fine.
- **Reentrant console locks.** A thread holding `io::output_locked()` that calls
`println` waits forever, even with no other thread.
- **A thread given a value and giving one.** `spawn_with` gives a `handle<void>`, so such
a thread needs a closure, and a loop variable must be moved in by hand. Merging
`spawn` and `spawn_with` into overloads waits on the checker inferring a closure's type
through overloads, which it doesn't: "No overload of `go` takes these arguments."
### Atomics and signals
- **The signals' waiting word as an `atomic<u64>`.** Handlers would set it, `dispatch`
would empty it with `exchange`, and the `take_signals` intrinsic would go.
- **Holding signals off for a stretch of code,** as a guard over `rt_sigprocmask`.
- **Timers:** `alarm`, and timers that repeat. `signal::alarm` exists, but nothing sets
one.
- **What a signal says of itself,** as who sent it or which child stopped. A handler is
given only the `signal`.
- **Real-time signals,** and rarer ones as SIGTTIN, SIGTTOU and SIGPROF.
- **Signals as a stream,** through `signalfd` or a pipe, so `poll` wakes for them.
`system::watch` and `system::watched` note a signal, but aren't a handle.
- **Chaining handlers:** `handle` giving back the handler it replaced.
### Processes
- **Waiting for whichever of several children stops first,** and capturing several at
once, for a build tool's jobs. Only `system::wait(-1, ...)` waits for any child.
- **`child::send(signal)`,** to ask a child to stop, and timeouts on `wait`. `child` has
only `kill`. `system::poll` takes a timeout, but `std::process` doesn't use it.
- **The error merged into the output in order,** as `2>&1`, and `io::file::duplicate`.
- **Overlapped reads on Windows,** in place of looking at each pipe with
`PeekNamedPipe` and sleeping up to 10 ms between looks.
- **Starting faster with `clone(CLONE_VM | CLONE_VFORK)`,** for a large program starting
many children.
- **Process groups and sessions,** and a child that outlives the program.
### Streams
- **Interpolation written straight into a stream,** without a `string` made for each
`$"..."`. A language change.
- **Adapters:** a tee, a writer that counts, a reader limited to a length, and
compression.
- **Reads that don't wait, timeouts, and polling several readers.** `system::poll` does
it for handles, but nothing in `std::io` does.
### Text
- **Vectors in more text functions.** `find_byte`, and so `index_of`, `contains`, `split`
and `read_line`, use vectors where they're held, as do `memset`, `memcpy`, `memcmp`
and the JSON reader. `strview::find`, `find_any`, `is_ascii`, `upper` and `lower`,
spans' `last_index_of` and `count_of`, and `std::serial`'s `is_utf8` read words only.
- **UTF-8 checked a word at a time past ASCII,** as simdutf does. `is_utf8` skips ASCII
by words, then checks each sequence a byte at a time.
- **Hexadecimal and base64,** encoded and decoded by words. std has neither.
- **Comparing text without regard to ASCII case,** through `lower` of each word.
- **`core::swar` lanes of 16 and 32 bits,** for UTF-16 and wider tables. It has bytes
only.
- **Left a byte at a time, on measurement:** trimming (0.76 to 0.93 times as fast by
words), and YAML's plain scalars (0.82 to 0.97).
### Reading the clock
On Linux, `std::time` reads the steady clock with a system call, about 211 ns in an
executable, where glibc reads it through the vDSO in 25 ns. Programs that time small work,
and the benchmarks plan, pay it on every read.
### Parsing numbers
`integer::parse::<T>` checks only the 64-bit limits, so a narrower `T` wraps:
`integer::parse::<u8>("300")` is 44, and `parse::<i8>("-200")` is 56. Positive values
stop at `i64`'s largest, so `std::args` reads a `u64` with a reader of its own
(`whole_of`, `signed_within` and `unsigned_within`).
### JSON, YAML and `std::serial`
- **Fixed arrays,** `T[n]`, aren't written or read by the walk, which refuses a type
holding one. A type holding one gives a form of its own.
- **The walk over trait references.** It's `encode<T>(value, out: &mut encoder)`, one
indirect call for each value, because a trait couldn't be a type argument then. That
works now (`feed<E>(out: E) where E: sink` given a `&mut sink`), so the walk could be
generic over its encoder.
- **Faster float printing,** as Ryu. About 45% of writing JSON, 0.46 s for a 4.3 MB
document, was the runtime's `put_float`, exact but working in big integers of 128
limbs. Every program printing floats pays it.
- **JSON Pointer,** as `doc.find("/params/position/line")`.
- **Trees that can be changed,** for JSON and YAML. Both are read-only arrays of 16-byte
nodes.
- **A field read as a `json::value`.** `json::value` is written but not read, so the
language server reads `method` first, then decodes `params`.
- **YAML:** comments kept when read and written again; a writer of comments, flow style
and anchors for repeated values; tags in typed values, as `!circle {radius: 1}`; and
keys that are collections, which `serial::encoder` can't write.
### Iterators
- **Splitting a sized iterator across threads.**
- **`chunks(n)` and `windows(n)` of a view,** giving views.
- **Iterators that write,** as `fill` and `copy_into`, which the algorithms plan has as
methods of slices.
### Math
- **`erf`, `gamma`, `lgamma`, and the Bessel functions.**
- **Correctly rounded versions,** from CORE-MATH, for programs that need results never
off by a rounding. MIT-licensed, but several times larger and slower than musl's.
### Time
- **`TZ`, and `TZDIR` beyond Windows,** read from the environment. On Linux, zones come
from `/usr/share/zoneinfo` and `/etc/localtime` only. `process::variable` exists, so
nothing blocks it.
- **Formats written with a pattern,** as `strftime`'s.
- **Windows zones by name, and the history of its local zone,** from the registry or
ICU. `zone::local()` there is the current rule only.
- **Leap seconds.** A day is 86,400 seconds, and a second of 60 is `out_of_range`.
### Arguments
- **`std::testing` reading its arguments through `std::args`.** `tester::run` compares
`--only` and `--here` by hand, since `std::args` would refuse the other arguments tests
are run with.
- **Environment variables as fallbacks,** as `@option{ env = "SAKURA_TARGET" }` for
`--target`. `process::variable` exists, so nothing blocks it.
- **Suggestions for a misspelled option:** "`--levle` is not an option; did you mean
`--level`?"
- **Shell completion scripts** written from the declarations.
- **Response files,** `@arguments.txt`, for lists longer than a system allows.
- **Help wrapped to the terminal's width.** It aligns its columns but never wraps.
- **The rest of the declarations checked while compiling.** The marks' shapes and types
are `compile_error`s, but duplicate names, duplicate short letters, which letters may
be short names, and `count` of an integer are checked as each run starts. Since
2026-10-28 a `compile_error` a running condition chooses is reported, so they could be
too.
### `core`
- **A `core` for places with no heap,** with the containers in a child of their own.
- **Lang items by attribute,** as `@lang("string")`, rather than by name in the module
`core`, so `core` could be split into modules of its own.
## blossom
- **The blossom plan's "Later, where wanted":** more `install` tags than `!include`, tags
for the build and test pipelines, versions resolved from ranges with a lock file,
`blossom new`, compiling in blossom's own process, and an index of packages by
`gpid/name`. Several blossomfiles built as one project came on 2026-11-14, as `members`;
several projects of their own names and versions, built together, are still later.
- **Not run here:** an rpm package, as there's no `rpmbuild`, though the spec it's built
from is written and the missing tool said; a Debian package with `dpkg`, which isn't here
either, though `ar` and `tar` read it back whole; and blossom on Windows, which was only
built and checked. Its tests of its commands run `git`, `sh` and `tar`, so they're
Linux's.
- **Building the compiler is checked by hand, not by a test.** A test would take
minutes.
- **zip files are stored, not compressed,** until std has deflate.
## Debugging information
- **No Windows debugger has read a PDB file.** Visual Studio or WinDbg, stopping in a
program built with `-g`, would show whether they take what LLVM's tools do.
- **What CodeView can't say of a variable:** a value known as a constant over a range,
which the DWARF gives, isn't named there; a part of a variable of several words held
in the frame isn't either; and a variable whose frame slot holds the address of its
object of the heap is shown as a pointer to it.
- **Every function's type is `void ()`** in the PDB file, as the DWARF gives none, and a
debugger can't call them anyway.
- **Names aren't qualified.** Two functions of one name in different modules, as two
`write_all`s, are told apart by their IDs, but a debugger finding one by name finds
both, as with the DWARF and the symbol tables.
- **Globals aren't described,** in the PDB file or the DWARF.
- **`binary::amd64`'s `absolute` meets `std::io`'s,** so a file importing both, as
`native/native.sakura` does, writes `amd64::absolute`.
## Tests not written
- **Writing to the program's own output once nothing reads it.** A test can't make its
own output a closed pipe. The machine stops with status 141, as it should.
- **A read from a real pipe interrupted by a signal.** `io::pipe::open()` exists, but
the test reads a stream made to look interrupted.
- **`function` holding a C function.** See [`function`](#function).
- **Windows, since `extern` and `system`.** Its sources and std's tests were checked for
`windows-x86_64`, and the compiler's import table matched the seed's. None of it was
run, and neither was the machine's test of `ucrtbase.dll`
(`tests/machine/machine.sakura`): there's no Windows or Wine here. Since `core` the
same holds, with `CreateDirectoryW` imported too, for the language server's copy of the
built-in text.
- **`--deps` from the compiler's own tests.** Only blossom's tests run `sakurac` with it,
through blossom.