Shouldn't safety be the default.

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Dec 26 08:08:57 UTC 2023


On Tuesday, December 26, 2023 12:05:48 AM MST Hors via Digitalmars-d wrote:
> Optional safety is really outdated, I think some people can't see
> how important is safety almost everywhere (both for system and
> general purpose). Safe by default allows you to catch bugs
> without possibly wrecking your entire system (or systems' of
> users of your app).

As I understand it, the main reason that we've never switched to @safe by
default (aside from concerns over how to do that without breaking everyone's
code) is that code that is extern(C), extern(C++), etc. needs to be treated
as @system by default. So, if we switched to @safe by default for extern(D),
that would then be inconsistent with all of the other linkage types (on top
of whatever extra complications in the compiler that would come with having
different defaults for different linkages).

So, from what I understand, you really don't need to convince Walter or
Atila that @safe by default would be good for D code. Rather, you'd need to
convince them that the inconsistencies that that would cause in the language
would be worth it - particularly when folks who want @safe can slap it on
their code with very little effort.

- Jonathan M Davis





More information about the Digitalmars-d mailing list