Mixed-Level Embedding and JIT Compilation for an Iteratively Staged DSL [chapter]

George Giorgidze, Henrik Nilsson
2011 Lecture Notes in Computer Science  
This paper explores how to implement an iteratively staged domain-specific language (DSL) by embedding into a functional language. The domain is modelling and simulation of physical systems where models are expressed in terms of non-causal differential-algebraic equations; i.e., sets of constraints solved through numerical simulation. What sets our language apart is that the equational constraints are first class entities allowing for an evolving model structure characterised by repeated
more » ... ion of updated constraints. Hence iteratively staged. Our DSL can thus be seen as a combined functional and constraint programming language, albeit a two-level one, with the functional language chiefly serving as a meta language. However, the two levels do interact throughout the simulation. The embedding strategy we pursue is a mixture of deep and shallow, with the deep embedding enabling justin-time (JIT) compilation of the constraints as they are generated for efficiency, while the shallow embedding is used for the remainder for maximum leverage of the host language. The paper is organised around a specific DSL, but our implementation strategy should be applicable for iteratively staged languages in general. Our DSL itself is further a novel variation of a declarative constraint programming language.
doi:10.1007/978-3-642-20775-4_3 fatcat:ocwlh4zezzbxngi6ju445tb2va