Comment #0 by alphaglosined — 2022-12-15T08:57:04Z
Adding a trait that allows returning alias symbols (like ``__traits(allMembers)``), but filtered for specific properties would allow for cutting down the costs of reflection code and make it more clear what it is doing.
Proposal:
```
__traits(getMembers, symbolOrModuleName, filters)
__traits(getMembersRecursive, symbolsOrModuleName, filters)
```
The difference between these two is one goes down nesting, and the other doesn't (shallow vs deep search).
Filters are in the form of:
``struct | union | class | fields | function | import``
Ideally, this would be an expression so you can do or's and ands to require things like udas. But not required, only need to offer just one option at a time.
Common use cases for this include registration of: web routes, ORM models, CLI handling routines.
Preliminary agreement on worthiness by Walter: https://github.com/dlang/dmd/pull/14699#issuecomment-1352683461
This will require isStatic trait to be added to close https://issues.dlang.org/show_bug.cgi?id=16024
Comment #1 by robert.schadek — 2024-12-15T15:27:42Z