On Wednesday, 30 May 2018 at 19:34:55 UTC, Steven Schveighoffer wrote:
On 5/30/18 3:05 PM, Daniel N wrote:

void func(NONE...)(string s, NONE, string file = __FILE__, size_t line = __LINE__) if(!NONE.length)
{
     import std.stdio;
     writefln("%s:%d: msg=%s", file, line, s);
}

void main() {func("hello"); func("there");
}

Very cool and interesting pattern. If you now wanted to wrap the function (let's say the caller of this wants to forward it's own called file/line to it), you could do this as well:

func!()("boo", file, line);


Heh, didn't consider that use-case, cool indeed!
How about we name the pattern "You shall not pass"/"None shall pass"? ;)

I still think we should be able to wrap __FILE__ and __LINE__ into another call without having the wrapping take over the file/line combo.

-Steve

Agree, adheres to the Principle of least astonishment.


Reply via email to