Thread overview
Effects of having multiple TypeInfo with the same type name and the future of Object.factory
6 days ago
bauss
6 days ago
Adam D Ruppe
November 22

Hi,
I'm creating this thread to gather insight and better understand how could mangle-prefix 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?

November 22

On 11/22/21 4:42 AM, Ahmet Sait wrote:

>

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?

Object.factory should be deprecated. Anyone using it is in for trouble. It already does not work in some cases.

-Steve

6 days ago

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 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.

6 days ago
On Monday, 22 November 2021 at 09:42:17 UTC, Ahmet Sait wrote:
> What do you think about Object.factory?

Just remove it, this thing is a drain on D.

If you need a runtime factory, it is trivial to register one with reflection. We should probably do a `core.factory` so these things can be centrally registered and provide the helper mixins so you can do custom ones too. Would be far more useful than Object.factory.