On Friday, 24 June 2016 at 03:16:58 UTC, Meta wrote:
On Friday, 24 June 2016 at 03:10:51 UTC, Mike Parker wrote:
Oh, perhaps I misunderstood your question. Do you meant this:
class Foo() {
void bar() { Log(); } // Pass reference to Foo instance
}
void doSomething() { Log(); } // Null reference
If so, the answer is no. And I don't see how that could work
as a compile time parameter, given that the reference itself
is a runtime value.
It actually is possible. You just have to be explicit.
void log(alias self)(string s)
{
pragma(msg, self.stringof);
}
struct Test
{
void test(string s)
{
log!this(s);
}
}
void main()
{
Test t;
t.test("asdf");
}
I don't want to be explicit! One can be explicit with __FILE__
too but one doesn't have to be.
I don't care if it's null.