Abstract

Pawns is a programming language under development that supports algebraic data types, polymorphism, higher order functions and “pure” declarative programming. It also supports impure imperative features including destructive update of shared data structures via pointers, allowing significantly increased e ffi ciency for some operations. A novelty of Pawns is that all impure “eff ects” must be made obvious in the source code and they can be safely encapsulated in pure functions in a way that is checked by the compiler. Execution of a pure function can perform destructive updates on data structures that are local to or eventually returned from the function without risking modification of the data structures passed to the function. This paper describes the sharing analysis which allows impurity to be encapsulated. Aspects of the analysis are similar to other published work, but in addition it handles explicit pointers and destructive update, higher order functions including closures and preand post-conditions concerning sharing for functions.

Highlights

  • This paper describes the sharing analysis done by the compiler for Pawns (Naish, 2015), a programming language that is currently under development

  • Declarative languages have the advantage of avoiding side effects, such as destructive update of function arguments

  • A function can behave in a purely declarative way if destructive update is allowed, but restricted to data structures that are created inside the function

Read more

Summary

INTRODUCTION

This paper describes the sharing analysis done by the compiler for Pawns (Naish, 2015), a programming language that is currently under development. As well as checking for annotations on assignments and function calls, sharing analysis is used to check that all parameters which may be updated are declared mutable in type signatures, and pre- and post-conditions are always satisfied. Because Pawns uses the syntax of statements to express pre- and post-conditions, our implementation uses the sharing analysis algorithm to derive an explicit alias set representation (currently this is done recursively, with the level of recursion limited by the fact than pre- and post-conditions must not contain function calls). Cons pointer and the cell containing Nil. Type instantiation is dealt with in the same way as variable equality, with the additional check that if any sharing is introduced, the variable with the more general type is not implicitly updated later while still live (it is sufficient to check there is no “!v2” annotation attached to a later statement).

DISCUSSION
RELATED WORK
CONCLUSION
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call