Getting the string representing the enum value ~ Proposal

kris foo at bar.com
Mon Apr 3 12:17:08 PDT 2006


pragma wrote:
> In article <e0pqn7$1ngo$1 at digitaldaemon.com>, kris says...
> 
>>I'll propose that a new property be added, somewhat like the .mangleof 
>>property. Instead, a .nameof property would simply return the lexical 
>>token for the named entity. Doesn't matter whether it refers to a 
>>struct, class, some attribute thereof, enum types or members, whatever 
>>... the x.nameof should just return a char[] of the respective name.
>>
>>Thoughts?
> 
> 
> It gets my vote - but there are a few kinks to work out.
> 
> For instance, how does this compare to .classname or TypeInfo.toString()?

For classes, I think it would be equivalent to .classname (since that 
returns a char[] of the class name). I suspect TypeInfo.toString() is a 
different kettle of fish, since it deals with type information instead 
of names per se?

> 
> I'd imagine that it would follow the same behavior as .mangleof (possibly all
> the way around), with respect to aliases and typedefs.  Templates might be kind
> of sticky though -- any ideas on that?

I think it would, as you say, follow the same behaviour as .mangleof ~ a 
  simple concept with simple rules; Had imagined .nameof would simply 
give you an equivalent name for anything that you can legitimately 
dereference. Regarding templates, does .mangleof do anything unexpected?





More information about the Digitalmars-d-learn mailing list