Code Monkey home page Code Monkey logo

Comments (4)

droundy avatar droundy commented on June 7, 2024 1

I can't think of something better than unsafe. I think unsafe is sometimes used in rust even when memory safety is not at issue (but only correctness). I think that bypassing compile-time guarantees could qualify as unsafe. e.g. interpreting a 32-bit integer as a f32 is unsafe, even though it cannot lead to any memory corruption issues. It's only unsafe because it might give different answers on different architectures. But broadly speaking, dimensioned is preventing precisely the same kind of thing: accidentally treating a value as a different type of value.

from dimensioned.

ExpHP avatar ExpHP commented on June 7, 2024 1

Rust's unsafe keyword is not so much about memory safety as it is about Undefined Behavior, and I feel that this usage of the term cheapens its meaning. I hope you may still consider changing this before an eventual 1.0.

I do not feel there needs to be a single term for this applicable in all contexts; one could call the member value_raw (or to really discourage its use, something unwieldy like internal_value). The phrase "dimensionally unsafe" can be replaced with phrases like "dimensionality is (un-)checked".

Re: integers to floats, f64::to_bits and from_bits (stabilized in 1.20) are unapologetically marked safe. There's a note on the latter that it may or may not mask signalling NaNs... but to my understanding, the question isn't whether or not Rust wants to provide "no signalling NaNs" as a guarantee, but rather, it's because nobody in the community really knows whether LLVM (or other platforms) considers them to invoke UB.

from dimensioned.

paholg avatar paholg commented on June 7, 2024

Unsafe it is!

from dimensioned.

paholg avatar paholg commented on June 7, 2024

Reopening this issue to be considered for the next batch of breaking changes (which will likely be when const generics are a thing).

from dimensioned.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.