Safety/purity and assert/enforce error messages
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Sep 12 14:39:42 PDT 2013
On Thu, Sep 12, 2013 at 11:37:10PM +0200, Joseph Rushton Wakeling wrote:
> On 12/09/13 22:23, Jonathan M Davis wrote:
> >You can put the try-catch in a version(assert) block to get around
> >that problem, but it is true that it's not exactly ideal. However,
> >there really isn't any way around that with a function that takes a
> >format string unless you want it to ignore bad arguments. You'd need
> >a function like text which just appends all of its arguments together
> >in order to get around that problem.
>
> Well, I have been using text() to generate my assert error messages,
> but the trouble is that (at least in 2.063) it's not @safe, pure or
> nothrow ... :-(
Even in git HEAD, text() may still throw.
So ultimately, you still need assumeWontThrow:
https://github.com/D-Programming-Language/phobos/pull/1571
:)
T
--
Some days you win; most days you lose.
More information about the Digitalmars-d-learn
mailing list