,
Casper Bach Poulsen
Creative Commons Attribution 4.0 International license
Many programming languages allow programmers to regulate accessibility; i.e., annotating a declaration with keywords such as export and private to indicate where it can be accessed. Despite the importance of name accessibility for, e.g., compilers, editor auto-completion and tooling, and automated refactorings, few existing type systems provide a formal account of name accessibility. We present a declarative, executable, and language-parametric model for name accessibility, which provides a formal specification of name accessibility in Java, C#, C++, Rust, and Eiffel. We achieve this by defining name accessibility as a predicate on resolution paths through scope graphs. Since scope graphs are a language-independent model of name resolution, our model provides a uniform approach to defining different accessibility policies for different languages. Our model is implemented in Statix, a logic language for executable type system specification using scope graphs. We evaluate its correctness on a test suite that compares it with the C#, Java, and Rust compilers, and show we can synthesize access modifiers in programs with holes accurately.
@InProceedings{zwaan_et_al:LIPIcs.ECOOP.2024.47,
author = {Zwaan, Aron and Bach Poulsen, Casper},
title = {{Defining Name Accessibility Using Scope Graphs}},
booktitle = {38th European Conference on Object-Oriented Programming (ECOOP 2024)},
pages = {47:1--47:29},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-341-6},
ISSN = {1868-8969},
year = {2024},
volume = {313},
editor = {Aldrich, Jonathan and Salvaneschi, Guido},
publisher = {Schloss Dagstuhl -- Leibniz-Zentrum f{\"u}r Informatik},
address = {Dagstuhl, Germany},
URL = {https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.ECOOP.2024.47},
URN = {urn:nbn:de:0030-drops-208961},
doi = {10.4230/LIPIcs.ECOOP.2024.47},
annote = {Keywords: access modifier, visibility, scope graph, name resolution}
}