Alumina

1 program Added 2026-02-09T09:32:13Z Agent: claude-codeModel: opusWebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit b4ca6b75b6 · authored 2026-02-09T10:33:12+01:00 · agent claude-code · model opus

Sources mentioning this language

2 sources · pl_id: pl/alumina
LLM (this repo) · 1Pldb

Related languages

Alda (0.25)Agena (0.23)Arena (0.23)Alpaca (0.21)Gallina (0.20)

LLM-contributed programs

Dynamic and Static Polymorphism

Provenance: commit b4ca6b75b6 · authored 2026-02-09T10:33:12+01:00 · agent claude-code · model opus · WebSearch enabled
code.alu · license: MIT · added: 2026-02-09T09:32:13Z
protocol Slot<Self, Element> {
    fn get(self: &Self) -> Option<Element>;
    fn set(self: &mut Self, element: Element);
    fn type_name(self: &Self) -> &[u8] {
        std::typing::type_name::<Self>()
    }
}

struct RealSlot {
    value: Option<i32>,
}

impl RealSlot {
    fn get(self: &RealSlot) -> Option<i32> {
        self.value
    }
    fn set(self: &mut RealSlot, element: i32) {
        self.value = Option::some(element);
    }
    mixin Slot<RealSlot, i32>;
}

struct NullSlot {}

impl NullSlot {
    fn get(self: &NullSlot) -> Option<i32> {
        Option::none()
    }
    fn set(self: &mut NullSlot, _element: i32) {
    }
    mixin Slot<NullSlot, i32>;
}

/// Static polymorphism.
///
/// During monomorphization, the compiler will generate a copy of `roundtrip_generic`
/// for each type of slot encountered (RealSlot and NullSlot).
fn roundtrip_generic<T: Slot<T, i32>>(slot: &mut T) {
    let val = 42;
    println!("[GENERIC] Inserting {} into {}", val, slot.type_name());
    slot.set(val);
    println!("[GENERIC] Retrieving value from {}: {}", slot.type_name(), slot.get());
}

/// Dynamic polymorphism.
///
/// `roundtrip_dyn` is a non-generic function. It takes a dyn object, which contains
/// a pointer to a virtual method table so an appropriate implementation of `Slot` can be
/// found at runtime.
fn roundtrip_dyn(slot: &mut dyn Slot<Self, i32>) {
    let val = 42;
    println!("[DYN] Inserting {} into {}", val, slot.type_name());
    slot.set(val);
    println!("[DYN] Retrieving value from {}: {}", slot.type_name(), slot.get());
}

fn main() {
    let real_slot = RealSlot { value: Option::none() };
    let null_slot = NullSlot {};

    roundtrip_generic(&real_slot);
    roundtrip_generic(&null_slot);

    roundtrip_dyn(&real_slot);
    roundtrip_dyn(&null_slot);
}

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Alumina (mapped to pl/alumina). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Alumina/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← aluasm ALWCIDFEC →