Design decisions

298. isqrt is std.math.isqrt, an ordinary body, not a compiler builtin (2026-11-22)

  • Decision. The call arm, the Int property arm and Builtin::Isqrt leave the compiler (checker tables, lowering, interpreter, codegen and the C++ runtime's cpl::isqrt). std.math.isqrt becomes @get pub fn isqrt(self: Int), so isqrt(n), n.isqrt and n.isqrt() all reach it; the prelude imports it. The body is the runtime's: a truncated sqrt corrected by multiplication, and the trap keeps its message, isqrt(-4) of a negative number.
  • Why. Decision 266: isqrt is derived, not a numeric primitive. Perf gate, 1e8 calls (g++ -O2): builtin 0.17-0.39 s, std body 0.17-0.18 s over 5 runs each. The first body (floor plus division) ran 0.31-0.46 s and was rewritten before landing.
  • Reverse. Revert the commit; the std body then stays as the reference the builtin is tested against.