-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add immutable-vector
, immutable-vector-copy
, etc.
#789
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These procedures make immutable vectors much easier to use, thanks!
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 |
This PR now pulls in @owaddell's improvements. There's no cptypes changes, yet, and those might be best considered in a new PR. |
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)
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>
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>
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>
Based on a suggestion and initial work from @owaddell, extract the
immutable-vector
addition from #596, and then addimmutable-vector-copy
and friends. The motivation for the additions is the same as forvector-copy
and 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-vector
ifimmutable-vector-copy
existed in the first place.