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

fix: cast indicies to std::size_t in Array #82

Merged
merged 1 commit into from
Feb 3, 2024

Conversation

vil02
Copy link
Contributor

@vil02 vil02 commented Feb 3, 2024

Description

In this PR I suggest to use std::size_t as the size of the Array. The advantage is that it avoids sign conversions and it seems to simplify the logic.
In order to avoid sign conversions I suggest to cast indices to std::size_t.

Checklist

  • A description of the changes in this PR is mentioned above.
  • All the new and existing tests pass.
  • The code follows the code style and conventions of the project.
  • No plagiarized, duplicated, or repetitive code that has been directly copied from another source.
  • I have read the whole Contributing guidelines of the project and its resources/related pages.

Screenshots (if any)

Note to reviewers

Use std::size_t as the size of Array.
Cast indices to std::size_t in Array.

@mertcandav mertcandav self-requested a review February 3, 2024 11:03
@vil02 vil02 marked this pull request as ready for review February 3, 2024 11:03
@mertcandav mertcandav added the api About API (C++ API, not std/runtime API implementation) label Feb 3, 2024
Copy link
Member

@mertcandav mertcandav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes seems not possible. Jule uses integer types for indexing types. We can use std::size_t but Jule developers can not use exact size of std::size_t. API is just interface to develop integrated C++ codes for Jule, therefore API should compatible with Jule's rules.

We should keep current implementation but also we can add alternative function overloading for std::size_t to relevant functions.

@vil02 vil02 force-pushed the use_size_t_as_size_of_array branch from 3a3aa79 to 97cba1b Compare February 3, 2024 11:18
@vil02 vil02 changed the title fix: use std::size_t as the size of Array fix: cast indicies to std::size_t in Array Feb 3, 2024
@vil02 vil02 requested a review from mertcandav February 3, 2024 11:21
Copy link
Member

@mertcandav mertcandav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for your contribution.

@mertcandav mertcandav merged commit f81929d into julelang:master Feb 3, 2024
8 checks passed
@vil02 vil02 deleted the use_size_t_as_size_of_array branch February 3, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api About API (C++ API, not std/runtime API implementation)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants