# What changed in 0.12.2

> Explicit contracts (pure, safe, par, own and borrow parameters, scope), rules and proofs, shared objects, faster interop, alice explain, the guide and AI-agent files.

Canonical: https://alice-lang.org/documentation/reference/whats-new-0-12-2/

[Documentation index](https://alice-lang.org/documentation/llms.txt) · [Complete book](https://alice-lang.org/llms-full.txt)

Alice 0.12.2 keeps inference as the default and adds keywords for when you want a guarantee: you state what you
want, and the compiler proves it or stops with an error. It also adds proofs over finite domains, the guide
for people and AI agents, and faster object, interop and start-up paths. Nothing breaks for 0.12 code. The
full list is in the [changelog](https://github.com/alicelanguage/alice/blob/main/CHANGELOG.md).

## Explicit contracts

| Syntax                        | Meaning                                                                                   | Error          |
| ----------------------------- | ----------------------------------------------------------------------------------------- | -------------- |
| `pure def f ...`              | `f` has no effects (no I/O, no writes to state it did not allocate)                       | AL0210         |
| `safe def f ...`              | `f` and everything it calls cannot reach files, network, processes, reflection or interop | AL0212         |
| `inline def f ...`            | ask the JIT to inline `f`                                                                 | -              |
| `par a, b = f(x), g(y)`       | always fork the two calls (Bend's parallel let)                                           | AL0211         |
| `def f(own xs : Array(T))`    | the caller moves its array into `f`                                                       | AL0207, AL0208 |
| `def f(borrow xs : Array(T))` | `f` never keeps `xs`                                                                      | AL0213         |
| `scope ... end`               | a lifetime region: arrays created inside are released at `end`                            | AL0207         |

```alice
def scale(own xs : Array(Float64), k : Float64) : Array(Float64)
  xs = xs.map { |v| v * k }   # owned: overwritten in place, no new array
  xs
end
```

When each one is worth using is covered in [rules and proofs](https://alice-lang.org/documentation/guides/rules-and-proofs.md) and in
`alice guide performance`.

## Rules and proofs

`RULES.al` holds `rule` declarations over finite domains; `alice prove` checks every case and writes
`PROOF.al`. See [rules and proofs](https://alice-lang.org/documentation/guides/rules-and-proofs.md).

## Faster without changes

- `fib(n - 1) + fib(n - 2)` forks directly (two independent calls in one expression).
- An array a function returns is recycled by its caller. In the GC benchmark, a scratch-buffer workload went
  from 3.8 MiB per run to under 400 bytes and 0 collections.
- Immutable objects built from constants are shared. A binary-tree workload allocates half as much as C#
  and runs about 1.35x faster.
- C functions over numbers and `Bool` are called without marshalling: a `Bool` call is 2.7x faster.
- `alice run` caches the compiled program: an unchanged file starts in about 0.1 s instead of 1.2 s.

## Tools

| Command                  | Purpose                                              |
| ------------------------ | ---------------------------------------------------- |
| `alice explain file.al`  | which optimizations each method received             |
| `alice prove [--check]`  | prove `RULES.al`, write or verify `PROOF.al`         |
| `alice guide [topic]`    | the guide; topics `performance`, `proofs`, `interop` |
| `alice agents [--write]` | the Alice block for a project's `AGENTS.md`          |

`alice new` now writes `AGENTS.md` and a `CLAUDE.md` that imports it. See
[AI agents and the guide](https://alice-lang.org/documentation/tools/ai-agents.md).

## Continue reading

- Previous: [Syntax quick reference](https://alice-lang.org/documentation/reference/syntax.md)
- Next: [What changed in 0.12](https://alice-lang.org/documentation/reference/whats-new-0-12.md)
