-
Notifications
You must be signed in to change notification settings - Fork 323
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
Remove Array.set_at
#3634
Remove Array.set_at
#3634
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.
It'd be more consistent if append_vector_range
used the same parameters as take
and drop
. Otherwise perfect - I am very glad Array.set
is gone!
engine/runtime/src/main/java/org/enso/interpreter/runtime/data/Array.java
Show resolved
Hide resolved
0a6480c
to
f18628e
Compare
@ExportMessage | ||
void writeArrayElement(long index, Object value) { | ||
items[(int) index] = value; | ||
} | ||
|
||
@ExportMessage | ||
boolean isArrayElementModifiable(long index) { | ||
return isArrayElementReadable(index); | ||
} | ||
|
||
@ExportMessage | ||
boolean isArrayElementInsertable(long index) { | ||
return false; | ||
} |
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.
I decided to remove these, since our arrays are meant to be immutable by design.
Curiously, still, Array.copy
is able to overwrite contents of our arrays even if they report being 'unmodifiable'. Very weird. @JaroslavTulach do you think this may be a bug? I assume it should be somehow possible to create a completely read-only array which does not support writing (possibly can be done by wrapping it in an UnmodifiableList
).
OTOH we are actually currently relying on this, as we use Array.copy
for implementing many of our Vector operations.
The removal of However many tests started failing for a separate, though related, reason. The reason is however a bug that was already there, it was just much more rare because most of our arrays used to be Enso A temporary fix would be to write a function
which ensures that an Enso array is used, and use it everywhere we pass arrays to such builtins, as there aren't that many places that do so. But this is definitely not an ideal solution, I think we need to rework how builtins expecting arrays work so that they accept any kind of array, not just the Enso ones. Maybe we can just replace |
As @hubertp pointed out, the issue may be partially fixed by #3628. I think the issue may still be worth discussing - because we would still be living with 3 types of arrays which are not interchangeable (not a very polyglot state of things), but at least vectors constructed from polyglot arrays would not cause such trouble as what is causing our current test failures, so that would be a step in the right direction. Still, for example the I think it will make most sense to put this PR on hold until #3628 is integrated and we can discuss the right way to proceed. |
e579617
to
8557a74
Compare
8557a74
to
29c4abc
Compare
29c4abc
to
01011f5
Compare
Array.copy still seems to work though
e2093bf
to
a7c8392
Compare
Pull Request Description
Implements https://www.pivotaltracker.com/story/show/182879865
Important Notes
Note that removing
set_at
still does not make our arrays fully immutable -Array.copy
can still be used to mutate them.Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide dist
and./run ide watch
.