add immutable-vector, immutable-vector-copy, etc.#789
Merged
mflatt merged 10 commits intocisco:mainfrom Jan 24, 2024
Merged
Conversation
burgerrg
approved these changes
Jan 6, 2024
Contributor
burgerrg
left a comment
There was a problem hiding this comment.
These procedures make immutable vectors much easier to use, thanks!
Contributor
|
I'd like to extend the inline handler for (define (expand-segments segments)
(let ([n (vector-length segments)])
(immutable-vector-append segments (make-vector n #f))))Right now cptypes doesn't recognize that Current work-in-progress patch to cpprims.ss: patch.txt |
Contributor
Author
|
This PR now pulls in @owaddell's improvements. There's no cptypes changes, yet, and those might be best considered in a new PR. |
burgerrg
reviewed
Jan 16, 2024
Contributor
Author
|
More improvements from @owaddell now added. |
(but edited by mflatt to sync with cptypes and such)
Includes cp0 rules to combine vector-construction operations, such as `(vector->immutable-vector (vector-append (vector x y) '#(3)))` to `(immutable-vector x y 3)`.
extend cpprim slightly to handle (immutable-vector-append vec1 (make-vector n e)) and (immutable-vector-append (make-vector n e) vec1)
mflatt
added a commit
to mflatt/ChezScheme
that referenced
this pull request
Jan 24, 2024
A follow-up to c081296, this commit adjusts the cp0 change to prefer an existing case instead of the new one. This order still passes the new test, it passes old ones with a small adjustment, and it passes Racket tests that are similar to "cp0.ms" tests. Meanwhile, c081296 should have noted the PR (cisco#789) it squashes and some author information that was lost in the squash: Co-authored-by: R. Kent Dybvig <dyb@scheme.com>
mflatt
pushed a commit
to mflatt/ChezScheme
that referenced
this pull request
Jan 25, 2024
A follow-up to c081296, this commit adjusts the cp0 change to avoid skipping the variable-dropping rewrite when the `begin` rotation applies. This combination passes the new test, passes old tests with small adjustments, and allows Racket to pass some tests that are similar to "cp0.ms" tests. Meanwhile, c081296 should have noted the PR (cisco#789) it squashes and some author information that was lost in the squash: Co-authored-by: R. Kent Dybvig <dyb@scheme.com>
mflatt
added a commit
that referenced
this pull request
Jan 31, 2024
A follow-up to c081296, this commit adjusts the cp0 change to avoid skipping the variable-dropping rewrite when the `begin` rotation applies. This combination passes the new test, passes old tests with small adjustments, and allows Racket to pass some tests that are similar to "cp0.ms" tests. Meanwhile, c081296 should have noted the PR (#789) it squashes and some author information that was lost in the squash: Co-authored-by: R. Kent Dybvig <dyb@scheme.com> Co-authored-by: Oscar Waddell <owaddell@beckman.com>
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.
Based on a suggestion and initial work from @owaddell, extract the
immutable-vectoraddition from #596, and then addimmutable-vector-copyand friends. The motivation for the additions is the same as forvector-copyand company: to implement persistent data structures, but where you want to enforce immutability and maybe enable optimizations.The changes include cp0 rules to combine vector-construction operations, such as turning
(vector->immutable-vector (vector-append (vector x y) '#(3)))into(immutable-vector x y 3).It turns out that
(immutable-vector-copy x)and(immutable-vector-append x)are both equivalent to(vector->immutable-vector x). This PR doesn't try to prune the API, although it's possible that we would have left outvector->immutable-vectorifimmutable-vector-copyexisted in the first place.