On Friday, 28 June 2013 at 13:25:54 UTC, monarch_dodra wrote:
Just because the arguments are known 99% of the time at compile time, doesn't mean they should be parameters. Parameters shouldn't be used to just mean "compile time" anyways, but *specifically* to create different versions of a function or code, which in this case, is not the case at all.

That was probably the idea when templates were conceived of for C++, but I think their usage has evolved far beyond that now, especially in D. With the advent of CTFE, there's an enormous amount that we can do at compile-time, a lot of which isn't strictly related to characterizing a function/struct/class/etc. on a type. Though I suppose it could be argued that with CTFE, doing compile-time template stuff isn't as important.

Besides, there are scenarios where you could pass these as runtime parameters from higher functions, if you want the exception to "look" like it came from a higher level call.

I was just using assertNotThrown as an example to illustrate my point.

Making these parameters would mean that *any* function that handles lines or filenames would have to be parameterized on that.

I don't think there's anything stopping you from passing __FILE__ and __LINE__ as template parameters to some functions, and as function parameters to other functions.

Reply via email to