[question] Access from UDA constructor to parent symbol
Jerry via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Dec 27 11:25:27 PST 2016
On Monday, 26 December 2016 at 21:15:03 UTC, Adam D. Ruppe wrote:
> On Monday, 26 December 2016 at 20:07:56 UTC, crimaniak wrote:
>> // I want to see Foo here and use it's reflection to
>> iterate fields and methods.
>
> then pass foo to it....
>
> What do you mean parent symbol? I assumed you mean subclass but
> your example shows one class and one struct. So is it the
> structure containing the class? Or what?
>
>
> But, the answer of just passing the argument is probably the
> best one anyway. You can use a factory function, or pass the
> type from a constructor to a super method, or something like
> that.
I think he wants the symbol that the UDA is attached to.
So instead of doing:
struct attribN(I, T) { }
@attrib1!(Implement1, MyStructName)
@attrib2!(Implement2, MyStructName)
struct MyStructName
{
}
you could instead possibly add a feature to do this:
struct attribN(I, T = __UDA__)
{
}
// or possibly
class attribN(I) : Attribute // Attribute then contains the
symbol its connected to
{
}
@attrib1!Implement1
@attrib2!Implement2
struct MyStructName
{
}
Not likely a feature to be added though.
More information about the Digitalmars-d-learn
mailing list