On Monday, 26 June 2017 at 04:31:33 UTC, H. S. Teoh wrote:
Yes, the wrong defaults were a historical accident.

One that we could fix, even without breaking any code.

Of course, breaking some code to change it would be fairly straightforward to fix for authors, and could even be done automatically in theory (something like dfix), but there's another solution too: opt in once per module, then change things. Javascript did this to pretty good success with its "use strict" thing.

---
// status quo D
module foo.bar;

@safe void whatever() {}
---

---
// next gen D
module version(3.0) foo.bar; // opt in here
void whatever() {} // now @safe by default
---


The syntax could be whatever, but inside the compiler, when it detects that, it switches around the default for the module. Being opt in means only maintained files get it, but being single point change means it is easy to do.

And since changes like this can easily live side by side with other modules, it provides a simple path forward.


So here's how I'd do it:

1) Add the opposite attributes: `impure`, `throws`, `@gc`, etc.
2) Add the module version thing that changes defaults on request
3) imagine more potential going forward


It isn't even hard.

Reply via email to