Goose

Minimal namespaces

Files can declare a namespace and refer to declarations by qualified names. This extends the existing import loader and whole-program compiler.

// image/filters.goose
namespace image;
struct Pixel { r: u8, g: u8, b: u8 }
fn brightness(p: Pixel) -> i64 { p.r + p.g + p.b }

// main.goose (a separate file)
import image.filters;
fn main() {
    let p = image::Pixel { 10, 20, 30 };
    print(image::brightness(p));
}

Rules

Implementation

This extension changes name resolution. It does not add separate compilation, package resolution, privacy, re-exports, or first-class module values.

Rust and Zig comparison

Rust's mod builds a hierarchical module tree within a crate, use introduces bindings, and visibility is generally private by default with pub controls. This design borrows qualified-path spelling but keeps file loading separate from namespace declaration, permits several files to contribute to one namespace, and leaves declarations public. See the official module reference, use reference and visibility rules.

Zig's const image = @import("image.zig"); binds the imported file's container type; declarations are accessed with ., and pub controls external visibility. That fits Zig's compile-time type/value model. The Goose namespace is only a symbol-table scope: it cannot be assigned, returned, parameterized as a value or inspected at compile time. See the official Zig language reference.