Auto-cleanup - #240
Merged
Merged
Conversation
# Conflicts: # crates/par-core/src/frontend_impl/types/assignability.rs # crates/par-core/src/frontend_impl/types/core.rs # crates/par-core/src/frontend_impl/types/display.rs # crates/par-core/src/frontend_impl/types/mod.rs
…eanup; auto-cleanup chapter still missing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces automatic cleanup of linear resources: the
boxconstraint is split intodropandshare, and linear resources can declare a cleanup branch that Par uses to dispose of them automatically.Language & types
boxconstraint into two:drop(value may be left unused) andshare(value may be copied, reused, and dropped). New constraint chain:signed -> number -> data -> share -> drop.choice/eithertype can mark exactly one branch with*(e.g..release* => !) to declare it safe for automatic disposal; the marker also appears in the correspondingcaseconstruction to register the branch.dropwhen it has a*branch whose result also satisfiesdrop;droppropagates structurally through pairs, eithers, recursive types, and generics.writer.close.tryto observe closing errors) still work.Implementation
dropvalues; choices expose a synthesized#closebranch to the backend.Global::Closenode with interaction rules for closing pairs, eithers, primitives, and choices.Standard library
boxtodrop/shareacrosscoreandbasic.Stream.cancel*,Sql.Transaction.rollback*,Console.close*,Bytes/Stringreader & writer.close*,Map.close(renamed from.list), and list builders.Option.ToResulttoOption.ToTry.Examples & tests
tests/src/CleanupBranch.parcovering automatic and explicit cleanup, structural follow-through, and external cleanup aliases.Book
drop/share.