Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
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 Davis


I'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


Re: traits for function having actual source declaration?

2017-09-01 Thread Jonathan M Davis via Digitalmars-d-learn
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



Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn

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


Re: traits for function having actual source declaration?

2017-09-01 Thread ketmar via Digitalmars-d-learn

bitwise wrote:


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.


they *should* listen. anyone who doesn't just aksing for troubles, and i 
see no reason to guard 'em further.


Re: traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn

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.


traits for function having actual source declaration?

2017-09-01 Thread bitwise via Digitalmars-d-learn
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?