Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 28, 2014 More Compile-Time Reflection | ||||
---|---|---|---|---|
| ||||
It would be great to have more access to compile time data structures such as struct/class/interface definitions. Data structures for things like method definitions would need to be added. Any thoughts on this? |
February 28, 2014 Re: More Compile-Time Reflection | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Marler | What specifically are you looking for? You can get names, overloads, parameters, return values, and attributes of struct/class methods with reflection today. See __traits(allMembers), etc., and the phobos std.traits module. |
February 28, 2014 Re: More Compile-Time Reflection | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | On Friday, 28 February 2014 at 22:55:54 UTC, Adam D. Ruppe wrote:
> What specifically are you looking for? You can get names, overloads, parameters, return values, and attributes of struct/class methods with reflection today. See __traits(allMembers), etc., and the phobos std.traits module.
See also x.tupleof property which returns a tuple of all the members of x, x being either a struct or class. Typical use
foreach (member; structure_or_class.tupleof)
{
// perform some side-effect with member
}
/Per
|
March 01, 2014 Re: More Compile-Time Reflection | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nordlöw | Nordlöw wrote: > On Friday, 28 February 2014 at 22:55:54 UTC, Adam D. Ruppe wrote: >> What specifically are you looking for? You can get names, overloads, parameters, return values, and attributes of struct/class methods with reflection today. See __traits(allMembers), etc., and the phobos std.traits module. > > See also x.tupleof property which returns a tuple of all the members of x, x being either a struct or class. Typical use > > foreach (member; structure_or_class.tupleof) > { > // perform some side-effect with member > } > > /Per For some examples of extra templates using tupleof, see https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d |
Copyright © 1999-2021 by the D Language Foundation