[Issue 23559] New: Add trait to get members from symbol/module with filtering
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Thu Dec 15 08:57:04 UTC 2022
    
    
  
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 at puremagic.com
          Reporter: alphaglosined at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list