741 lines
40 KiB
Markdown
741 lines
40 KiB
Markdown
# Roadmap: one compiler, and a language that holds
|
||||
|
|
|
|||
|
|
Written 2026-10-20. The same day you chose the recommended answer to every decision at
|
|||
|
|
the end, and steps 1 to 6 were built. Steps 1 and 2 are commit `5a6de39`, 3 and 4
|
|||
|
|
`c61f9cd`, and 5 `f9d3a2b`. Step 6 isn't committed.
|
|||
|
|
|
|||
|
|
**What it is:** the way from today to a rebuild whose language stops changing under the
|
|||
|
|
programs written in it, and with it the end of the C compiler. Eight steps:
|
|||
|
|
1. `extern` and the `system` library (the ffi plan, built);
|
|||
|
|
2. `core`, and a std read as it's imported (the std plan, built);
|
|||
|
|
3. contracts in the language (the contracts plan, built);
|
|||
|
|
4. what the checks do (the checks plan, built);
|
|||
|
|
5. the rules the two compilers disagreed on, settled (built);
|
|||
|
|
6. properties as C# writes them, with `this` and `value` implied (built);
|
|||
|
|
7. lambdas that own what they use: the last change to the syntax;
|
|||
|
|
8. the freeze.
|
|||
|
|
|
|||
|
|
- **The C compiler gets only what it needs to build the rebuild,** as you said on
|
|||
|
|
2026-10-20. Decision 1 says whether that's nothing past today, or whatever each step's
|
|||
|
|
std needs until the freeze.
|
|||
|
|
- **Plans that only add come after the freeze:** [freestanding.md](freestanding.md), the
|
|||
|
|
library plans, [blossom.md](blossom.md) (built on 2026-10-24, at your asking), and the
|
|||
|
|
compilers' own speed (decision 5).
|
|||
|
|
- **Each step is a plan here,** except:
|
|||
|
|
- 5, 6 and 8, which are written out below;
|
|||
|
|
- 7, which gets its own plan once you've chosen a direction (decisions 2 and 3).
|
|||
|
|
|
|||
|
|
## What "stable" means
|
|||
|
|
|
|||
|
|
From the freeze on, a program the rebuild accepts:
|
|||
|
|
- is accepted by every later rebuild;
|
|||
|
|
- 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 today
|
|||
|
|
(probed).
|
|||
|
|
|
|||
|
|
Methods are the exception. `core` might later add a method to one of its own types with
|
|||
|
|
the same name as one a program declared on that type. Step 5 settles that the program's
|
|||
|
|
wins, as it does for names.
|
|||
|
|
|
|||
|
|
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.
|
|||
|
|
|
|||
|
|
That sorts everything open today:
|
|||
|
|
|
|||
|
|
| Before the freeze: it would break programs later | After, or whenever: it only adds |
|
|||
|
|
|---|---|
|
|||
|
|
| `@foreign`, `@link` and `std::sys` going (step 1) | freestanding.md: a target, attributes, `core::x86_64` |
|
|||
|
|
| Which names a file sees, `core`'s root, the types the syntax makes (step 2) | The library plans: algorithms, benchmarks, grammars, linear, logging, random, tui |
|
|||
|
|
| `std::contract` going, and what `ensures` does (step 3) | blossom.md |
|
|||
|
|
| What `x[k]` checks, zero values, and `raw_allocate` no longer clearing (step 4) | `type_of(f)::name()`, thread-locals, 128-bit integers, documentation as an intrinsic |
|
|||
|
|
| Three rules the rebuild gets wrong, two awaiting you, and which method wins (step 5) | Constants without a type, inferring through a reference, `==` of `maybe`, `equatable` for `void` |
|
|||
|
|
| `m is nothing` and `(&mut x) as u64` refused; `+=` in place (decision 7) | Rules the rebuild refuses that could be accepted (step 5) |
|
|||
|
|
| Properties with `this` and `value` implied, and the old forms refused (step 6) | A property of the type itself, marked, if one's wanted (decision 9) |
|
|||
|
|
| How a lambda owns, and whether every lambda has a type of its own (step 7) | Warnings: lambdas returned through a call, handles outliving, reading a moved local |
|
|||
|
|
| | `+` joining text, more operator traits, and the compilers' speed |
|
|||
|
|
|
|||
|
|
**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, since 2026-10-26;
|
|||
|
|
- 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.
|
|||
|
|
|
|||
|
|
## Where it stands
|
|||
|
|
|
|||
|
|
**Probed** on 2026-10-20, with the repository's `sakura-v1.0.0`, built from the working
|
|||
|
|
tree that morning:
|
|||
|
|
- **The language has 30 keywords.** The plans add one, `extern`, which nothing in std,
|
|||
|
|
the compiler, its tests or its tools uses as a name. Every other word they add means
|
|||
|
|
something only where it stands:
|
|||
|
|
- `expects`, `asserts`, `ensures` and `old`, from step 3. std has
|
|||
|
|
`contract::expects` and `contract::asserts` today.
|
|||
|
|
- `undefined`, from step 4. It has to stay that way, since the rebuild's checker
|
|||
|
|
names an error kind `ec::undefined`.
|
|||
|
|
- `none` as an `os`, from freestanding.md, inside a `when`.
|
|||
|
|
- **What each plan changes for programs:**
|
|||
|
|
|
|||
|
|
| Plan | The grammar | What else programs see |
|
|||
|
|
|---|---|---|
|
|||
|
|
| Step 1, ffi | `extern import`, `extern module ... when`. `@foreign` and `@link` go | `std::sys` is `system` |
|
|||
|
|
| Step 2, std | Nothing | Which names a file sees (decisions 4–6 and 8). The eight types the syntax makes, held by the compiler. A module's files found by its path (decision 3) |
|
|||
|
|
| Step 3, contracts | `expects`, `asserts`, `ensures` statements, `old(e)`, `r:` | `std::contract` goes |
|
|||
|
|
| Step 4, checks | `= undefined` | What `x[k]` checks (decision 1). Zero values (decision 4). `raw_allocate` stops clearing (decision 6) |
|
|||
|
|
| freestanding.md | Nothing: attributes and a target | `@interrupt`, `@align`, `@packed`, `core::x86_64`, `os == none` |
|
|||
|
|
| The seven library plans | Nothing: attributes std declares, and `keep` | std gains |
|
|||
|
|
| blossom.md | Nothing | A tool beside the compiler |
|
|||
|
|
|
|||
|
|
- **Lambdas:** there are about 340 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>`.
|
|||
|
|
`carrying<A>` stands in for a lambda that owns what it's given: it's how
|
|||
|
|
`spawn_with` works.
|
|||
|
|
- The compiler's own sources start threads with `spawn_with` three times.
|
|||
|
|
- 13 test files write a functor by hand.
|
|||
|
|
- **Properties:** there are 183, in std (115), the compiler's own sources (38) and the
|
|||
|
|
tests (30). Three are declared in traits.
|
|||
|
|
- All 184 getters are `get(&this)`.
|
|||
|
|
- All 15 setters are `set(&mut this, to)`. Four give `to` a type, always the
|
|||
|
|
property's own.
|
|||
|
|
- The only accessors that don't use `this` are one test's stub, `dot::width`.
|
|||
|
|
- No property belongs to a type rather than a value, since accessors must take
|
|||
|
|
`this`. What belongs to a type is one of 52 associated variables, as
|
|||
|
|
`val permissions::owner_read := 0o400;`.
|
|||
|
|
- **The rules the compilers disagree on:** inconsistencies.md's "Rules of the language"
|
|||
|
|
lists 15. The rebuild was wrong about 3 of them, and 2 waited on your decision. Step 5
|
|||
|
|
settled all of them.
|
|||
|
|
|
|||
|
|
## The steps
|
|||
|
|
|
|||
|
|
| # | Step | Size, rebuild only, from each plan | Two-step bootstrap |
|
|||
|
|
|---|---|---|---|
|
|||
|
|
| 0 | C's last build (decision 1) | None | — |
|
|||
|
|
| 1 | The ffi plan, all of it | About 300 lines; 4,100 moved | Yes. The attributes stay valid beside `extern` for one step (its decision 4) |
|
|||
|
|
| 2 | The std plan, phases 1 to 5 and 7 | About 700 lines; 10,000 moved | Yes, for phases 2 and 3 |
|
|||
|
|
| 3 | The contracts plan, all of it | About 400 lines | Yes, when std's `contract::` calls become statements |
|
|||
|
|
| 4 | The checks plan, all of it | Not estimated in the plan; about 1,200 lines as built | Yes, as `core` gains `checking()` and `raw_allocate_zeroed` |
|
|||
|
|
| 5 | The rules | Three fixes, a rule for methods, two decisions, three items from later.md; about 470 lines as built | None was needed: nothing std or the sources use was refused |
|
|||
|
|
| 6 | Properties | Small: the parser and checker give accessors their parameters, and a script rewrites the 183; about 150 lines as built | Yes: a first stage from copies whose accessors are written as before (later.md) |
|
|||
|
|
| 6½ | References and values, one rule | About 450 lines as built, and 130 places given `&` | Plain: today's sources build with `sakura-v1.0.0`, then with themselves |
|
|||
|
|
| 7 | Lambdas that own what they use | Its own plan | Yes, when std's `spawn` starts taking them |
|
|||
|
|
| 8 | The freeze | The README, a corpus, the bootstrap rule | — |
|
|||
|
|
|
|||
|
|
**Steps 1 to 6 are built, and so is the rule for references and values between 6 and 7.** The plans of steps 1 to 4 were deleted once built, as
|
|||
|
|
earlier plans were, and [later.md](later.md) holds what they left. Steps 5 and 6 have
|
|||
|
|
their "As built" below. later.md's "The repository's compiler" says how step 5's compiler, which
|
|||
|
|
`sakura-v1.0.0` is since it was rebuilt at 20:01, builds today's sources, and where the
|
|||
|
|
chain from the seed has a gap.
|
|||
|
|
|
|||
|
|
**The order:**
|
|||
|
|
- **The ffi plan comes first,** as each plan says.
|
|||
|
|
- **The std plan comes next.** Contracts fail through its `fault`, and every later step adds
|
|||
|
|
to the std it lays out.
|
|||
|
|
- **The checks plan follows the contracts plan.** Its decision 5 shrinks to the containers' faults
|
|||
|
|
once contracts are statements.
|
|||
|
|
- **Step 5 can run beside steps 2 to 4.** Its fixes are small, and only decisions 6 and
|
|||
|
|
7 hold it up.
|
|||
|
|
- **Step 6 can come any time after step 1.** It's small and mechanical, and only
|
|||
|
|
decisions 8 and 9 hold it up.
|
|||
|
|
- **Step 7 is last,** as you asked.
|
|||
|
|
|
|||
|
|
**The std plan's phase 6 is left until after the freeze.** That's the one moving
|
|||
|
|
`std::regex`, `std::uri`, `std::version` and the formats. It's std's business, and
|
|||
|
|
blossom fetches the packages.
|
|||
|
|
|
|||
|
|
### 0. The C compiler's last build (decision 1)
|
|||
|
|
|
|||
|
|
**Decided: (a), and done.** The seed is the rebuild's commit `420783d`, which your
|
|||
|
|
working tree matched when step 1 began. Checked on 2026-10-20:
|
|||
|
|
- C's working tree builds it;
|
|||
|
|
- that stage builds it again, and that one builds it a third time, the same to the byte.
|
|||
|
|
|
|||
|
|
C's working tree isn't committed, so commit it: the seed's builder should be a commit
|
|||
|
|
too.
|
|||
|
|
|
|||
|
|
**Under (a),** the seed is the last commit C builds.
|
|||
|
|
- From then on, each stage is built by the one before. A step that changes what std or
|
|||
|
|
the sources are written in leaves a commit that its successor is built from, as the
|
|||
|
|
bootstraps since 10-09 have.
|
|||
|
|
- `tools/bootstrap.sh` would walk that chain from C. Each link is a commit you make.
|
|||
|
|
Until it exists, the notes in later.md's "The repository's compiler" are the recipe.
|
|||
|
|
- The C repository stays as it is, with a README line saying what it builds.
|
|||
|
|
- Nothing more is mirrored into its std.
|
|||
|
|
|
|||
|
|
**Under (b),** C learns what the rebuild's own sources and the std they read use, on
|
|||
|
|
Linux, and nothing else. That means no optimizer, Windows, language-server or
|
|||
|
|
freestanding work:
|
|||
|
|
- step 1: `extern` sections, and `system`'s new paths in its table of intrinsics;
|
|||
|
|
- step 2: `core` found beside its executable, `core`'s names seen everywhere, the eight
|
|||
|
|
types, and the rules of decisions 4 to 6. That's most of the std plan's half for C, since
|
|||
|
|
the rebuild's sources read `core`;
|
|||
|
|
- step 3: the statements parsed and left out, as `--contracts off` does;
|
|||
|
|
- step 4: what std's code uses;
|
|||
|
|
- step 6: properties' new form;
|
|||
|
|
- step 7: lambdas that own, where std's `spawn` takes them.
|
|||
|
|
|
|||
|
|
The freeze's commit is then the seed.
|
|||
|
|
|
|||
|
|
### 5. The rules, settled
|
|||
|
|
|
|||
|
|
When C stops, the rebuild's behavior becomes the language unless it's changed here.
|
|||
|
|
inconsistencies.md's "Rules of the language":
|
|||
|
|
|
|||
|
|
| Rule | What the rebuild does | Settled as |
|
|||
|
|
|---|---|---|
|
|||
|
|
| Redeclaring in the same scope | Takes it | Decision 6 |
|
|||
|
|
| `&` of a union's owning field | Takes it | Decision 6 |
|
|||
|
|
| `&mut` of a union's field | Takes it | Decision 6 |
|
|||
|
|
| Returning an owning local into a union | Takes it, and closes it once | The rebuild's |
|
|||
|
|
| A function ending in `while true` | Refuses it | The rebuild's, for now. Accepting one with no `break` is an addition |
|
|||
|
|
| Type arguments given to overloads | Picks by the receiver | The rebuild's |
|
|||
|
|
| Inferring from a lambda through overloads | Refuses it | The rebuild's, for now. Accepting is an addition, and step 7 removes `spawn_with`, the reason it was wanted |
|
|||
|
|
| A range's type from where it goes | Takes the declared type | The rebuild's |
|
|||
|
|
| A float constant where `T: numeric` | Takes it | The rebuild's |
|
|||
|
|
| Comparing a `string` with a `strview` | Takes it, and answers wrong | **Fixed: refused,** as the README says |
|
|||
|
|
| A property of type `void` | Takes it | **Fixed: refused,** as it was meant to be |
|
|||
|
|
| A full path to a module not imported | Takes it | The rebuild's, by the std plan's decision 6 |
|
|||
|
|
| A generic type's own variables | Takes the declaration, and reads it wrong | **Fixed: the declaration refused.** Making it work is an addition |
|
|||
|
|
| A property as a value | Refuses it | The rebuild's. Accepting is an addition |
|
|||
|
|
| `cfn` as a key | Not hashable | The rebuild's. Making it hashable is an addition |
|
|||
|
|
|
|||
|
|
**A method a program declares on a type of `core`'s** wins over one `core` adds later
|
|||
|
|
with the same name. That makes adding methods an addition. It sits beside the std plan's
|
|||
|
|
decision 5, which says where such methods are seen.
|
|||
|
|
|
|||
|
|
**A library's child sees its root's names without an import,** as it does today. You
|
|||
|
|
decided this on 2026-10-20, the question the std plan had left open. Where the root's
|
|||
|
|
code isn't there, that must be an error that's easy to catch.
|
|||
|
|
|
|||
|
|
From later.md, decision 7 takes the items that would break programs if done later:
|
|||
|
|
- **`m is nothing` refused.** It's never true of a `maybe`, so any program writing it
|
|||
|
|
has a mistake.
|
|||
|
|
- **`(&mut x) as u64` refused.** An integer conversion of a reference written `&x` or
|
|||
|
|
`&mut x` gives the value, not the address. Converting to a pointer stays the way to
|
|||
|
|
the address.
|
|||
|
|
- **`+=` in place.** `x += y` calls the type's `add_assign`, where it has one, and is
|
|||
|
|
`x = x + y` otherwise. Done after the freeze, it would start calling a method that a
|
|||
|
|
program had named `add_assign` for its own reasons.
|
|||
|
|
|
|||
|
|
**Set aside for good:** references that are never moved. Refusing a `var` reference
|
|||
|
|
given another one would break programs walking a chain (later.md).
|
|||
|
|
|
|||
|
|
**As built,** on 2026-10-20, in the rebuild only:
|
|||
|
|
- **Refused, each with a note where it's written:**
|
|||
|
|
- **A name declared twice in one block,** including one an `is not` test names for the
|
|||
|
|
rest of the block. A parameter, a block within, a loop's body and a function within
|
|||
|
|
may still declare it again, as C has it. Each block keeps where its names begin
|
|||
|
|
(`checker::check_redeclared`).
|
|||
|
|
- **`&mut` of a union's field,** or of anything within one, and **`&`** where what it
|
|||
|
|
refers to closes (`checker::check_lends_field`). A C union's fields are lent as
|
|||
|
|
before, since it holds no tag.
|
|||
|
|
- **A property of type `void`,** and **a variable declared through a generic type.**
|
|||
|
|
- **`x is T` of a union where `T` is one of its fields' types,** as `m is nothing`. The
|
|||
|
|
note names the field. In generic code it's asked of the template, not of each
|
|||
|
|
instance.
|
|||
|
|
- **`&x as` a number, `bool` or enum.** A reference held in a variable still converts
|
|||
|
|
as its value.
|
|||
|
|
- **A `string` compared with a view,** either way round. A literal still compares with
|
|||
|
|
either.
|
|||
|
|
- **A member a program declares on `core`'s type** with a name `core` gives the type too
|
|||
|
|
is kept in a chain of its own (`decls.added`), and isn't a duplicate of `core`'s, even
|
|||
|
|
with the same parameters. Wherever it's seen, it's chosen. `core`'s overloads are tried
|
|||
|
|
only where none of the program's takes the arguments, for calls, operators and paths
|
|||
|
|
alike (`checker::overloads_for`). `core`'s own code never sees the program's, and a
|
|||
|
|
trait's conformance looks at both chains. A method and a property may share a name
|
|||
|
|
this way too. So may a type a program declares through `core`'s, as `type
|
|||
|
|
bool::storage = bit;` for a trait asking for one, which the corpus does, and a member
|
|||
|
|
or type `core` gives that name.
|
|||
|
|
- **`+=` in place:** ten names, `add_assign` to `shift_right_assign`. Where the target's
|
|||
|
|
type has one taking the value, the compound assignment calls it on the target, through
|
|||
|
|
a property or an element too, and writes nothing back. Through a property, `set` takes
|
|||
|
|
what `get` gave, changed. Elsewhere it's `x = x + y`, as before. One giving a value is
|
|||
|
|
refused. Nothing in std has one yet: `string`'s would
|
|||
|
|
come with joining text by `+` ([later.md](later.md#joining-text-with-)).
|
|||
|
|
- **A child module sees the names of those holding it,** as before. Where no file of one
|
|||
|
|
was read, as a library's root left out, "`helper` is not declared where it is used"
|
|||
|
|
goes on to say which module has no file.
|
|||
|
|
- **Almost nothing in the tree was refused:** std, the compiler, its tests and its tools
|
|||
|
|
check clean under every new rule, and one corpus program compared a `string` with a
|
|||
|
|
view, which now writes `view()`. So step 4's compiler builds step 5's sources, and no
|
|||
|
|
bootstrap step was needed.
|
|||
|
|
- **Measured:** the compiler checking itself on one core at 2.1 GHz takes 324 ms with
|
|||
|
|
step 4's checker and with step 5's alike.
|
|||
|
|
- **Checked:** the fixed point, and one built on one thread is the one built on eight;
|
|||
|
|
`sakura-v1.0.0` builds it in two steps; the unit tests, 266; the corpus, 144, in the
|
|||
|
|
VM, natively at `-O0` to `-O2`, with `run --checks` and built with `--checks`;
|
|||
|
|
`test/checked` and `test/memory`, 12 each; std's tests, 259, in the VM and natively,
|
|||
|
|
checked and not, and under `run --checks`. The compiler and std's tests build for
|
|||
|
|
Windows, where nothing was run.
|
|||
|
|
- **Tests:** seven checker tests, and a corpus program,
|
|||
|
|
`compound_assignments_change_in_place_where_a_type_can_1`, which grows a `string` in
|
|||
|
|
place through a property too.
|
|||
|
|
- **Found and fixed while building it:** `+=` in place through a property of a type
|
|||
|
|
that closes closed what `get` gave after `set` had taken it, a double free that
|
|||
|
|
`run --checks` and valgrind showed.
|
|||
|
|
|
|||
|
|
### 6. Properties, as C# writes them (decisions 8 and 9)
|
|||
|
|
|
|||
|
|
A getter always takes `&this`. A setter always takes `&mut this` and a value of the
|
|||
|
|
property's type. Nothing else is possible, so writing them out says nothing.
|
|||
|
|
|
|||
|
|
Today:
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
var rect::width: f32 {
|
|||
|
|
get(&this) { return this.w; }
|
|||
|
|
set(&mut this, to) { this.w = to; }
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
After:
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
var rect::width: f32 {
|
|||
|
|
get => this.w;
|
|||
|
|
set { this.w = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var rect::height: f32 {
|
|||
|
|
get => this.h;
|
|||
|
|
set => this.h = value;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
val rect::area: f32 { get => this.width * this.height; }
|
|||
|
|
|
|||
|
|
trait sized {
|
|||
|
|
val size: u64 { get; }
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
- **`get` has `this`, as `&this`.** **`set` has `this`, as `&mut this`, and `value`, of
|
|||
|
|
the property's type.** They're there whether the body uses them or not.
|
|||
|
|
- **An accessor has a body, `=> expression;`, or `;`,** `get` and `set` alike. The `;` is
|
|||
|
|
for a trait, as now. `=> expression` is how a lambda and a match arm already give one
|
|||
|
|
value. A setter's `set => this.h = value;` takes it too, as you asked on 2026-10-20,
|
|||
|
|
since assigning is an expression.
|
|||
|
|
- **`value` is a word only inside a `set`,** and acts as a parameter's name would.
|
|||
|
|
`result`'s field is untouched: with a parameter named `value`, `r is value(&p)` and a
|
|||
|
|
match's `value(n) =>` still work (probed).
|
|||
|
|
- **`pub get` and `pub set` keep their own visibility,** as now.
|
|||
|
|
- **The old forms, `get(&this)` and `set(&mut this, to)`,** are accepted beside the new
|
|||
|
|
for one bootstrap step, then refused (decision 8).
|
|||
|
|
- **No getter takes `&mut this`,** and none of the 184 does today. If one's wanted later,
|
|||
|
|
a written `get(&mut this)` would be an addition.
|
|||
|
|
- **Methods keep `&this` written.** A method may take `&this`, `&mut this` or neither,
|
|||
|
|
and the first two may overload each other, so there the receiver says something.
|
|||
|
|
|
|||
|
|
**A property that doesn't use `this`** (decision 9). You suggested that where neither
|
|||
|
|
accessor uses `this`, the property could also be reached through its type, as
|
|||
|
|
`rect::unit`, without being required to. The trouble is that what a property is to its
|
|||
|
|
callers would then hang on its bodies:
|
|||
|
|
- A getter that starts using `this`, say to read a field, would take `rect::unit` away
|
|||
|
|
from every caller reaching it that way. That's an edit inside a body breaking
|
|||
|
|
programs, which the freeze promise rules out.
|
|||
|
|
- A trait's `{ get; }` has no body to look at.
|
|||
|
|
- The language server would have to read bodies to offer `rect::` completions.
|
|||
|
|
|
|||
|
|
Nothing needs it yet: nothing in the tree is a property of a type, and its associated
|
|||
|
|
variables, trait constants and static functions do that job. So the recommendation is
|
|||
|
|
that a property always belongs to a value.
|
|||
|
|
|
|||
|
|
If a type's own property is wanted, it's better said in the declaration, the way a
|
|||
|
|
method without `&this` is static. For example, `get()` with an empty list takes nothing,
|
|||
|
|
so it's the type's. That can come after the freeze as an addition, or now.
|
|||
|
|
|
|||
|
|
**As built,** on 2026-10-20, in the rebuild only, with decisions 8(a) and 9(a):
|
|||
|
|
- **`get` and `set` take nothing in parentheses.** The body is a block, `=> expression;`,
|
|||
|
|
or `;` in a trait. `=>` gives what a `get` returns, and is what a `set` does, as `set =>
|
|||
|
|
this.w = value;`. The parser makes it a block holding that `return` or statement, as
|
|||
|
|
it does for `return x if c;`, so nothing after it changed.
|
|||
|
|
- **The parameters are implied:** the parser makes `this` and a `set`'s `value` itself,
|
|||
|
|
marked `implied`, with the `get` or `set` for their token, since a name comes from a
|
|||
|
|
token. `checker::param_name` gives their names where they're bound, in debugging
|
|||
|
|
information and in reflection. The language server's `local_text` gives them where it
|
|||
|
|
shows a local: hover gives `value: int` and `this: &r`, completion offers both, and
|
|||
|
|
renaming refuses both. The `get` or `set` itself is never taken for them.
|
|||
|
|
- **`value` is a word only inside a `set`.** Elsewhere it's an ordinary name, and a
|
|||
|
|
`result`'s field keeps it.
|
|||
|
|
- **The written form is refused,** with a note at its `(` showing the form now, as "A
|
|||
|
|
`set` takes no parameters written: it has `this`, and `value` of the property's type,
|
|||
|
|
as `set => this.w = value;` or `set { this.w = value; }`." It's still read, so what
|
|||
|
|
follows it is checked as it means.
|
|||
|
|
- **Rewritten by a script,** in 64 files of `core`, std, the sources, the tests and the
|
|||
|
|
corpus: 192 getters, 163 of them to `=>`, 25 blocks and 4 `get;`, and 18 setters, 14
|
|||
|
|
to `=>`, 2 blocks and 2 `set;`, with `to` renamed `value`. Nothing needed rewriting by
|
|||
|
|
hand.
|
|||
|
|
- **The decision 8 step was done another way.** Rather than one compiler accepting both
|
|||
|
|
forms, the bootstrap writes copies back to the old form for the first stage, so the
|
|||
|
|
compiler refuses the old form from the start. later.md's "The repository's compiler"
|
|||
|
|
has the recipe from `sakura-v1.0.0`, checked to reach the fixed point.
|
|||
|
|
- **No getter takes `&mut this`,** and decision 9 leaves every property a value's.
|
|||
|
|
- **Measured:** checking the compiler takes 324 ms with step 5's checker on its form of
|
|||
|
|
the sources and with step 6's on theirs.
|
|||
|
|
- **Checked:** the fixed point, one thread or eight alike; the unit tests, 268; the
|
|||
|
|
corpus, 144, in the VM, natively at `-O0` to `-O2`, with `run --checks` and built with
|
|||
|
|
`--checks`; `test/checked` and `test/memory`, 12 each; std's tests, 259, everywhere.
|
|||
|
|
The compiler and std's tests build for Windows, where nothing was run.
|
|||
|
|
- **Tests:** a parser test of both forms of body and of the written form refused, a
|
|||
|
|
checker test of `this`, `value` and their types, and a language server test of hover
|
|||
|
|
and renaming.
|
|||
|
|
|
|||
|
|
### 6½. References and values, one rule (asked on 2026-10-21)
|
|||
|
|
|
|||
|
|
Copies and moves followed one rule already: a value that closes is never copied
|
|||
|
|
implicitly. References followed two. They were read through, and taken at a call
|
|||
|
|
without `&`, as in C++, but they were also types that stacked (`&&T`), were inferred
|
|||
|
|
for `T`, were pointed elsewhere by `r = s`, and were carried along by `:=`, as in Rust.
|
|||
|
|
So `val e := v[0]` referred to the element while `val e := a[0]` of a fixed array and
|
|||
|
|
`val y := v[0].x` copied, `max(v[0], v[1])` gave a reference into `v`, and a function
|
|||
|
|
taking `&T` wasn't accepted where one taking `T`, `&mut T` or `&&T` was asked.
|
|||
|
|
|
|||
|
|
**The rule:** where a value goes says what happens to it. A reference type lends it,
|
|||
|
|
and any other type gives it: a new value moves, a place is copied where it closes
|
|||
|
|
nothing, and one that closes is refused. Only `&` or `&mut` written, or a reference
|
|||
|
|
parameter at a call, makes a reference.
|
|||
|
|
|
|||
|
|
1. **Giving:** `:=`, a `T` parameter, a field, an element, `return`, `=`, `is some(v)`,
|
|||
|
|
`for x in`, and what a lambda's `=>` gives.
|
|||
|
|
2. **Lending:** a `&T` or `&mut T` parameter, result or field, `val r := &x`,
|
|||
|
|
`is some(&v)`, `for &x in`. `&mut` needs what can be written, or what `&mut` reaches.
|
|||
|
|
3. **References never stack:** `&` of a reference is that reference.
|
|||
|
|
4. **Inference sees values:** a `T` parameter given `v[0]` takes an `i64`, and `f(&x)`
|
|||
|
|
a reference.
|
|||
|
|
5. **Assigning writes through:** `r = s` writes what `s` reaches; `r = &y` points `r`
|
|||
|
|
at `y`.
|
|||
|
|
6. **Function values are called as the type asks:** a named function given where a
|
|||
|
|
function type it doesn't match is expected is called by a function made for it,
|
|||
|
|
as a call would call it: defaults filled, arguments lent or read through, the
|
|||
|
|
overload a call chooses.
|
|||
|
|
|
|||
|
|
Asked on 2026-10-22, with it: a reference written as one is a pointer where one is
|
|||
|
|
expected, and `core` has `address(x)`, `*mut T` or `*T`, beside `through(p)`.
|
|||
|
|
|
|||
|
|
**As built,** on 2026-10-22, in the rebuild only:
|
|||
|
|
- **One decision per node.** Each place a reference is taken as its value, or `&` of
|
|||
|
|
a reference is that reference, notes it on the node (`rf::valued`, `rf::relent`).
|
|||
|
|
An instance takes the template's decision, so where `T` is a reference, a `T` is
|
|||
|
|
still the value the template meant: `vector<&T>::append` stores the reference, and
|
|||
|
|
`move(&mut x)` of a `T` moves it. Collapsing `&&T` in the types themselves broke
|
|||
|
|
exactly this, and was dropped.
|
|||
|
|
- **A reference to a trait** is taken as it is wherever a value would be, since no
|
|||
|
|
value is of a trait. Refusing it instead would have changed every
|
|||
|
|
`some(held)` of a `maybe<&mut allocator>`.
|
|||
|
|
- **Adapters** are functions the emitter makes for each place a function is named
|
|||
|
|
so: `function_value` gives one where the checker marks the node `rf::adapted`.
|
|||
|
|
`call_site()` in a default is where the function is named.
|
|||
|
|
- **Overloads:** a writable argument is better lent to a `&mut` parameter than a `&`
|
|||
|
|
one, as receivers already were, so `address(x)` of a `var` gives a `*mut`.
|
|||
|
|
- **Found by the change:** `dict`'s key and value cursors returned `&entry.key` of a
|
|||
|
|
copy once `is some(entry)` copied, which `run --checks` stopped at; they name the
|
|||
|
|
entry with `&` now. Temporary warnings listed every `var` that had held a reference,
|
|||
|
|
every assignment that had pointed one elsewhere, and every `&` of a copy, and each
|
|||
|
|
was read.
|
|||
|
|
- **Rewritten:** 120 bindings and patterns in the sources, `core`, std and the tests
|
|||
|
|
gained `&` or `&mut`, as `val syntax := &this.units[file].syntax;`, and 12 loops
|
|||
|
|
became `for &x`. The compiler errors named each of them.
|
|||
|
|
`integer::parse` and `real::parse` could take `strview` again, which is yours to
|
|||
|
|
change back.
|
|||
|
|
- **Measured:** checking the compiler takes 0.35 s, and building it at `-O2` 3.4 s,
|
|||
|
|
with the compiler from before and with this one. Built under the rule, the
|
|||
|
|
compiler is 13 KB larger, 0.15%, from the copies its bindings make now.
|
|||
|
|
- **Checked:** the two steps from `sakura-v1.0.0` to the fixed point; the unit tests,
|
|||
|
|
271, but for gdb's, which failed the same way before; the corpus, 148, in the VM,
|
|||
|
|
natively at `-O0` to `-O2`, with `run --checks` and built with `--checks`;
|
|||
|
|
`test/checked` and `test/memory`, 12 each; std's tests, 259, everywhere. The
|
|||
|
|
compiler and std's tests build for Windows, where nothing was run.
|
|||
|
|
- **Tests:** two checker tests, of the rule and of the functions called as a type
|
|||
|
|
asks, and two corpus programs, `references_are_lent_and_values_given_1` and
|
|||
|
|
`named_functions_are_called_as_the_type_asks_1`. Seven tests written for the old
|
|||
|
|
rule now say the new one, as `indexing_gives_the_reference_at_gives_1`.
|
|||
|
|
|
|||
|
|
What it left is in [later.md](later.md#references-and-values-what-the-rule-left).
|
|||
|
|
|
|||
|
|
### 7. Lambdas that own what they use (decisions 2 and 3)
|
|||
|
|
|
|||
|
|
**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`:
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
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)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
**Already turned down, on 2026-10-19:**
|
|||
|
|
- a list in brackets, as C++ has, either of initializers (`[count = 0]`) or of words
|
|||
|
|
(`[move log, level]`);
|
|||
|
|
- `move def`, as Rust has.
|
|||
|
|
|
|||
|
|
**What any direction 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` and only one compiler
|
|||
|
|
has to know it.
|
|||
|
|
- **`spawn` takes anything `invokable`.** `spawn_with` and `carrying` go.
|
|||
|
|
- **A lambda that refers to locals keeps today's rules,** and today's warnings.
|
|||
|
|
|
|||
|
|
**The directions** (decision 2):
|
|||
|
|
|
|||
|
|
**(a) 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.
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
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
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
```ebnf
|
|||
|
|
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.
|
|||
|
|
|
|||
|
|
**(b) Values bound by std, with no syntax.** `bind(f, values...)` gives a functor that
|
|||
|
|
holds the values and passes them by `&mut`, ahead of the call's arguments: `spawn_with`
|
|||
|
|
for any lambda.
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
return function::new(bind(def(count: &mut i64): i64 { count++; return count; }, 0));
|
|||
|
|
thread::spawn(bind(def(lines: &mut vector<string>) { write_all(lines); }, move(&mut lines)));
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
The language doesn't change at all. The lambda's parameter types are written, as they
|
|||
|
|
are for `spawn_with` today. It could be built as well as (a), or before it.
|
|||
|
|
|
|||
|
|
**(c) Declared in the body, with a word saying they're made with the lambda:**
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
return def(): i64 {
|
|||
|
|
own var count := 0;
|
|||
|
|
count++; return count;
|
|||
|
|
};
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
It reads like the body, but it runs at a different time than the lines under it.
|
|||
|
|
`own` would mean something only before `val` or `var`, since std uses it as a name.
|
|||
|
|
|
|||
|
|
**(d) Functors, as now.**
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. It's the smallest change to the language: one rule on a list
|
|||
|
|
every lambda already has, in words the language already uses.
|
|||
|
|
|
|||
|
|
**Which lambdas get a type of their own** (decision 3):
|
|||
|
|
- Under every direction, a lambda that owns needs one.
|
|||
|
|
- Giving one to every lambda would let generic code take each lambda as its own type, so
|
|||
|
|
a lambda would cost what a functor does:
|
|||
|
|
- the adapters, which cost 4 to 9 times functors today (later.md, "Lambdas given to
|
|||
|
|
adapters");
|
|||
|
|
- a sort's order, which no optimization reaches otherwise (algorithms.md,
|
|||
|
|
decision 4).
|
|||
|
|
|
|||
|
|
A lambda would still convert to a function type wherever one is expected. What it
|
|||
|
|
refuses is two lambdas given to one variable that isn't declared with a function type:
|
|||
|
|
|
|||
|
|
```sakura
|
|||
|
|
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
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
Each place in the tree that gives a lambda to a variable already declares a function
|
|||
|
|
type (probed), so nothing in the tree is refused. It changes what programs mean, so it's
|
|||
|
|
now or never.
|
|||
|
|
|
|||
|
|
**Its own plan,** written once steps 5 and 6 are done, measures and builds the
|
|||
|
|
direction you choose.
|
|||
|
|
|
|||
|
|
### 8. The freeze (decision 4)
|
|||
|
|
|
|||
|
|
- **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 `test/programs` uses yet, each with its `.out`. A change that breaks one fails a
|
|||
|
|
test.
|
|||
|
|
- **inconsistencies.md goes.** Its rules are settled by step 5. Its VMs and code
|
|||
|
|
generation are C's, which decision 1 retires.
|
|||
|
|
- **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;
|
|||
|
|
- so the chain from C stops growing at the freeze.
|
|||
|
|
- **std is found as `core` is,** and `--std` and `SAKURA_STD` go. Built on 2026-10-26,
|
|||
|
|
as the README says: `--lib std=DIR`,
|
|||
|
|
else beside or above the compiler, else where `blossom install` puts it. There's one compiler by then, under
|
|||
|
|
either answer to decision 1.
|
|||
|
|
|
|||
|
|
## What this changes in the other plans
|
|||
|
|
|
|||
|
|
- **Each plan's phases say "in both compilers".** Each plan now says, beside its
|
|||
|
|
ffi line, that it's built in the rebuild alone.
|
|||
|
|
- **The bootstrapping lines change.** The std and contracts plans said "C builds the
|
|||
|
|
rebuild directly throughout". Under 1(a), the chain did that.
|
|||
|
|
- **The plans that only add** wait for the freeze (decision 5). Their "Comes after the
|
|||
|
|
ffi plan" lines still hold.
|
|||
|
|
- **inconsistencies.md:** its "What runs while compiling", "The VMs" and "The code each
|
|||
|
|
makes" stop mattering under 1(a). Only its rules are left, for step 5.
|
|||
|
|
|
|||
|
|
## Found along the way
|
|||
|
|
|
|||
|
|
- **A program's own type named as a built-in hides it.** `struct u32 { var lo: u64; }`
|
|||
|
|
builds and runs. So a built-in type, such as `i128`, can come after the freeze.
|
|||
|
|
- **`undefined` is a name in the rebuild,** `ec::undefined`, so the checks plan's
|
|||
|
|
`= undefined` must be a word only where it stands.
|
|||
|
|
- **A parameter named `value` hides nothing a setter needs.** `r is value(&p)` and a
|
|||
|
|
match's `value(n) =>` on a `result` still work beside it, so `set`'s implied `value`
|
|||
|
|
can be a plain name.
|
|||
|
|
- **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>`;
|
|||
|
|
- a `val maybe: def(): int` chosen by `?:`.
|
|||
|
|
|
|||
|
|
No array holds lambdas. So decision 3(a) refuses nothing in the tree.
|
|||
|
|
- **The built-in types are read as `module core`,** and a program with no `module` line
|
|||
|
|
is module 0, which holds every module. So a program's member on a built-in type was
|
|||
|
|
"seen" from `core`'s own code too, which step 5 had to keep to `core`'s own members.
|
|||
|
|
- **The comparison of a `string` with a view had answered right since the std plan,** by
|
|||
|
|
making a `string` of the view, which allocates. Step 5 refuses it all the same.
|
|||
|
|
- **A program's method named as a property of `core`'s,** as `string::is_empty`, was a
|
|||
|
|
duplicate reported at `core`'s line, before step 5.
|
|||
|
|
|
|||
|
|
## Decisions for you
|
|||
|
|
|
|||
|
|
**Decided 2026-10-20:** the recommended answer to each.
|
|||
|
|
|
|||
|
|
1. **Where the C compiler stops:**
|
|||
|
|
- **(a) At a seed today:** your next commit of the working tree. It's the last commit
|
|||
|
|
C builds, and the rebuild builds each one after it.
|
|||
|
|
- **(b) At the freeze,** learning until then what the rebuild's own sources and the
|
|||
|
|
std they read use, on Linux.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**.
|
|||
|
|
- It saves the C half of every step: about 300 lines for the ffi plan, 700 for the std
|
|||
|
|
plan, 400 for the contracts plan, and keeping C's std in step with the rebuild's.
|
|||
|
|
- What's lost is the corpus run under two compilers, which found most of
|
|||
|
|
inconsistencies.md. The `.out` files still hold every answer.
|
|||
|
|
- Two-step bootstraps are what each change since 10-09 has needed anyway.
|
|||
|
|
2. **How a lambda owns what it uses:**
|
|||
|
|
- **(a) `val` and `var` parameters, made where the lambda is written.**
|
|||
|
|
- **(b) std's `bind`,** with no syntax.
|
|||
|
|
- **(c) `own val` and `own var` in the body.**
|
|||
|
|
- **(d) Functors, as now.**
|
|||
|
|
|
|||
|
|
Recommended: **(a)**, with (b) worth building beside it if a library wants it.
|
|||
|
|
3. **Which lambdas have a type of their own:**
|
|||
|
|
- **(a) Every lambda,** converting to a function type where one is expected.
|
|||
|
|
- **(b) Only those holding values of their own.**
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Owning lambdas need the machinery anyway, and it makes every
|
|||
|
|
lambda cost what a functor does. What it refuses doesn't occur in the tree, and it's
|
|||
|
|
now or never. The cost is an instance of generic code for each lambda given to it,
|
|||
|
|
which step 7's plan would measure.
|
|||
|
|
4. **What the freeze promises:**
|
|||
|
|
- **(a) Additions only, from then on.** A program accepted keeps being accepted and
|
|||
|
|
keeps its meaning. New words mean something only where they stand.
|
|||
|
|
- **(b) Editions:** (a) within an edition, while a new edition may change things. A
|
|||
|
|
file or blossomfile names its edition, so old programs build as they did.
|
|||
|
|
- **(c) Nothing until a 1.0 tag.** The freeze is a candidate, and changes stay
|
|||
|
|
possible while you write programs in it.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Editions can come later without breaking it, since a file that
|
|||
|
|
names none would be of the first.
|
|||
|
|
5. **When the plans that only add are built:**
|
|||
|
|
- **(a) After the freeze.** They're then written against the language as it stays.
|
|||
|
|
- **(b) freestanding.md before the freeze, and the rest after.** It's what you want
|
|||
|
|
the language for, and it changes nothing that's there.
|
|||
|
|
- **(c) Whenever wanted,** once the std plan is built.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Each one built first puts the freeze further off, and none of
|
|||
|
|
them needs it to wait.
|
|||
|
|
6. **Rules the rebuild accepts that C refused,** where refusing is the safer side:
|
|||
|
|
- **(a) Refuse them, as C does:**
|
|||
|
|
- `val x` declared twice in one scope;
|
|||
|
|
- `&` and `&mut` of a union's field, which lend the field without asking which
|
|||
|
|
field the union holds.
|
|||
|
|
|
|||
|
|
`is value(&p)` and `is some(&mut q)` stay the way in. Accepting either later is an
|
|||
|
|
addition.
|
|||
|
|
- **(b) Keep the rebuild's:** names redeclared in the same scope, as Rust has it,
|
|||
|
|
and a union's field lent as it is.
|
|||
|
|
- **(c) Split:** redeclaring kept, the union's fields refused.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Step 5 counts the places std and the sources use them, and
|
|||
|
|
changes them.
|
|||
|
|
7. **later.md's items that would break programs if done later:**
|
|||
|
|
- **(a) All three before the freeze:**
|
|||
|
|
- `m is nothing` refused;
|
|||
|
|
- `(&mut x) as u64` refused;
|
|||
|
|
- `+=` calling `add_assign` where a type has one.
|
|||
|
|
- **(b) The two refusals only.** `+=` stays `x = x + y` for good.
|
|||
|
|
- **(c) None.**
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Otherwise `+=` on a `string`, or on anything else that owns
|
|||
|
|
memory, allocates every time, and building text with `+=` is common.
|
|||
|
|
8. **How accessors are written:**
|
|||
|
|
- **(a) `get` and `set` with nothing in parentheses,** and a body, `=> expression;`
|
|||
|
|
or `;`. The old forms are accepted for one bootstrap step, then refused.
|
|||
|
|
- **(b) The same, with the old forms kept** as a longer spelling.
|
|||
|
|
- **(c) Without `=>`:** bodies and `;` only.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. There's one way to write it, and `=>` is how the language
|
|||
|
|
already writes a body that gives one value.
|
|||
|
|
9. **A property that doesn't use `this`:**
|
|||
|
|
- **(a) It still belongs to a value.** What belongs to a type is an associated
|
|||
|
|
variable, a trait's constant, or a static function. A marked form, as (c), can be
|
|||
|
|
added after the freeze.
|
|||
|
|
- **(b) Inferred, as you suggested:** where no accessor uses `this`, it may be
|
|||
|
|
reached through its type as well.
|
|||
|
|
- **(c) Marked now:** `get()`, with an empty list, takes nothing, so the property is
|
|||
|
|
its type's, reached as `rect::unit`.
|
|||
|
|
|
|||
|
|
Recommended: **(a)**. Under (b), an edit inside a body could break callers, and a
|
|||
|
|
trait's property has no body to tell by. Nothing in the tree needs a type's property
|
|||
|
|
yet, and (c) stays open.
|