[Issue 17593] __POS__ magical constant like __FILE__ and friends
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jul 4 18:40:11 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17593
Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dlang-bugzilla at thecybershad
| |ow.net
--- Comment #1 from Vladimir Panteleev <dlang-bugzilla at thecybershadow.net> ---
I think such an enhancement could use some more background.
When would you find it useful, and how are the existing tools insufficient to
warrant a change in the language?
Right now, you can use:
- string mixins, i.e.:
Pos pos = mixin(mixPos);
where
enum mixPos = q{ Pos(__FILE__, __MODULE__, __LINE__) };
- The property of __FILE__/__LINE__ etc. that as default arguments, they are
evaluated at the call site:
Pos pos = getPos();
where
Pos getPos(string f=__FILE__, string m=__MODULE__, int l=__LINE__)
{ return Pos(f, m, l); }
- As above, but also for template arguments, not just runtime function
arguments:
Pos pos = currentPos!();
where
enum Pos currentPos(string f=__FILE__, string m=__MODULE__, int l=__LINE__)
= Pos(f, m, l);
(I haven't tested the above, but I think they should work.)
--
More information about the Digitalmars-d-bugs
mailing list