On Friday, 22 May 2020 at 18:11:28 UTC, ag0aep6g wrote:
So the DIP itself wasn't good enough to convince you.

Had that been the case, I would have rejected it.

Your reasoning is fine when you're dealing with a function that has a safe interface. I.e., it can only corrupt your code when it's buggy. Then it makes sense so say "I trust the authors". D users do it with Phobos. Phobos authors do it with the C standard library. This kind of trust is perfectly ok. Your reasoning is completely wrong when you're thinking about a function that doesn't have a safe interface. E.g., C's `memcpy` just isn't safe.

memcpy isn't a good example since it's explicitly @system:

https://dlang.org/phobos/core_stdc_string.html#.memcpy

It doesn't matter whether you trust the authors or not. The user has to make sure that the call is correct. Otherwise, `memcpy` will corrupt your memory. And `memcpy` is far from the only such function.

Yes. But most of them aren't like memcpy. Most D code calls other D code, not C.

Am I saying nothing bad can happen if we implicitly trust extern(C) declarations? No. I'm saying we'll be no worse off if they're all implicitly @system.

This compiles with no warnings right *now*:

void main() {
    import core.stdc.stdlib: free;
    free(cast(void*) 42);
    free(new int);
    free(&main);
}



        • Re: DIP10... Steven Schveighoffer via Digitalmars-d-announce
          • Re: D... Atila Neves via Digitalmars-d-announce
            • ... ag0aep6g via Digitalmars-d-announce
            • ... Atila Neves via Digitalmars-d-announce
            • ... Dukc via Digitalmars-d-announce
            • ... Steven Schveighoffer via Digitalmars-d-announce
            • ... Joseph Rushton Wakeling via Digitalmars-d-announce
            • ... Paolo Invernizzi via Digitalmars-d-announce
            • ... Walter Bright via Digitalmars-d-announce
        • Re: DIP10... ag0aep6g via Digitalmars-d-announce
          • Re: D... Atila Neves via Digitalmars-d-announce
            • ... ag0aep6g via Digitalmars-d-announce
            • ... Paul Backus via Digitalmars-d-announce
            • ... Mathias LANG via Digitalmars-d-announce
            • ... Dominikus Dittes Scherkl via Digitalmars-d-announce
  • Re: DIP1028 - Rational... jmh530 via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Timon Gehr via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Adam D. Ruppe via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Atila Neves via Digitalmars-d-announce
  • Re: DIP1028 - Rational... Gregory via Digitalmars-d-announce

Reply via email to