We need something like source_location in D

FeepingCreature feepingcreature at gmail.com
Wed Sep 25 07:16:21 UTC 2019

On Tuesday, 24 September 2019 at 15:15:22 UTC, Stefan Koch wrote:
> On Tuesday, 24 September 2019 at 11:32:03 UTC, Jacob Carlborg 
> wrote:
>> On Tuesday, 24 September 2019 at 10:36:53 UTC, guy hebert 
>> wrote:
>>> Have you got the solution.
>> A __traits has been implemented: 
>> https://dlang.org/changelog/2.088.0.html#getloc
>> --
>> /Jacob Carlborg
> Does that solve the issue?
> can it stand in for the caller location?

No - how would you get the caller symbol? It's completely useless 
for this purpose.

Personally I use Fence _ = Fence(), string file = __FILE__, 
size_t line = __LINE__, but that's obviously awkward in that it's 
not composable.

Other things that don't work: void foo(Loc loc = Loc(__FILE__, 
__LINE__)), because __FILE__ and __LINE__ are substituted by 
explicitly checking whether the default value *is that symbol*. 
They cannot be composed. That's why we do need something like 

PS: You should ignore anyone on the topic unless they're linking 
a run.dlang.io with working code.

PPS: https://run.dlang.io/is/B5eK59

More information about the Digitalmars-d mailing list