20 research outputs found

    Modelling homogeneous generative meta-programming

    Get PDF
    Homogeneous generative meta-programming (HGMP) enables the generation of program fragments at compile-time or run-time. We present a foundational calculus which can model both compile-time and run-time evaluated HGMP, allowing us to model, for the first time, languages such as Template Haskell. The calculus is designed such that it can be gradually enhanced with the features needed to model many of the advanced features of real languages. We demonstrate this by showing how a simple, staged type system as found in Template Haskell can be added to the calculus

    T-LAIMA: Answer Set Programming for Modelling Agents with Trust

    Get PDF
    In a time where multi-agent systems (MAS) become increasingly more popular, they come in many forms and shapes depending on the requirements of the agents that need to populate them. Amongst the more demanding properties with respect to the design and implementation is how these agents may individually reason and communicate about their knowledge and beliefs, with a view to cooperation and collaboration. With information coming from various sources, it becomes vital for agents to have an idea how reliable these information providers are, especially if they start to contradict each other. In this paper we present a hybrid multi-agent platform, called T-LAIMA, using an extension of answer set programming (ASP). We show that our framework is capable of dealing with the specification and implementation of the system’s architecture, communication and the individual reasoning capacities of the agents. We discuss both the theoretical framework which models a single, fixed encounter between a number of agents and the implementation that sets ups these encounters in a open multi-agent domain

    A Practical Unification of Multi-stage Programming and Macros

    Get PDF
    Program generation is indispensable. We propose a novel unification of two existing metaprogramming techniques: multi-stage programming and hygienic generative macros. The former supports runtime code generation and execution in a type-safe manner while the latter offers compile-time code generation. In this work we draw upon a long line of research on metaprogramming, starting with Lisp, MetaML and MetaOCaml. We provide direct support for quotes, splices and top-level splices, all regulated uniformly by a level-counting Phase Consistency Principle. Our design enables the construction and combination of code values for both expressions and types. Moreover, code generation can happen either at runtime Ă  la MetaML or at compile time, in a macro fashion, Ă  la MacroML. We provide an implementation of our design in Scala and we present two case studies. The first implements the Hidden Markov Model, Shonan Challenge for HPC. The second implements the staged streaming library Strymonas

    A Transformation-Based Foundation for Semantics-Directed Code Generation

    Get PDF
    Interpreters and compilers are two different ways of implementing programming languages. An interpreter directly executes its program input. It is a concise definition of the semantics of a programming language and is easily implemented. A compiler translates its program input into another language. It is more difficult to construct, but the code that it generates runs faster than interpreted code. In this dissertation, we propose a transformation-based foundation for deriving compilers from semantic specifications in the form of four rules. These rules give apriori advice for staging, and allow explicit compiler derivation that would be less succinct with partial evaluation. When applied, these rules turn an interpreter that directly executes its program input into a compiler that emits the code that the interpreter would have executed. We formalize the language syntax and semantics to be used for the interpreter and the compiler, and also specify a notion of equality. It is then possible to precisely state the transformation rules and to prove both local and global correctness theorems. And although the transformation rules were developed so as to apply to an interpreter written in a denotational style, we consider how to modify non-denotational interpreters so that the rules apply. Finally, we illustrate these ideas by considering a larger example: a Prolog implementation

    Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs

    Get PDF
    Software engineering demands generality and abstraction, performance demands specialization and concretization. Generative programming can provide both, but the effort required to develop high-quality program generators likely offsets their benefits, even if a multi-stage programming language is used. We present lightweight modular staging, a library-based multi-stage programming approach that breaks with the tradition of syntactic quasi-quotation and instead uses only types to distinguish between binding times. Through extensive use of component technology, lightweight modular staging makes an optimizing compiler framework available at the library level, allowing programmers to tightly integrate domain-specific abstractions and optimizations into the generation process. We argue that lightweight modular staging enables a form of language virtualization, i.e. allows to go from a pure-library embedded language to one that is practically equivalent to a stand-alone implementation with only modest effort

    Syntactic Accidents in Program Analysis: On the Impact of the CPS Transformation

    Full text link
    corecore