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

Inconsistent behaviour between arr0 and arr1 #1255

Closed
nbro opened this issue Dec 29, 2022 · 1 comment
Closed

Inconsistent behaviour between arr0 and arr1 #1255

nbro opened this issue Dec 29, 2022 · 1 comment

Comments

@nbro
Copy link
Contributor

nbro commented Dec 29, 2022

To create a 0-d array with arr0, we can actually pass an array literal as follows

let a = arr0([0]);

This is ignored because arr0 does not check what is passed or whether it has the correct shape. First of all, I think this is bad. See the related issue: #1253

As you can see, I don't need to pass a reference.

Now, if we attempt to create a 1d, 2d or 3d array with the similar functions, we need to pass the literal by reference, i.e. the following does not compile

let a = arr1([[0], [2]]);

The same happens with arr2 and arr3.

Whether we decide to solve the other issue #1253 or not, in my view, this inconsistency should not exist.

By the way, we can also do

let a = arr0(&[0]);

This inconsistency is due to the fact that arr0 accepts A while the other functions accept &[A], and I suppose we can pass references when we accept A

@bluss
Copy link
Member

bluss commented Mar 20, 2023

0-d is always a special case, so I don't see what the action should be here. A 0-d array is very similar to a scalar, so I think its argument should be a scalar.

@bluss bluss closed this as completed Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants