Skip to content

enhancement: self-host basic list access helpers in stdlib #57

Description

@vycdev2

Summary

Move the compositional list helpers list.is_empty, list.first, and list.last from hardcoded checker/interpreter cases into exported compiler-shipped .jett source while preserving their generic collection-view signatures, ownership behavior, and empty-list behavior. This is the first slice toward the required end state: every public list.* declaration is source-owned.

Source documentation

Target boundary

Every public list.* name and signature must ultimately be declared in compiler-shipped .jett source. Compositional helpers have real Jett bodies. Source declarations may delegate allocation, indexing, mutation, sorting, and callback execution to private trusted runtime kernels, but those kernels are implementation details rather than public compiler-owned APIs. The compiler must not retain hardcoded public list names or signatures as the final architecture; the current compiler-backed surface is transitional technical debt.

This issue is a bounded first extraction slice. Follow-up work remains required for every public list operation outside the three helpers, including public declarations that front foundational length and indexing kernels.

Intended source signatures

namespace list

export function is_empty[T](view items: list[T]) returns bool
export function first[T](view items: list[T]) returns optional[T]
export function last[T](view items: list[T]) returns optional[T]

The view items: list[T] parameter is part of the contract. The source bodies may compose over private/foundational length and indexing kernels during this slice: is_empty compares length with zero, first reads index zero, and last returns none for an empty list or reads length - 1.

Scope

Includes:

  • Add the three exported generic declarations and real Jett bodies under compiler-shipped namespace list source.
  • Remove only those three redundant public checker signatures and interpreter bodies.
  • Preserve generic inference, explicit type arguments, optional return values, empty-list behavior, and collection-view ownership.
  • Add regressions proving each helper can be called and the original list then reused successfully.
  • Add coverage proving normal builds and symbol/signature queries resolve the helpers from compiler-shipped list source.
  • Keep standard-library progress, design, and architecture documentation aligned with the complete source-owned target.

Explicitly excludes:

  • Migrating other public list operations in this slice.
  • Reimplementing allocation, indexing, mutation, sorting, callback execution, or other primitive runtime behavior in Jett.
  • Changing list ownership, optional semantics, generic inference, namespace/import rules, or the trusted stdlib-origin design tracked by design: define module imports and trusted stdlib origins #3.
  • HIR, MIR, native runtime, or code-generation work.

Acceptance criteria

  • Compiler-shipped stdlib source exports generic list.is_empty, list.first, and list.last with the exact collection-view signatures above and real Jett bodies.
  • Existing empty and non-empty behavior passes for inferred and explicit generic calls.
  • Ownership regressions call each helper and then successfully reuse the original list; cover first and last on empty and non-empty lists and both is_empty outcomes.
  • Compatibility with existing implicit collection-view calls remains intact where supported.
  • The three helpers no longer have hardcoded public signatures in jett_typecheck or Rust execution bodies in jett_comptime.
  • Length/indexing behavior used by the source bodies is exposed only through the transitional foundational boundary, with follow-up retained for source-owned public declarations.
  • Project and dependency code still cannot reopen the builtin list namespace.
  • A focused query or loader regression identifies compiler-shipped list source as the definition location for at least one migrated helper.
  • Documentation states that all public list.* declarations become source-owned and identifies private trusted kernels as implementation details.
  • cargo fmt --check, cargo build, and cargo test -q pass.

Dependencies / open questions

Coordinate builtin-type namespace handling with PR #56 so string and list use one narrow compiler-shipped rule rather than parallel special cases. This work must not broaden or resolve the module/import/trusted-origin policy in #3.

This was generated by an AI agent (vycdev2). Please verify any changes before merging or applying.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions