DIPs
DIPs copied to clipboard
Safe by default v2
Please add your name and contact info to the author field. You can remove Walter's.
The DIP does not (explicitly) talk about function pointer and delegate types, especially when those types are used as a function parameter or function return type. With this DIP, which of the following two is the function declaration
void delegate() getCallback();
equivalent to?
void delegate() @safe getCallback() @safe;
or
void delegate() @system getCallback() @safe;
or some third option I could not think of?
With this DIP, which of the following two is the function declaration
void register(void delegate() callback);
equivalent to?
void register(void delegate() @safe callback) @safe;
or
void register(void delegate() @system callback) @safe;
or some third option I could not think of?
I think a more pragmatic step would be to opt in to @safe
per module - @safe module foo;
. That is far more flexible than a preview switch and allows mixing use of safe modules with non safe modules in the same compiler invocation. There are lots of awkward issues with changing the default. By opting in per source file those are avoided.
I need a name and contact info in the Author field, please. Walter's name goes second if you're reusing content from his original DIP.
@ntrel, in which regard would @safe module foo;
be different from module foo; @safe:
?
@ntrel, in which regard would
@safe module foo;
be different frommodule foo; @safe:
?
I'm pretty sure that @safe:
won't make struct or class member-functions @safe
.
I'm pretty sure that
@safe:
won't make struct or class member-functions@safe
.
It does! Unlike @nogc nothrow pure
, which don't propagate through scopes.
@Bolpat @safe:
turns off inference of safety for templates, inferred return type functions and function literals. @safe module foo;
would just change the default safety but not override inference.
@ntrel, I used templates and attributes a lot, but never stumbled on this; wow. Probably because I consider attribute:
harmful for anything except public
and private
.
@skyline131313 I've emailed you recently about moving this into review. Please get back to me when you're ready to move forward.
This will need to show benefit over inference of safety (which it currently does not).