Skip to content
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

Array slices #47

Open
Mercerenies opened this issue Feb 15, 2019 · 1 comment
Open

Array slices #47

Mercerenies opened this issue Feb 15, 2019 · 1 comment

Comments

@Mercerenies
Copy link
Owner

So it occurred to me that we already have this feature (or at least a read-only version of it). It would just be nice to make it a little more accessible. Specifically, if I want to get a slice of an array, I can just clone the array and change the bounds

arr := [1, 2, 3, 4].
slice := arr clone.
slice lowerBound := 1.
slice upperBound := 3.
slice printObject. ;; [2, 3]

Unfortunately, this is (1) incredibly verbose and (2) unidirectional. That is, changes to arr will be reflected in slice but not the other way around. We could pretty easily make a slice proxy object which allows bidirectional modification. The slice object would have mutable indices but would not have push or pop capabilities.

@Mercerenies
Copy link
Owner Author

Note that we would need to consider the impact of this issue with #32. Specifically, it would be nice to be able to slice into the #32 limited object as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant