Meta-Monomorphizing Specializations
Federico Bruzzone, Walter Cazzola

TL;DR
This paper presents meta-monomorphizing specializations, a compile-time metaprogramming framework that enables deterministic, coherent specialization in programming languages like Rust without modifying the host compiler.
Contribution
It introduces a novel approach that repurposes monomorphization through compile-time metaprogramming to achieve high-performance specialization.
Findings
Enables expressive specialization patterns in Rust using existing macro facilities.
Maintains full compatibility with standard optimization pipelines.
Outperforms runtime TypeId-based dispatch in micro-benchmarks.
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
