← Back to Docs

@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 loop to disable the built-in loop protection.

Without @unsafe, any loop iteration that completes in under 2 seconds is blocked. With @unsafe, the loop runs with no speed checks.

Syntax

@unsafe while (condition) {
    // 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

ProtectionNormal while@unsafe while
Iteration speed check (< 2s)✓ Active✗ Disabled

Rules

  • @unsafe can only be placed directly before while
  • It cannot be used on other statements (if, fn, let, etc.)
  • Using @unsafe before anything other than while is a compile error