[Issue 17593] __POS__ magical constant like __FILE__ and friends

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 5 03:51:40 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17593

b2.temp at gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp at gmx.com

--- Comment #3 from b2.temp at gmx.com ---
I manage to make the feature working with a tuple after a quick hacking
session, with this code that compiles and runs and then displays the expected
result:

====
module runnable;

import std.stdio, std.typecons;

void foo(Tuple!(string, string, int) p = __POS__)
{
    writeln(p);
}

void main(string[] args)
{
    writeln(__POS__[0]);
    writeln(__POS__[1]);
    writeln(__POS__[2]);
    foo();
}
====

actually more can be added to the tuple. (here it's the equivalent of __FILE__,
__MODULE__ then __LINE__) since __PRETTY_FUNCTION__ is also important for
logging.


If DMD people agree on the principle of the feature I'm not against proposing a
PR. Also with a small bounty as motivation if possible.

--


More information about the Digitalmars-d-bugs mailing list