40 research outputs found

    Program logics for homogeneous meta-programming.

    Get PDF
    A meta-program is a program that generates or manipulates another program; in homogeneous meta-programming, a program may generate new parts of, or manipulate, itself. Meta-programming has been used extensively since macros were introduced to Lisp, yet we have little idea how formally to reason about metaprograms. This paper provides the first program logics for homogeneous metaprogramming – using a variant of MiniMLe by Davies and Pfenning as underlying meta-programming language.We show the applicability of our approach by reasoning about example meta-programs from the literature. We also demonstrate that our logics are relatively complete in the sense of Cook, enable the inductive derivation of characteristic formulae, and exactly capture the observational properties induced by the operational semantics

    Program logics for homogeneous meta-programming.

    Get PDF
    A meta-program is a program that generates or manipulates another program; in homogeneous meta-programming, a program may generate new parts of, or manipulate, itself. Meta-programming has been used extensively since macros were introduced to Lisp, yet we have little idea how formally to reason about metaprograms. This paper provides the first program logics for homogeneous metaprogramming – using a variant of MiniMLe by Davies and Pfenning as underlying meta-programming language.We show the applicability of our approach by reasoning about example meta-programs from the literature. We also demonstrate that our logics are relatively complete in the sense of Cook, enable the inductive derivation of characteristic formulae, and exactly capture the observational properties induced by the operational semantics

    A Logical Foundation for Environment Classifiers

    Full text link
    Taha and Nielsen have developed a multi-stage calculus {\lambda}{\alpha} with a sound type system using the notion of environment classifiers. They are special identifiers, with which code fragments and variable declarations are annotated, and their scoping mechanism is used to ensure statically that certain code fragments are closed and safely runnable. In this paper, we investigate the Curry-Howard isomorphism for environment classifiers by developing a typed {\lambda}-calculus {\lambda}|>. It corresponds to multi-modal logic that allows quantification by transition variables---a counterpart of classifiers---which range over (possibly empty) sequences of labeled transitions between possible worlds. This interpretation will reduce the "run" construct---which has a special typing rule in {\lambda}{\alpha}---and embedding of closed code into other code fragments of different stages---which would be only realized by the cross-stage persistence operator in {\lambda}{\alpha}---to merely a special case of classifier application. {\lambda}|> enjoys not only basic properties including subject reduction, confluence, and strong normalization but also an important property as a multi-stage calculus: time-ordered normalization of full reduction. Then, we develop a big-step evaluation semantics for an ML-like language based on {\lambda}|> with its type system and prove that the evaluation of a well-typed {\lambda}|> program is properly staged. We also identify a fragment of the language, where erasure evaluation is possible. Finally, we show that the proof system augmented with a classical axiom is sound and complete with respect to a Kripke semantics of the logic

    Customizable Templates for OutSystems Applications

    Get PDF
    This dissertation addresses an extension of a metaprogramming mechanism in low-code platforms, specifically in the OutSystems platform. As proposed in the template language OSTRICH, model templates allow developers to reuse existing and thoroughly tested code fragments in a more productive and sound development process. Code templates help to overcome developer difficulties and lack of training. For instance, the development of professionally designed user interfaces is not a skill that is common amongst developers. Scenarios like specific synchronization algorithms are the other end of the spectrum for templates in OutSystems. The GOLEM project has the chief objective of providing mechanisms for automated programming. Such automation will make programming more accessible to a larger community of developers. This work is part of those efforts. To this end, our focus will be on developing and improving the template language OSTRICH that targets the OutSystems platform. It enables the creation of code fragments like screen templates, saving the user from the cumbersome task of repeatedly constructing code complex patterns. In OSTRICH, templates are instantiated by expanding their definition in the caller context to enable further customization of the resulting code. OSTRICH preserves the structure of the original model by expanding templates in place. However, expanding the template definition in place breaks the possibility of reapplying the template in the case of an update to a newer version or changing parameters. It requires the user to repeat all customization operations on top of a new instantiation of the template. Our purpose is to solve this issue by supporting customization operations that extend to all future template updates and new parameters. This way, the user will be saved from some erroneous trials, which could, eventually, push them to give up. We plan to evaluate our work using the benchmark template examples used previously to evaluate OSTRICH.Esta dissertação aborda uma extensão de um mecanismo de metaprogramação em pla- taformas low-code, especificamente na plataforma da OutSystems. Como proposto na linguagem de template OSTRICH, os templates permitem que os utilizadores reutilizem fragmentos de código existentes e completamente testados num processo de desenvol- vimento produtivo e seguro. Estes fragmentos ajudam os utilizadores a ultrapassar as dificuldades ou falta de conhecimento em linguagens de programação. Por exemplo, a sua utilização permite criar interfaces de forma profissional, o que nem sempre é uma habilidade comum entre desenvolvedores de software. Do outro lado do espetro, estão os algoritmos de sincronização específicos para modelos em OutSystems. O projeto GOLEM tem como principal objetivo fornecer mecanismos para automatizar a programação. Esta automatização irá tornar a programação mais acessível a um maior número de pessoas. Este trabalho faz parte destes esforços. Para alcançar este objetivo, estaremos focados no desenvolvimento e melhoria da linguagem de template OSTRICH para a plataforma da OutSystems. Esta permite a cria- ção de fragmentos de código como screen templates, poupando os utilizadores da tarefa complicada de repetir padrões complexos de código. Nesta linguagem, os templates são instanciados através da expansão da sua definição para permitir a customização do código resultante. Contudo, expandir esta definição no local quebra a possibilidade de reaplicar o template em caso de atualização para uma versão mais recente ou mudança de parâmetros. Isto acaba por obrigrar o utilizador a repetir todas as operações aplicadas numa nova instanciação de template. O nosso propósito passa por resolver este problema, permitindo que as operações do utilizador possam ser reaplicadas em todas as novas atualizações do template e novos parâmetros. Desta forma, o utilizador será poupado de seguir uma apren- dizagem tentativa e erro, que poderia eventualmente levá-lo a desistir. Planeamos avaliar o nosso trabalho utilizando como referência exemplos de templates usados anteriormente para avaliar a linguagem OSTRICH

    Squid: Type-Safe, Hygienic, and Reusable Quasiquotes

    Get PDF
    Quasiquotes have been shown to greatly simplify the task of metaprogramming. This is in part because they hide the data structures of the intermediate representation (IR), instead allowing metaprogrammers to use the concrete syntax of the language they manipulate. Scala has had ``syntactic'' quasiquotes for a long time, but still misses a statically-typed version like in MetaOCaml, Haskell and F#. This safer flavor of quasiquotes has been particularly useful for staging and domain-specific languages. In this paper we present Squid, a metaprogramming system for Scala that fills this gap. Squid quasiquotes are novel in three ways: they are the first statically-typed quasiquotes we know that allow code inspection (via pattern matching); they are implemented purely as a macro library, without modifications to the compiler; and they are reusable in the sense that they can manipulate different IRs. Adapting (or binding) a new IR to Squid is done simply by implementing a well-defined interface in the style of object algebras (i.e., tagless-final). We detail how Squid is implemented, leveraging the metaprogramming tools already offered by Scala, and show three application examples: the definition of a binding for a DSL in the style of LMS; a safe ANF conversion; and the introduction of type-safe, hygienic macros as an alternative to the current macro system

    Dynamically typed languages

    Get PDF
    Dynamically typed languages such as Python and Ruby have experienced a rapid grown in popularity in recent times. However, there is much confusion as to what makes these languages interesting relative to statically typed languages, and little knowledge of their rich history. In this chapter I explore the general topic of dynamically typed languages, how they differ from statically typed languages, their history, and their defining features

    Late-bound code generation

    Get PDF
    Each time a function or method is invoked during the execution of a program, a stream of instructions is issued to some underlying hardware platform. But exactly what underlying hardware, and which instructions, is usually left implicit. However in certain situations it becomes important to control these decisions. For example, particular problems can only be solved in real-time when scheduled on specialised accelerators, such as graphics coprocessors or computing clusters. We introduce a novel operator for hygienically reifying the behaviour of a runtime function instance as a syntactic fragment, in a language which may in general differ from the source function definition. Translation and optimisation are performed by recursively invoked, dynamically dispatched code generators. Side-effecting operations are permitted, and their ordering is preserved. We compare our operator with other techniques for pragmatic control, observing that: the use of our operator supports lifting arbitrary mutable objects, and neither requires rewriting sections of the source program in a multi-level language, nor interferes with the interface to individual software components. Due to its lack of interference at the abstraction level at which software is composed, we believe that our approach poses a significantly lower barrier to practical adoption than current methods. The practical efficacy of our operator is demonstrated by using it to offload the user interface rendering of a smartphone application to an FPGA coprocessor, including both statically and procedurally defined user interface components. The generated pipeline is an application-specific, statically scheduled processor-per-primitive rendering pipeline, suitable for place-and-route style optimisation. To demonstrate the compatibility of our operator with existing languages, we show how it may be defined within the Python programming language. We introduce a transformation for weakening mutable to immutable named bindings, termed let-weakening, to solve the problem of propagating information pertaining to named variables between modular code generating units.Open Acces

    Dynamically typed languages.

    Get PDF
    Dynamically typed languages such as Python and Ruby have experienced a rapid grown in popularity in recent times. However, there is much confusion as to what makes these languages interesting relative to statically typed languages, and little knowledge of their rich history. In this chapter I explore the general topic of dynamically typed languages, how they differ from statically typed languages, their history, and their defining features

    Static Computation and Reflection

    Get PDF
    Thesis (PhD) - Indiana University, Computer Sciences, 2008Most programming languages do not allow programs to inspect their static type information or perform computations on it. C++, however, lets programmers write template metaprograms, which enable programs to encode static information, perform compile-time computations, and make static decisions about run-time behavior. Many C++ libraries and applications use template metaprogramming to build specialized abstraction mechanisms, implement domain-specific safety checks, and improve run-time performance. Template metaprogramming is an emergent capability of the C++ type system, and the C++ language specification is informal and imprecise. As a result, template metaprogramming often involves heroic programming feats and often leads to code that is difficult to read and maintain. Furthermore, many template-based code generation and optimization techniques rely on particular compiler implementations, rather than language semantics, for performance gains. Motivated by the capabilities and techniques of C++ template metaprogramming, this thesis documents some common programming patterns, including static computation, type analysis, generative programming, and the encoding of domain-specific static checks. It also documents notable shortcomings to current practice, including limited support for reflection, semantic ambiguity, and other issues that arise from the pioneering nature of template metaprogramming. Finally, this thesis presents the design of a foundational programming language, motivated by the analysis of template metaprogramming, that allows programs to statically inspect type information, perform computations, and generate code. The language is specified as a core calculus and its capabilities are presented in an idealized setting
    corecore