Unsafe evolution #9705
Replies: 4 comments 23 replies
-
What about the |
Beta Was this translation helpful? Give feedback.
-
Besides the one There are various practices that disallow |
Beta Was this translation helpful? Give feedback.
-
These documents should be captured in the conversation:
The second doc gets a bit at "levels of safety". |
Beta Was this translation helpful? Give feedback.
-
First I need to say that I agree with the overall effort to indicate clearly, and consistently, what methods have the "standard safety guarantees" and which do not, and to give users the ability to track (and restrict) sources of unsafety in their programs. This could be a great feature that helps users understand how careful they need to be in using certain features, beyond just the scope of pointers. However, I think the solution to annotate "everything" in .NET with
This is an issue because it means that actually So my first idea: ditch Embrace Now the practical part ‒ I like the introduction of If // Can't put `unsafe` just around the base interface
interface IThing : IEnumerable<void*[]>; // So maybe referencing a pointer type would not require `unsafe` anymore? class Base
{
// Maybe `unsafe` not required anymore even with pointer parameters?
public unsafe Base(int* x) {}
}
class Derived : Base
{
// Can't put `unsafe` just around the base call... but what if the base constructor is `[RequiresUnsafe]` but the derived one should not be?
public Derived(IntPtr ptr) : base(Convert(ptr))
{
}
static unsafe int* Convert(IntPtr ptr) => (int*)ptr;
} It is my understanding of the proposed new meaning of the This kind of removing a feature just to replace it with a similar-looking one only to have to come up with ways of filling the holes that action have caused reminds me of a certain children's tale, where the family bought a Christmas tree, but they noticed it was a bit flat on one side, as if missing a branch. So they drilled a hole inside the trunk there, cut a branch from another side, and inserted it in the hole. But then they noticed it was flat on the side where they cut the branch, so they sawed off another branch and shoved it into a newly drilled hole there. When they were finally happy, someone accidentally shook the tree and all the branches fell off. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Discussion topic for unsafe evolution.
Champion issue: #9704
Beta Was this translation helpful? Give feedback.
All reactions