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

Vector.Unboxed doesn't export constructors, but Unboxed.Mutable does #49

Closed
cartazio opened this issue Oct 16, 2014 · 5 comments
Closed
Milestone

Comments

@cartazio
Copy link
Contributor

I think they should both be exported (or at least I dont see any good reason not to export them)

@Shimuuar
Copy link
Contributor

This stuff is wildly unsafe. One can easily construct invalid vectors and even circumvent memory safety.

evil = V_2 1000 empty empty

Now we have ostensible 1000 element vector and any valid read from vector will read past end of actual array. Same applies to mutable vector though.

I'm not opposed to exporing constuctors but I think they should come with disclaimer: "Very unsafe. Use at your own peril". Internal module maybe?

@cartazio
Copy link
Contributor Author

we already export unsafeIndex and friends, i'm not sure if its much worse than that :)
but yeah, putting it in a .Base or .Internal module (provided we EXPOSE that module) would be totally ok by me :)

@Shimuuar
Copy link
Contributor

With exported constructors we lose memory safety even with safe operations
since we can create violate invariants of vectors of tuples. I however
don't think it's major issue.
13 Ноя 2014 г. 1:46 пользователь "Carter Tazio Schonwald" <
[email protected]> написал:

we already export unsafeIndex and friends, i'm not sure if its much worse
than that :)
but yeah, putting it in a .Base or .Internal module (provided we EXPOSE
that module) would be totally ok by me :)


Reply to this email directly or view it on GitHub
#49 (comment).

@cartazio
Copy link
Contributor Author

well, sure. thats why i'm totally ok with it being only exposed via a .Internal style module rather than by default. I've had to jump through some nasty painful hoops because these constructors arent properly exported though, and I dont care WHAT module they're in, just that I can get to them.

@lehins
Copy link
Contributor

lehins commented Jun 19, 2022

Constructors for unboxed vectors have been exported from Data.Vector.Unboxed.Base from the beginning of time. It is an internal module as it very much should be, but it does not prevent others to shoot themselves in the foot.

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

3 participants