Giter Club home page Giter Club logo

Comments (2)

titzer avatar titzer commented on June 16, 2024

I'm open to designing such a mechanism. One question is what to do with functions/APIs that take Pointer. Technically, the unsafe things being done (like Pointer.atContents, etc) happen in one place, and then an unsafe value is passed through an API. That might imply that functions need an annotation. I'm not sure how to do that with type parameters.

Another way might be to do it file-by-file, either as an annotation at the top, or by forcing the user to specify additional options at the command line. For example, a big bundle of unsafe code is the runtime itself, which is already normally passed in -rt.files=. That would unlock the use of platform-specific features.

from virgil.

k-sareen avatar k-sareen commented on June 16, 2024

I'm open to designing such a mechanism. One question is what to do with functions/APIs that take Pointer. Technically, the unsafe things being done (like Pointer.atContents, etc) happen in one place, and then an unsafe value is passed through an API. That might imply that functions need an annotation. I'm not sure how to do that with type parameters.

Rust accomplishes this in two ways: a function can be annotated as unsafe, so in this case Pointer.atContents will be marked as unsafe; and then if I use Pointer.atContents anywhere in a function I have to use an unsafe-block in order to make the compiler happy, so in this case it'll be unsafe { Pointer.atContents(ptr) }; And while not semantically forced by the compiler or linter, a comment is written above the unsafe-block to explain why the programmer believes the "unsafe" operation is "safe", while for an unsafe function, a /// # Safety rustdoc comment is written to explain when the function should be "safe" to use.

from virgil.

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.