@unsafe
⚠️ Warning
@unsafe disables safety protections. Only use it when you fully understand the consequences. An unprotected loop can freeze your program indefinitely.
What is @unsafe?
@unsafe is an annotation you place directly before a while, for, orfor-in loop to disable the built-in loop protection.
Without @unsafe, any loop iteration that takes more than 2 seconds is blocked. With @unsafe, the loop runs with no speed checks.
Syntax
@unsafe while (condition) {
// loop body — no speed protection
}
@unsafe for (let i = 0; i < n; i = i + 1) {
// loop body — no speed protection
}
@unsafe for (item in array) {
// loop body — no speed protection
}Example
class App {
fn fastCount(n) {
@unsafe while (n > 0) {
print("count:", n);
n = n - 1;
}
}
fastCount(1000);
}When to use @unsafe
- Tight computational loops (math, sorting, processing)
- Game loops that run at high frame rates
- Benchmarking or performance testing
- Any loop where you are certain it will terminate
When NOT to use @unsafe
- When you are unsure if the loop will terminate
- In production code where stability matters more than speed
- When learning VDX — let the safety system help you
What @unsafe disables
| Protection | Normal loop | @unsafe loop |
|---|---|---|
| Iteration speed check (< 2s) | ✓ Active | ✗ Disabled |
Rules
@unsafecan be placed directly beforewhile,for, orfor-inloops- It cannot be used on other statements (if, fn, let, etc.)
- Using
@unsafebefore anything other than a loop is a compile error