-
Notifications
You must be signed in to change notification settings - Fork 326
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.new
and Array.copy
and move Vector functions to builtins.
#7147
Conversation
81f1694
to
f896873
Compare
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.
So the idea with Array
and Vector
is to make sure that they have essentially the same methods and can be used interchangeably (see also #6299). It seems like the allocate
bit interfere with that.
Re builtins design - lgtm so far.
Ideally, I will remove |
f896873
to
7ce4ccf
Compare
Array.new
and Array.copy
and move Vector functions to builtins.
engine/runtime/src/test/java/org/enso/interpreter/test/ArrayTest.java
Outdated
Show resolved
Hide resolved
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.
Looks good, just a question.
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'd rather we keep some of the static wrapper calls in place, if possible
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.
Overall very positive and useful change. Some comments, advises left for your consideration.
It'd be good to benchmark flatten
, insert
and remove
and compare previous and new results.
Array.copy vec.to_array 0 arr i vec.length | ||
i + vec.length | ||
Vector.from_polyglot_array arr | ||
flatten self = @Builtin_Method "Vector.flatten" |
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 am surprised flatten isn't written in Enso and requires a builtin. Less builtins is always better...
flat x =
size = x.map .length . fold 0 (+)
b = Vector.new_builder size
x.map arr->
arr.map e->
b.append e
b.to_vector
this code seems to flatten
the elements too.
self.move_builtin destination copy_options | ||
False -> self.move_builtin destination Array.empty | ||
copy_options = [StandardCopyOption.REPLACE_EXISTING] | ||
self.move_builtin destination copy_options.to_array |
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.
Nobody shall require .to_array
call. The File
should be fixed to work with Vector
or any array-like object. The issue is already tracked as
...ain/java/org/enso/interpreter/node/expression/builtin/immutable/InsertBuiltinVectorNode.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/enso/interpreter/node/expression/builtin/immutable/RemoveAtVectorNode.java
Outdated
Show resolved
Hide resolved
...time/src/main/java/org/enso/interpreter/node/expression/builtin/mutable/CoerceArrayNode.java
Show resolved
Hide resolved
engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/SystemProcessTest.scala
Show resolved
Hide resolved
Removing `Array.empty`.
Replaces the `Array.copy` in `Vector_Builder` with a new `Builder` based approach.
Removed old test now allocate removed.
Linting type sig check fixes.
Passing `ArraySlice` would enter the fallback and crash.
7eff518
to
75e85c3
Compare
Some type signature fixes.
Pull Request Description
new
,copy
andnew_[1234]
.Vector.insert
,Vector.remove
andVector.flatten
.Vector_Builder
use ofArray.copy
to aVector.Builder
approach.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.