Is @trusted the wrong direction?
Dominikus Dittes Scherkl
dominikus at scherkl.de
Sat Nov 9 21:13:22 UTC 2019
On Saturday, 9 November 2019 at 20:38:47 UTC, Alexandru Ermicioi
wrote:
> ```d
> import std.stdio;
>
> T trusted (T)(T delegate() @system dg) @trusted {
> return dg();
> }
>
> void main() @safe
> {
> writeln("Hello D");
>
> ({
> writeln("C ", cast(void*) 1);
> }).trusted;
> }
> ```
>
> looks a lot better than anonymous functions that are called
> right away after being defined.
Hmm. Only slightly better syntax, but more important doesn't
solve the other half of the problem: Forbidding non-lambda
trusted functions.
The syntax I would prefer for trusted blocks is simply
@trusted
{
}
And everything between the @trusted and the opening bracket (like
function declarations) would be forbidden.
More information about the Digitalmars-d
mailing list