Pure, Nothrow in Generic Programming

Walter Bright newshound1 at digitalmars.com
Fri Nov 27 11:54:47 PST 2009


dsimcha wrote:
> I think you misunderstood the argument.  memcmp() could be @trusted if functions
> only need to be safe when passed valid parameters, though I don't necessarily
> agree that this makes sense.  I was thinking memcmp() shouldn't even be marked
> @trusted because it's so easy to invoke undefined behavior by passing incorrect
> parameters.  This would mean that, if opCmp() uses it, opCmp() couldn't be marked
> as @safe.

memcmp() could be marked @trusted, but it should not be. This is because 
@trusted functions can be called by @safe ones, but there's no way that 
an @safe function can guarantee it sends memcmp() arguments that will 
work safely with memcmp().

Whoever calls memcmp() can be marked @trusted.



More information about the Digitalmars-d mailing list