UDAs and no complaints about "need 'this'"

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Thu Apr 9 02:53:14 PDT 2015


struct BigLongStructName
{
	int evenLongerMemberName;
}

struct QN{}

unittest
{
	BigLongStructName bigLongStructName;

	@(bigLongStructName.evenLongerMemberName)
		QN quickName;
	
	__traits(getAttributes, quickName)[0]++;
}

Is it just me or is it weird that this works? Once you pull the 
UDA out from being a storage class and attempt to alias it, you 
get the usual "need 'this' for 'evenLongerMemberName' of type 
'int'" error messages on use.

Why are UDAs so special? I don't believe there's any other way to 
achieve this sort of effective renaming.


More information about the Digitalmars-d mailing list