{"title":"Defining Name Accessibility using Scope Graphs (Extended Edition)","authors":"Aron Zwaan, Casper Bach Poulsen","doi":"arxiv-2407.09320","DOIUrl":null,"url":null,"abstract":"Many programming languages allow programmers to regulate accessibility; i.e.,\nannotating a declaration with keywords such as export and private to indicate\nwhere it can be accessed. Despite the importance of name accessibility for,\ne.g., compilers, editor auto-completion and tooling, and automated\nrefactorings, few existing type systems provide a formal account of name\naccessibility. We present a declarative, executable, and language-parametric model for name\naccessibility, which provides a formal specification of name accessibility in\nJava, C#, C++, Rust, and Eiffel. We achieve this by defining name accessibility\nas a predicate on resolution paths through scope graphs. Since scope graphs are\na language-independent model of name resolution, our model provides a uniform\napproach to defining different accessibility policies for different languages. Our model is implemented in Statix, a logic language for executable type\nsystem specification using scope graphs. We evaluate its correctness on a test\nsuite that compares it with the C#, Java, and Rust compilers, and show we can\nsynthesize access modifiers in programs with holes accurately.","PeriodicalId":501197,"journal":{"name":"arXiv - CS - Programming Languages","volume":null,"pages":null},"PeriodicalIF":0.0000,"publicationDate":"2024-07-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Programming Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2407.09320","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
Abstract
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.