Journal of Information Processing
Online ISSN : 1882-6652
ISSN-L : 1882-6652
 
MAYUZIN: Runtime Generative and Analytical Metaprogramming
Ya Mone ZinYukiyoshi Kameyama
Author information
JOURNAL FREE ACCESS

2025 Volume 33 Pages 461-470

Details
Abstract

This paper introduces Mayuzin, a new multi-stage programming (MSP) language designed to integrate both generative and analytical capabilities for run-time metaprogramming while preserving type safety. While code generation and code analysis play complementary roles in metaprogramming practice, theoretical foundation for code analysis has been largely overlooked in the literature, with a notable exception by Stucki et al., who studied code analysis in compile-time metaprogramming. In this study, we fill this gap by presenting a metaprogramming language that supports both runtime code generation and analysis, ensuring type safety throughout. Mayuzin introduces three key features: (1) a code analysis framework that leverages pattern matching to enable dynamic code inspection and transformation, (2) integration of ML-style let polymorphism within the multi-stage setting using the Hindley-Milner type system as a foundation, and (3) support for manipulation of open codes, which is crucial for generating efficient code. Our design extends traditional MSP by providing robust facilities for runtime code analysis while aiming to maintain type guarantees across stages. We will illustrate Mayuzin's capabilities through examples of runtime code optimization in domain-specific applications, such as eliminating redundant computations in generated numerical code. These examples demonstrate how Mayuzin's unified approach to metaprogramming facilitates efficient domain-specific optimizations, with rigorous proof of type safety, ensuring safe runtime code transformations.

Content from these authors
© 2025 by the Information Processing Society of Japan
Previous article Next article
feedback
Top