@trusted considered harmful
Jonathan M Davis
jmdavisProg at gmx.com
Sat Jul 28 14:03:06 PDT 2012
On Saturday, July 28, 2012 22:52:32 David Nadlinger wrote:
> Maybe it would be a good idea to also allow
> `@trusted(emplace!S)(mem, cast(S)(*_range).save)`, with semantics
> similar to TRUSTED? Or even applying @trusted to arbitrary
> expressions, similar to `checked` in C#?
Even the cast is unsafe. Basically, that entire line is @system and needs to
be @trusted except for (*_range).save. Attribute inferrence needs to be used
on that portion. So, aside from inventing yet more syntax like
@trusted { emplace!S(mem, cast(S)@infer{(*_range).save}); }
I don't know how you'd avoid the code duplication here. But at least with
@trusted blocks, it can be reduced to a single line rather than having to
duplicate the whole function.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list