Iterators are a fundamental programming abstraction for traversing and modifying elements in containers in mainstream imperative languages such as C++. Iterators provide a uniform access mechanism that hides low-level implementation details of the underlying data structure. However, iterators over mutable containers suffer from well-known hazards including invalidation, aliasing, data races, and subtle side effects. Immutable data structures, as used in functional programming languages, avoid the pitfalls of mutation but rely on a very different programming model based on recursion and higher-order combinators (map, foldl, traverse, etc.) rather than iteration. However, these combinators are not always well-suited to expressing certain algorithms, and recursion can expose implementation details of the underlying data structure.
In this paper, we propose persistent iterators—a new abstraction that reconciles the familiar iterator-based programming style of imperative languages with the semantics of persistent data structures. A persistent iterator snapshots the version of its underlying container at creation, ensuring safety against invalidation and aliasing. Iterator operations (++, erase, etc.) operate on the iterator-local copy of the container, giving true value semantics: variables can be rebound to new persistent values while previous versions remain accessible. We implement our approach in the form of LibFpp—a C++ container library providing persistent vectors, maps, sets, strings, and other abstractions as persistent counterparts to the Standard Template Library (STL). Our evaluation shows that LibFpp retains the expressiveness of iterator-based programming, eliminates iterator-invalidation, and achieves asymptotic complexities comparable to STL implementations—albeit with the higher constant-factor overheads of persistence. Our design targets use cases where persistence and safety are desired, while allowing developers to retain familiar iterator-based programming patterns.
Thu 18 JunDisplayed time zone: Mountain Time (US & Canada) change
11:00 - 12:40 | Domain-Specific LanguagesPLDI Research Papers at Flatirons 3 Chair(s): Qirun Zhang Georgia Institute of Technology | ||
11:00 20mTalk | Decoupling Data Layouts from Bounding Volume Hierarchies PLDI Research Papers Christophe Gyurgyik Stanford University, Alexander J Root Stanford University, Fredrik Kjolstad Stanford University DOI | ||
11:20 20mTalk | Contextual Embeddings: Implementing Bound Variables through Instance Resolution PLDI Research Papers Samantha Frohlich University of Bristol, Jessica Foster University of Bristol, Alex Kavvos University of Bristol, Meng Wang University of Bristol DOI Pre-print Media Attached | ||
11:40 20mTalk | CoTenN: Constrained Optimization with Tensor Networks PLDI Research Papers Ritvik Sharma Stanford University, Cheng Peng Stanford Institute for Materials and Energy Sciences, SLAC National Accelerator Laboratory, Siddharth Dangwal University of Chicago, Sara Achour Stanford University DOI | ||
12:00 20mTalk | Diagramming Program Values by Spatial Refinement PLDI Research Papers Siddhartha Prasad Brown University, Michael Tu Brown University, Karan Kashyap Brown University, Tim Nelson Brown University, Shriram Krishnamurthi Brown University DOI | ||
12:20 20mTalk | Persistent Iterators with Value Semantics PLDI Research Papers DOI | ||