Re: Get parent function of nested delegate

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 16, 2025 12:38:09 AM MDT Anonymouse via Digitalmars-d-learn wrote: > I want to get a reference to a parent function from inside a > nested function. I need it for `getUDAs!(parentFunction, > attribute)`. > > `__traits(parent, mixin(__FUNCTION__))` works inside the parent > func

Re: Get parent function of nested delegate

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 17, 2025 6:28:19 PM MDT Jonathan M Davis via Digitalmars-d-learn wrote: > On Sunday, February 16, 2025 12:38:09 AM MDT Anonymouse via > Digitalmars-d-learn wrote: > > I want to get a reference to a parent function from inside a > > nested function. I need it for `getUDAs!(parentF

Re: Get parent function of nested delegate

2025-02-16 Thread Inkrementator via Digitalmars-d-learn
On Sunday, 16 February 2025 at 07:38:09 UTC, Anonymouse wrote: How can I make this work? As a workaround, you can define a useless symbol and get the parent of that. ``` module foo; void bar(string s, int i) { assert(__FUNCTION__ == "foo.bar"); alias parentModule = __traits(parent, m

Get parent function of nested delegate

2025-02-15 Thread Anonymouse via Digitalmars-d-learn
I want to get a reference to a parent function from inside a nested function. I need it for `getUDAs!(parentFunction, attribute)`. `__traits(parent, mixin(__FUNCTION__))` works inside the parent function and gives me the module, but `mixin(__FUNCTION__)` alone inside the nested function immed