DIP1028 - Rationale for accepting as is

Mathias LANG geod24 at gmail.com
Sat May 23 06:57:47 UTC 2020


On Friday, 22 May 2020 at 18:24:39 UTC, Atila Neves wrote:
>
> 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);
> }

And this code won't compile at all when you make `@safe` the 
default:

```
void main ()
{
     int[] myArray = (cast(int*) malloc(42 * int.sizeof))[0 .. 42];
}
```

So, we changed the default.

Now those people that want to easily prototype something, or 
write applications that extensively use system libraries, will be 
extremely inconvenienced, but we satisfied the people that want 
more `@safe`ty, which we all known and agree is the future.

Except that in that process we also destroyed the meaning of 
`@safe` by shooting a hole into it, for the convenience of the 
people that want to easily prototype something and write 
applications that interact extensively with system libraries, 
because that's what half of the D users do.

Clearly, an improvement.


More information about the Digitalmars-d-announce mailing list