I give up! I tried to create a reflection library but D's traits are just too screwed up!
drug
drug2004 at bk.ru
Wed Apr 3 10:08:14 UTC 2019
On 03.04.2019 12:35, Alex wrote:
> On Wednesday, 3 April 2019 at 09:24:23 UTC, Atila Neves wrote:
>> On Wednesday, 3 April 2019 at 07:22:10 UTC, Alex wrote:
>>
>>> But D's type system is too screwed up. Fields and members are not
>>> treated as types in and have themselves so
>>
>> I don't know what this means.
>
> One cannot pass a field type around like one can a class. Using Fields
> and FieldsNameTuple does not create a type. This then requires one
> trying to exact the type info by hacking which then requires all kinds
> of tricks that never ultimately succeed. If they do work in one aspect
> they completely breakdown in another.
>
> The BaseReflection class should is supppose to encapsulate getting the
> name, id, module, etc of any base reflected type. Works fine for
> aggregates...
> The moment you try to use it on a field it fails because fields don't
> have a type. Specializing for fields then sends one off in a different
> direction and it fail fails.
>
> I posted all the code for you. It should not be difficult to understand
> and get working with your knowledge about D's meta system.
>
> Simply put the different code snippets in their appropriate modules and
> run. It should work. Note the output and the fields and methods section.
>
> Now try to get the code to fill in the appropriate data for them. That
> is all. It should be an easy task, right? (I have specialized for the
> fields by hacking but the private bug stops it from being general enough)
>
IIUC, the reason is that there are three types of data that frontend
operates on - Types, Symbols and Expressions. Symbols and Expressions
are often used together, so we have two kinds in fact - Types and
Symbols+Expressions. Types processing differs from Symbols processing so
we have this issue you have encountered - Types do not have protection,
for example. You need to check if the entity you worked with is Types or
Symbols and process it accordingly.
More information about the Digitalmars-d
mailing list