Am 24.12.2010 10:41, schrieb spir:
On Thu, 23 Dec 2010 23:18:06 -0600
Andrei Alexandrescu<[email protected]> wrote:
module testmodule;
import std.string : split;
import std.stdio : writeln;
string modulename = split(.stringof)[1];
void main()
{
writeln(modulename);
}
What the... I didn't know you can do that. Thanks for the tip!
What is this syntactic form (".something")? Is there an explicit alternative,
with a prefix?
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
A leading dot means looking up at the module's scope. An explicit prefix
would be the module name but then you're back at hardcoding the
modulename. And stringof is a special property of everything (I think)
which gives you a compile-time string out of it.
Mafi