Building Code with Dynamic Staging
Piotr Danilewski (1, 2, 3), Philipp Slusallek (1, 2, 4), ((1) Saarland University, Germany, (2) Intel Visual Computing Institute,, Germany, (3) Theoretical Computer Science, Jagiellonian University, Poland,, (4) Deutsches Forschungszentrum f\"ur K\"unstliche Intelligenz, Germany)

TL;DR
This paper introduces a dynamic staging approach for embedded DSLs that constructs executable code incrementally during parsing, eliminating the need for deep AST embeddings and enabling efficient, reusable, and flexible language semantics.
Contribution
It proposes a novel method for defining DSL semantics through action functions during parsing, allowing incremental code assembly without object representations or external traversals.
Findings
Produces code as efficient as handwritten implementations
Enables reuse of code between EDSL and host language
Supports complex semantics like variable scope and control flow
Abstract
When creating a new domain-specific language (DSL) it is common to embed it as a part of a flexible host language, rather than creating it entirely from scratch. The semantics of an embedded DSL (EDSL) is either given directly as a set of functions (shallow embedding), or an AST is constructed that is later processed (deep embedding). Typically, the deep embedding is used when the EDSL specifies domain-specific optimizations (DSO) in a form of AST transformations. In this paper we show that deep embedding is not necessary to specify most optimizations. We define language semantics as action functions that are executed during parsing. These actions build incrementally a new, arbitrary complex program function. The EDSL designer is able to specify many aspects of the semantics as a runnable code, such as variable scoping rules, custom type checking, arbitrary control flow structures,…
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.
Taxonomy
TopicsLogic, programming, and type systems · Model-Driven Software Engineering Techniques · Formal Methods in Verification
