Gradual Metaprogramming

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Chen, Tianyu, Shetty, Darshal, Siek, Jeremy G., Chen, Chao-Hong, Ma, Weixi, Venet, Arnaud, Liu, Rocky
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866908496111337472
author Chen, Tianyu
Shetty, Darshal
Siek, Jeremy G.
Chen, Chao-Hong
Ma, Weixi
Venet, Arnaud
Liu, Rocky
author_facet Chen, Tianyu
Shetty, Darshal
Siek, Jeremy G.
Chen, Chao-Hong
Ma, Weixi
Venet, Arnaud
Liu, Rocky
contents Data engineers increasingly use domain-specific languages (DSLs) to generate the code for data pipelines. Such DSLs are often embedded in Python. Unfortunately, there are challenges in debugging the generation of data pipelines: an error in a Python DSL script is often detected too late, after the execution of the script, and the source code location that triggers the error is hard to pinpoint. In this paper, we focus on the scenario where a DSL embedded in Python (so it is dynamically-typed) generates data pipeline description code that is statically-typed. We propose gradual metaprogramming to (1) provide a migration path toward statically typed DSLs, (2) immediately provide earlier detection of code generation type errors, and (3) report the source code location responsible for the type error. Gradual metaprogramming accomplishes this by type checking code fragments and incrementally performing runtime checks as they are spliced together. We define MetaGTLC, a metaprogramming calculus in which a gradually-typed metalanguage manipulates a statically-typed object language, and give semantics to it by translation to the cast calculus MetaCC. We prove that successful metaevaluation always generates a well-typed object program and mechanize the proof in Agda.
format Preprint
id arxiv_https___arxiv_org_abs_2506_09043
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Gradual Metaprogramming
Chen, Tianyu
Shetty, Darshal
Siek, Jeremy G.
Chen, Chao-Hong
Ma, Weixi
Venet, Arnaud
Liu, Rocky
Programming Languages
D.3
Data engineers increasingly use domain-specific languages (DSLs) to generate the code for data pipelines. Such DSLs are often embedded in Python. Unfortunately, there are challenges in debugging the generation of data pipelines: an error in a Python DSL script is often detected too late, after the execution of the script, and the source code location that triggers the error is hard to pinpoint. In this paper, we focus on the scenario where a DSL embedded in Python (so it is dynamically-typed) generates data pipeline description code that is statically-typed. We propose gradual metaprogramming to (1) provide a migration path toward statically typed DSLs, (2) immediately provide earlier detection of code generation type errors, and (3) report the source code location responsible for the type error. Gradual metaprogramming accomplishes this by type checking code fragments and incrementally performing runtime checks as they are spliced together. We define MetaGTLC, a metaprogramming calculus in which a gradually-typed metalanguage manipulates a statically-typed object language, and give semantics to it by translation to the cast calculus MetaCC. We prove that successful metaevaluation always generates a well-typed object program and mechanize the proof in Agda.
title Gradual Metaprogramming
topic Programming Languages
D.3
url https://arxiv.org/abs/2506.09043