shape-runtime 0.2.0

Bytecode compiler, builtins, and runtime infrastructure for Shape
Documentation
/// @module std::core::len
/// `Len` — uniform length interface for collection-like types.
///
/// Any type that exposes a zero-argument `len()` method returning `int`
/// satisfies the structural contract of `Len`. Dispatch today goes through
/// per-type PHF method tables (see `shape-runtime::method_registry`), so the
/// canonical call form is `value.len()`.
///
/// This module carries the trait definition plus explicit implementations for
/// built-in length-bearing types. Future work: auto-derive `impl Len for T`
/// for any `T` whose method registry contains an exact-signature
/// `len() -> int`, enabling generic bounds `fn f<T: Len>(x: T) -> int`
/// without hand-written impls.
///
/// ## Known Implementations
///
/// | Type           | Dispatch source                              |
/// |----------------|----------------------------------------------|
/// | Array<T>       | built-in PHF (array_basic, array_ops)        |
/// | String         | built-in PHF (string_methods)                |
/// | HashMap<K,V>   | built-in PHF (hashmap_methods)               |
/// | Set<T>         | std/core/set.shape                           |
/// | TypedArray<T>  | built-in PHF (typed_access.rs)               |

/// Uniform length interface for collection-like types.
///
/// Every length-bearing built-in satisfies this contract via method dispatch
/// on `.len()`. The declared signature intentionally returns `int` (not
/// `number`) to match the zero-tag typed-opcode path (`ArrayLenTyped`,
/// `MapLenTyped`).
trait Len {
    /// Return the number of elements (or bytes, for strings).
    len(): int
}