digitalmars.D - Re: Eliminate assert and lazy from D?
- Jason House <jason.james.house gmail.com> Oct 13 2009
- "Steven Schveighoffer" <schveiguy yahoo.com> Oct 13 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?
Oct 13 2009
On Tue, 13 Oct 2009 08:21:44 -0400, Jason House <jason.james.house gmail.com> wrote: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.
With macros, this can be solved without lazy. I'd say work on getting macros working, then drop lazy and assert. -Steve
Oct 13 2009