Effects of having multiple TypeInfo with the same type name and the future of Object.factory

Ahmet Sait nightmarex1337 at hotmail.com
Mon Nov 22 09:42:17 UTC 2021


Hi,
I'm creating this thread to gather insight and better understand 
how could 
[mangle-prefix](https://github.com/dlang/dmd/pull/13115) changes 
would affect the language.

What are the runtime features that relly on TypeInfo? Comparing 
`typeid(a) == typeid(b)` checks if type names match, what other 
language/runtime features rely on type names?
I've been told that LDC (and GDC) is able to merge TypeInfo 
symbols correctly which means it is possible to compare 
references instead of type names in this case.

What about exceptions? How does exception mechanism interact with 
TypeInfo?

What do you think about Object.factory? It works by iterating 
TypeInfo fields from ModuleInfo and constructs the object if it 
finds one that matches the given type name. This of course breaks 
when there are more than a single type with the same name. Do you 
have a solution in mind to fix it? Also, it is possible to create 
a similar functionality to Object.factory with the existing 
meta-programming machinary so it's of questionable value. How 
would you feel if Object.factory gets deprecated?


More information about the Digitalmars-d mailing list