Comments (2)
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.
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)
- Add Windows batch scripts for JAR and WASM target HOT 1
- Mutability of `def var` fields in subclasses HOT 3
- Support socket flags/options
- Improve type system and type inference rules HOT 4
- Change system and pointer APIs to pervasively use the `Range` type HOT 2
- Copy/modify initialization expression - `with`?
- Weakening `private` to file scope HOT 4
- Shard testsuite and parallelize
- Support Windows 64 bit
- Most of documentation files seem to be empty HOT 1
- CI Scripts don't report failure properly
- make fails in the virgil folder HOT 6
- Git conflict markers in tests HOT 4
- Exclude code from compilation HOT 2
- Array type init with a negative value. HOT 4
- macos x86_64 11.7.10 build failed HOT 3
- Online documentation
- New PDF URL to one of the research papers HOT 1
- RFC: Choice Types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from virgil.