D thinks it is OK to mess around with TypeInfo

Yuxuan Shui via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Mar 4 13:35:45 PST 2016


For example

struct A{}
@safe void main(){
	import std.stdio;
	A a, b;
	auto y = typeid(a);
	y.name = "Nope, I'm not A";
	auto x = typeid(b);
	writeln(x);
}

Make changes to TypeInfo will affect all the future typeid() 
results! And D is OK with that?

IMO, TypeInfo returned by typeid() should be immutable.


More information about the Digitalmars-d-learn mailing list