Effects of having multiple TypeInfo with the same type name and the future of Object.factory
bauss
jj_1337 at live.dk
Tue Nov 23 07:02:13 UTC 2021
On Monday, 22 November 2021 at 09:42:17 UTC, Ahmet Sait wrote:
> 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?
The solution is probably going to be core reflection as it'll let
you reflect the correct type for the class you want to
instantiate.
More information about the Digitalmars-d
mailing list