# AI Agent Notes ## Canonical AI References - Use `docs/ai_language_reference.md` as the primary, compiler-verified Lyng language reference for code generation. - For generics-heavy code generation, follow `docs/ai_language_reference.md` section `7.1 Generics Runtime Model and Bounds` and `7.2 Differences vs Java / Kotlin / Scala`. - Use `docs/ai_stdlib_reference.md` for default runtime/module APIs and stdlib surface. - Treat `LYNG_AI_SPEC.md` and older docs as secondary if they conflict with the two files above. - Prefer the shortest clear loop: use `for` for straightforward iteration/ranges; use `while` only when loop state/condition is irregular or changes in ways `for` cannot express cleanly. - In Lyng code, slice strings with range indexing (`text[a.. slot only on demand for Kotlin interop (no eager name mapping on every call). - Avoid PUSH_SCOPE/POP_SCOPE in bytecode for loops/functions unless dynamic name access or Kotlin reflection is requested. ## ABI proposal notes - Runtime generic metadata for generic extern classes is tracked in `proposals/extern_generic_runtime_abi.md`. - Keep this design `Obj`-centric: do not assume extern-class values are `ObjInstance`; collection must be enabled on `ObjClass`.