On Saturday, 16 April 2016 at 00:03:59 UTC, Jonathan M Davis wrote:
Yes, you can do that, but do _not_ do that unless you really have no other choice. What you need to realize is that because the file and line number arguments will be unique for every call to this function, it will generate a new instantiation of it _every_ time it is called. So, you're going to get a lot of code bloat. There are rare cases where such bloat would be acceptable, but in the general case, it's a terrible thing to do. This particular case might be acceptable given how short it is, but in general, using __FILE__ or __LINE__ as template arguments should be avoided like the plague.

yeah I know that but there is really no other way in this case because of the varargs. Also because of the varargs the function will be different most of the time when always passing different arguments. There should be some "give me location of caller" keyword in D

Also, to nitpick your exact implementation, debug blocks and assertions aren't even vaguely related. debug blocks are used with the -debug flag with the intention of being used for printing out additional debug information (and getting around restrictions with pure with those messages while you're at it). They have nothing to do with -release, which is what controls assertions. What you really want to be doing is to use version(assert), not debug.

right, makes sense because there is a release with assertion flags.


Reply via email to