Allocations

This commit is contained in:
2026-06-10 03:04:20 +02:00
parent dcc1709d9e
commit b46ae6f6e9
2 changed files with 25 additions and 0 deletions
@@ -40,6 +40,17 @@ pub struct Inspector<'a> {
}
```
## Allocations
In classes, it's very important to initialize heap allocated fields in `constructor` using `path -> expr`, here is the most common example:
```mist
pub class Dog : Animal {
constructor() {
super -> Super::new();
}
}
```
This outputs `std::ptr::write` which is a force write to memory without dropping what "exists", and it's commonly used in uninitialized memory, such as uninitialized dynamic fields.
## Key Characteristics
- **Prefix Pointer Syntax**: `*Type` for shared references, `*mut Type` for mutable references.