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::uninitialized() #804

Closed
bluss opened this issue Apr 18, 2020 · 6 comments
Closed

Remove Array::uninitialized() #804

bluss opened this issue Apr 18, 2020 · 6 comments

Comments

@bluss
Copy link
Member

bluss commented Apr 18, 2020

It now has a replacement. See previous issue #685

If 0.14.0 comes quickly after 0.13.1, probably start with just deprecating the method

@bluss bluss added this to the 0.14.0 milestone Apr 18, 2020
@bluss
Copy link
Member Author

bluss commented Apr 19, 2020

Possibly put maybe_uninit in its place (rename it)

@bluss
Copy link
Member Author

bluss commented Jan 25, 2021

uninitialized is hard to use correctly. I haven't removed it yet because I think I have managed to put it on sound ground - it is technically possible to use it correctly. See issue #804 and issue #876 (we have just completed removing all internal usage of this method).

Unfortunately ArrayBase::uninitialized:

  1. Has some usage by actual users - it's a basically popular and easy to use (github code search confirms)
  2. This usage is from casual inspection almost always technically incorrect

The conclusion is that deprecation will have impact on users, but we need to do it, and need to make maybe_uninit easy to use.

@xd009642
Copy link
Contributor

Now I'm wondering how incorrect my usage in ndarray-vision is 😅

@bluss
Copy link
Member Author

bluss commented Jan 25, 2021

Our uninitialized was added before stronger rules crystallized. It had been said (earlier) that let x = std::mem::uninitialized(); *(&mut x) = 1.0; would probably be correct when the type was copy - however that as also been judged as incorrect now eventually (creating a reference to uninit), so there are not many easy ways to use it left - short of using the raw views (partly why they were introduced). Yes, your code breaks this rule (as did ours before the next version - and a few versions back, Rust std was also sometimes breaking this rule).

@bluss
Copy link
Member Author

bluss commented Jan 25, 2021

See also #796 (A lot of progress has been made on that issue).

@bluss
Copy link
Member Author

bluss commented Mar 15, 2021

Deprecated by #902, so this issue is now fixed. But it will be finally removed in the next release.

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

No branches or pull requests

2 participants