@trusted considered harmful
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jul 27 17:21:15 PDT 2012
On Saturday, July 28, 2012 02:08:28 David Nadlinger wrote:
> This is similar to other constructs we have today, for example
> debug {}, which allows impure code. It can be debated whether a
> block »argument« should introduce a new scope or not (like
> static if). The latter currently seems much more attractive to
> me, but I suppose it could be confusing for some.
I'd definitely vote for it _not_ introducing a new scope. It will be much more
useful that way.
> In any case, while there is probably quite a bit of bikeshedding
> to be done for 2), I don't think there is much controversy about
> 1). So, let's try to get this done shortly after the 2.060
> release – as discussed above, it is very unlikely that the
> change will break something, but the odds still increase over
> time. Also, there is currently a Phobos pull request [4] which
> will be influenced by the outcome of this discussion.
I'm all for this. Templates and @trusted just don't get along very well, which
has a huge impact on ranges. The only real saving grace there is that
attribute inferrence solves a lot of the problem if you just never use @safe
or @trusted on a templated function, but when you have to do @system stuff
within such a template, it's a real problem (as RefRange shows).
As for the syntax, I think that @trusted{ /+ at system code+/ } makes perfect
sense.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list