nish:compact

The marker interfaces that pick a class's layout (WP48). class R implements Compact stores every field typed exactly R or R | null, in any class, as a 32-bit offset into one reserved address range, so a tree or list node of an i32 and two links is 12 bytes, not 24. Locals, parameters, returns, arrays, maps and other unions stay full pointers.

import {
  Compact,
  Wide,
} from "nish:compact";

The compiler refuses a compact class where C or Node would see its layout: a build with --emit-header, --emit-napi or --emit-napi-async, a declare class, a class holding a Secret, and a class a C or N-API surface exports. wasm32, a host --emit-dts page module and an ASAN build compile it uncompressed: a pointer there is already 4 bytes, the page runs on the wasm runtime, or the range cannot hold the sanitizer's blocks.

Under Node

runtime/nish.mjs answers the import with runtime/core.mjs, where both names are empty values: a reference is the engine's own and the marker changes nothing a program prints.

Rules: https://github.com/amritk/nish/blob/main/docs/LANGUAGE.md#compact-classes

Interfaces

Compact

The marker a class implements to store its links as 32-bit offsets. It has no members, so implements Compact adds no field.

interface Compact

Wide

Reserved for WP48 stage 3, which lets a class refuse a layout the compiler picks. Accepted today and changes nothing.

interface Wide