A practical mode system for recursive definitions - Inria - Institut national de recherche en sciences et technologies du numérique
Article Dans Une Revue Proceedings of the ACM on Programming Languages Année : 2021

A practical mode system for recursive definitions

Résumé

In call-by-value languages, some mutually-recursive definitions can be safely evaluated to build recursive functions or cyclic data structures, but some definitions (let rec x = x + 1) contain vicious circles and their evaluation fails at runtime. We propose a new static analysis to check the absence of such runtime failures. We present a set of declarative inference rules, prove its soundness with respect to the reference sourcelevel semantics of Nordlander, Carlsson, and Gill [2008], and show that it can be directed into an algorithmic backwards analysis check in a surprisingly simple way. Our implementation of this new check replaced the existing check used by the OCaml programming language, a fragile syntactic criterion which let several subtle bugs slip through as the language kept evolving. We document some issues that arise when advanced features of a real-world functional language (exceptions in first-class modules, GADTs, etc.) interact with safety checking for recursive definitions. CCS Concepts: • Software and its engineering → General programming languages; Recursion.
Fichier principal
Vignette du fichier
letrec.pdf (732.77 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-03125031 , version 1 (29-01-2021)

Identifiants

Citer

Alban Reynaud, Gabriel Scherer, Jeremy Yallop. A practical mode system for recursive definitions. Proceedings of the ACM on Programming Languages, 2021, 5 (POPL), pp.1-29. ⟨10.1145/3434326⟩. ⟨hal-03125031⟩
140 Consultations
115 Téléchargements

Altmetric

Partager

More