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

Remove Array.new and Array.copy and move Vector functions to builtins. #7147

Merged
merged 26 commits into from
Jul 3, 2023

Conversation

jdunkerley
Copy link
Member

@jdunkerley jdunkerley commented Jun 28, 2023

Pull Request Description

  • Removed Array methods: new, copy and new_[1234].
  • New builtins for Vector.insert, Vector.remove and Vector.flatten.
  • Replaced Vector_Builder use of Array.copy to a Vector.Builder approach.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@jdunkerley jdunkerley force-pushed the wip/jd/s3-list-objects branch from 81f1694 to f896873 Compare June 29, 2023 12:52
Copy link
Collaborator

@hubertp hubertp left a 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.

@jdunkerley
Copy link
Member Author

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.

Ideally, I will remove allocate and copy shortly. This will mean only way to make an Array within Enso is by creating a vector and calling to_array.

@jdunkerley jdunkerley force-pushed the wip/jd/s3-list-objects branch from f896873 to 7ce4ccf Compare June 30, 2023 10:20
@jdunkerley jdunkerley changed the title Wip/jd/s3 list objects Remove Array.new and Array.copy and move Vector functions to builtins. Jun 30, 2023
@jdunkerley jdunkerley added the CI: No changelog needed Do not require a changelog entry for this PR. label Jun 30, 2023
@jdunkerley jdunkerley marked this pull request as ready for review June 30, 2023 11:01
Copy link
Member

@radeusgd radeusgd left a 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.

Copy link
Collaborator

@hubertp hubertp left a 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

@jdunkerley jdunkerley added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Jun 30, 2023
Copy link
Member

@JaroslavTulach JaroslavTulach left a 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"
Copy link
Member

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
Copy link
Member

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

@jdunkerley jdunkerley force-pushed the wip/jd/s3-list-objects branch from 7eff518 to 75e85c3 Compare July 3, 2023 07:46
@jdunkerley jdunkerley added CI: Ready to merge This PR is eligible for automatic merge and removed CI: Clean build required CI runners will be cleaned before and after this PR is built. labels Jul 3, 2023
@mergify mergify bot merged commit 4fbe7e3 into develop Jul 3, 2023
@mergify mergify bot deleted the wip/jd/s3-list-objects branch July 3, 2023 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants