Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ releases can be downloaded from [GitHub](https://github.com/burnlang/burn/releas

## Unreleased

- Local variables that only hold a parameter, another variable, or a field or element of one now borrow their value instead of counting a reference, when nothing can free it while they are used ([memory](./language/memory.mdx#what-the-compiler-does)). Loops over arrays of objects and strings and walks over linked structures no longer touch reference counts; the compiler's own code does 8.5% fewer of them and builds faster.
- The compiler rejects memory hazards that used to compile, each with a suggested fix ([memory](./language/memory.mdx#what-the-compiler-rejects)): adding to or removing from an array or map inside a `for` loop over it, using an array, map or object while an `async fun` it was given to may still be changing it, and async functions that change globals or read global arrays, maps and objects.

## 26.1.0-experimental-9
Expand Down
3 changes: 3 additions & 0 deletions content/language/memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ lets go, the object is freed, and so are the objects only it owned.
The compiler keeps the bookkeeping cheap:

- Passing a value to a function costs nothing: the caller keeps owning it, and the function borrows it.
- A local variable that only ever holds a parameter, another variable, or a field or element of one borrows its value
the same way, as long as nothing can free that value while the variable is used. `for p in points`, walking a
linked list with `cur = cur.next` and `var first = items[0]` count nothing.
- Returning a local variable hands it to the caller instead of copying.
- Numbers, bools and enums are not objects and are never counted.
- String literals are part of the program and are never freed.
Expand Down
Loading