hasStaticMember and enums

Steven Schveighoffer schveiguy at gmail.com
Tue Sep 22 12:52:19 UTC 2020

On 9/22/20 7:04 AM, Petar Kirov [ZombineDev] wrote:
> I'd say aggregates have 4 different types of members:
> * instance fields and functions
> * static fields and functions
> * enum fields and functions (though enum functions may become regular 
> instance/static functions if https://wiki.dlang.org/DIP27 is accepted).
> * alias-es (a case could be made that from an aggregate user point of 
> view, alias members should be indistinguishable from normal members, but 
> technically they're different, and this could be important for meta code 
> to be able to distinguish. Also there are things like certain types of 
> alias sequences that can't be neither instance, static or enum members.)


On 9/22/20 12:50 AM, Aliak wrote:
> Thoughts: static members are addressable so if you have metà programs that are checking if something is static and then taking the address based on that, those will break. So they are the same in how you access them but not in terms of memory. 

Thanks for all the replies. It looks clear that we can't add enums into 
this trait. We simply need more traits that can figure out the different 
types of members.

So maybe a hasInstanceMember at a minimum (then I can use that to 
distinguish instance members from non-instance ones), and then I don't 
know if we can look further at enum and alias members. For sure alias 
members are odd, I don't know how you would distinguish them from other 

Indeed, in the use case I have, I would treat an alias of another field 
member as another separate field member, even though it points at the 
same field as something else. This would be problematic.

On 9/22/20 7:04 AM, Petar Kirov [ZombineDev] wrote:
> Before a couple of releases you couldn't alias the result of __traits() 
> expressions and mixins (among other limitations), and this code predates 
> those language improvements.

OK, thanks. We should remove that complexity. Would be an easy PR for 
someone to get their feet wet! Just switch from Alias to a standard alias.


More information about the Digitalmars-d mailing list