pith. sign in

Meta-Monomorphizing Specializations

1 Pith paper cite this work. Polarity classification is still indexing.

1 Pith paper citing it
abstract

Achieving zero-cost specialization remains a fundamental challenge in programming language and compiler design. It often necessitates trade-offs between expressive power and type system soundness, as the interaction between conditional compilation and static dispatch can easily lead to unforeseen coherence violations and increased complexity in the formal model. This paper introduces meta-monomorphizing specializations, a novel framework that achieves specialization by repurposing monomorphization through compile-time metaprogramming. Instead of modifying the host compiler, our approach generates meta-monomorphized traits and implementations that encode specialization constraints directly into the type structure, enabling deterministic, coherent dispatch without overlapping instances. We formalize this method for first-order, predicate-based, and higher-ranked polymorphic specialization, also in presence of lifetime parameters. Our evaluation, based on a Rust implementation using only existing macro facilities, demonstrates that meta-monomorphization enables expressive specialization patterns while maintaining full compatibility with standard optimization pipelines. We show that specialization can be realized as a disciplined metaprogramming layer, offering a practical, language-agnostic path to high-performance abstraction. A comprehensive study of public Rust codebases further validates our approach, revealing numerous workarounds that meta-monomorphization can eliminate, leading to more idiomatic and efficient code. An empirical evaluation on 16 micro-benchmarks confirms that compile-time specialization matches or outperforms runtime TypeId-based dispatch, and demonstrates expressiveness gains on patterns -- such as lifetime-based dispatch, higher-ranked types, compound predicates, and wildcard matching -- that runtime dispatch structurally cannot express.

fields

cs.SE 1

years

2026 1

verdicts

UNVERDICTED 1

representative citing papers

Generalized Software Product Line Extraction

cs.SE · 2026-05-27 · unverdicted · novelty 5.0

A general protocol for SPL extraction and configuration based on atoms, with a client-server architecture demonstrated in a prototype for language product lines.

citing papers explorer

Showing 1 of 1 citing paper.

  • Generalized Software Product Line Extraction cs.SE · 2026-05-27 · unverdicted · none · ref 16 · internal anchor

    A general protocol for SPL extraction and configuration based on atoms, with a client-server architecture demonstrated in a prototype for language product lines.