Eliminate assert and lazy from D?

Jason House jason.james.house at gmail.com
Tue Oct 13 05:21:44 PDT 2009


Andrei Alexandrescu Wrote:
> 
> It's simpler actually:
> 
> debug void assert(T)( T expr, string delegate() msg ) {
>      if(!expr)
>          throw new Exception(msg);
> }
> else void assert(T)( T delegate(), string delegate() ) {
> }
> 
> Hm, actually it's more complicated than your version :o).
> 
> 
> Andrei



You should be throwing AssertError

I really like lazy for log messages and asserts. I like the implicit cast to (scope) pure delegate idea. It works well in those contexts.

How hard would it be to use a library assert in ctfe context?



More information about the Digitalmars-d mailing list