Modular Borrowing Without Ownership or Linear Types
Borrowing describes the process in which a tracked resource can be temporarily shared and used in a special form before being returned to the original resource owner/handler. This is an old idea that was more recently popularized in the Rust programming language. In Rust, borrowing is used to guarantee memory safety by making mutability and aliasing mutually exclusive and bounding the lifetimes of borrowed references. This in turn depends crucially on Rust’s ownership system, which is a substructural type system with a coarse representation of value lifetimes that significantly restricts the space of valid programs. But the basic idea of borrowing also makes sense independently of such ownership and substructural systems, and in particular it makes sense in more classical garbage-collected and high-level programming languages. In this context, it can for example be used to prevent iterator invalidation and to make structured concurrency “fearless” by preventing data races.
In this talk, I propose a new take on borrowing based on a type and effect system and Boolean algebraic subtyping. Instead of restricting the aliasing of sensitive resources, we track their uses as side effects in the type system. Then, we encode borrowing by describing regions in which certain effects cannot occur – which is represented through the use of Boolean negation types. Moreover, using a slight generalization of MLstruct’s Boolean-algebraic subtype inference allows us to express programs that make use of borrowing without any type annotations in user programs. Finally, since our borrowing discipline is entirely type-based (and not syntactic, unlike Rust’s borrow-checker), we can freely modularize the code by, for instance, moving arbitrary parts of an implementation into helper functions, enabling fearless refactoring.
Slides (Modular Borrowing Without Ownership or Linear Types.pdf) | 304KiB |
I am an Assistant Professor at the HKUST CSE department since February 2021. I am looking for students to join my research group! Please contact me (first-name dot last-name at gmail.com) if you’d like to work on something related to programming languages, type systems, or compiler optimization.
I obtained my PhD in 2020 from EPFL, in the Data Analysis Theory and Applications Laboratory (DATA), where I created the Squid type-safe metaprogramming library for Scala.
Mon 21 OctDisplayed time zone: Pacific Time (US & Canada) change
11:00 - 12:30 | |||
11:00 30mTalk | Capabilities, Effects, Ownership, and Behaviors IWACO Colin Gordon Drexel University | ||
11:30 30mTalk | Modular Borrowing Without Ownership or Linear Types IWACO Lionel Parreaux HKUST (The Hong Kong University of Science and Technology) Media Attached File Attached | ||
12:00 30mTalk | Substructural Information Flow via Polymorphism IWACO Hemant Gouni Carnegie Mellon University, Pittsburgh, Pennsylvania, United States, Jonathan Aldrich Carnegie Mellon University Media Attached File Attached |