Discussion Thread: DIP 1028--Make @safe the Default--Final Review
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Fri Apr 3 21:42:36 UTC 2020
On Friday, 3 April 2020 at 09:50:39 UTC, Walter Bright wrote:
> On 3/27/2020 5:32 AM, aliak wrote:
>> So my understanding is if extern (C) is applied on a function
>> declaration, then an annotation is explicitly required?
>
> No. Without an explicit annotation, it will be the default
> (@safe).
That sounds risky, and is exactly the opposite of how Rust
handles extern functions:
https://doc.rust-lang.org/book/ch19-01-unsafe-rust.html#using-extern-functions-to-call-external-code
"Functions declared within `extern` blocks are always unsafe to
call from Rust code. The reason is that other languages don’t
enforce Rust’s rules and guarantees, and Rust can’t check them,
so responsibility falls on the programmer to ensure safety."
Now I'm not suggesting that D should do it because Rust does ;-)
But their reasoning seems sound, and I don't see an obvious
reason for assuming @safe-ty of functions that the D compiler
cannot verify.
More information about the Digitalmars-d
mailing list