www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Safety/purity and assert/enforce error messages

Hi all,

Suppose that I want to insert some variable values into an assert error
  The easy way to do this is something like:

     assert(someCondition, text("x = ", x, ", cannot blah blah blah"));

However, the use of text() prevents me from applying  safe and other such 
attributes to the function containing this assert, even though text() will only 
be called in the event of an assertion failure.

Is there any reliable way to include variable values in the error message that 
doesn't interfere with  safe, pure, etc.?  Using to!string has a similar

Thanks & best wishes,

     -- Joe
Sep 12 2013