trusted purity?

monarch_dodra monarchdodra at gmail.com
Mon Apr 29 03:58:44 PDT 2013


Is there *any* way to make a call to a non-pure function in a 
pure context, if you know you won't violate your own purity?

This is something you can do with @safe (@trusted), but what 
about pure?

For example, "free" is not pure, because you can't call it twice 
on the same pointer. But if you manage the pointer yourself 
inside a struct, you can guarantee the purity of your own 
functions. But the language won't allow you to do that.

Related question:
Can a function that "sometimes throws" be considered as pure?


More information about the Digitalmars-d mailing list