digitalmars.D.bugs - [Issue 23559] New: Add trait to get members from symbol/module with
- d-bugmail puremagic.com (37/37) Dec 15 2022 https://issues.dlang.org/show_bug.cgi?id=23559
https://issues.dlang.org/show_bug.cgi?id=23559 Issue ID: 23559 Summary: Add trait to get members from symbol/module with filtering Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dlang.org Assignee: nobody puremagic.com Reporter: alphaglosined gmail.com 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 --
Dec 15 2022