digitalmars.D.learn - traits for function having actual source declaration?
- bitwise (4/4) Sep 01 2017 When I'm using __traits(allMembers), I get a all the invisible
- bitwise (5/9) Sep 01 2017 dlang's "Lexical" page says:
- ketmar (3/12) Sep 01 2017 they *should* listen. anyone who doesn't just aksing for troubles, and i...
- bitwise (3/6) Sep 01 2017 Yeah...eventually came to the same conclusion ;)
- Jonathan M Davis via Digitalmars-d-learn (10/14) Sep 01 2017 You can use std.meta.Filter if you need to filter anything out of an
- bitwise (17/27) Sep 01 2017 I'm working on a runtime reflection library, so there won't be
When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?
Sep 01 2017
On Friday, 1 September 2017 at 14:38:38 UTC, bitwise wrote:When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?dlang's "Lexical" page says: "Identifiers starting with __ (two underscores) are reserved." So I suppose I could just filter out functions with leading underscores, but still seems unreliable, as people may not listen.
Sep 01 2017
bitwise wrote:On Friday, 1 September 2017 at 14:38:38 UTC, bitwise wrote:they *should* listen. anyone who doesn't just aksing for troubles, and i see no reason to guard 'em further.When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?dlang's "Lexical" page says: "Identifiers starting with __ (two underscores) are reserved." So I suppose I could just filter out functions with leading underscores, but still seems unreliable, as people may not listen.
Sep 01 2017
On Friday, 1 September 2017 at 17:26:11 UTC, ketmar wrote:[...] they *should* listen. anyone who doesn't just aksing for troubles, and i see no reason to guard 'em further.Yeah...eventually came to the same conclusion ;) Thanks
Sep 01 2017
On Friday, September 01, 2017 14:38:38 bitwise via Digitalmars-d-learn wrote:When I'm using __traits(allMembers), I get a all the invisible functions added by the compiler as well "__ctor", "__xdtor", "__cpctor", etc.. Is there a way to filter them out?You can use std.meta.Filter if you need to filter anything out of an AliasSeq like this, and whether you should be filtering out those functions is highly dependent on what you're doing - e.g. sometimes, you really want to get your hands on __ctor, whereas other times, that's not at all what you're looking for. But because it gives you everything, you have a choice, whereas if they were filtered out, then any code that needed to know about them would be screwed. - Jonathan M Davis
Sep 01 2017
On Friday, 1 September 2017 at 18:06:04 UTC, Jonathan M Davis wrote:[...] You can use std.meta.Filter if you need to filter anything out of an AliasSeq like this, and whether you should be filtering out those functions is highly dependent on what you're doing - e.g. sometimes, you really want to get your hands on __ctor, whereas other times, that's not at all what you're looking for. But because it gives you everything, you have a choice, whereas if they were filtered out, then any code that needed to know about them would be screwed. - Jonathan M DavisI'm working on a runtime reflection library, so there won't be any access to the actual type. Any access to constructors will have to be done through an interface like these: class Struct : Reflection { size_t size() const; void construct(void[] mem); } class Class : Reflection { Object createInstance() const; } The library is basically done, but needs polishing. Also, I'm stuck waiting for things like __traits() being allowed to bypass protection, which was recently decided upon, but not yet implemented (hopefully this hasn't been overturned again). Thanks
Sep 01 2017