DIP 1028---Make @safe the Default---Community Review Round 1

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 9 00:49:29 UTC 2020

On Thu, Jan 09, 2020 at 10:12:23AM +1000, Manu via Digitalmars-d wrote:
> unsafe blocks is distinctly preferable to me. Functions are usually >1
> line, and I hate that we can only mark this at the function level.
> Unsafely statements are never at the function level, it's usually just
> one line among a larger function. An unsafe scope would be immensely
> preferable to me, because I can make it as narrow as the code i'm
> suspicious of, and the surrounding code doesn't lose its safe checking
> just by being a bystander.

There is this current idiom that essentially serves as a @trusted block:

	auto myFunc() @safe {
		... // mundane stuff
		() @trusted {
			// dangerous stuff goes here
		... // more mundane stuff

But it's quite the eyesore, I'll admit.

OTOH, that may be its redeeming quality: it looks so ugly, and is so
icky to write, that it discourages people from overusing it. You're
inclined to do it only when you absolutely have to.


There's light at the end of the tunnel. It's the oncoming train.

More information about the Digitalmars-d mailing list