Formal semantics of weak references

  • Authors:
  • Kevin Donnelly;J. J. Hallett;Assaf Kfoury

  • Affiliations:
  • Boston University;Boston University;Boston University

  • Venue:
  • Proceedings of the 5th international symposium on Memory management
  • Year:
  • 2006

Quantified Score

Hi-index 0.00

Visualization

Abstract

Weak references are references that do not prevent the object they point to from being garbage collected. Many realistic languages, including Java, SML/NJ, and Haskell to name a few, support weak references. However, there is no generally accepted formal semantics for weak references. Without such a formal semantics it becomes impossible to formally prove properties of such a language and the programs written in it.We give a formal semantics for a calculus called λweak that includes weak references and is derived from Morrisett, Felleisen, and Harper's λgc. The semantics is used to examine several issues involving weak references. We use the framework to formalize the semantics for the key/value weak references found in Haskell. Furthermore, we consider a type system for the language and show how to extend the earlier result that type inference can be used to collect reachable garbage. In addition we show how to allow collection of weakly referenced garbage without incurring the computational overhead often associated with collecting a weak reference which may be later used. Lastly, we address the non-determinism of the semantics by providing both an effectively decidable syntactic restriction and a more general semantic criterion, which guarantee a unique result of evaluation.