Thread overview
Use template _d_newclass in TypeInfo_Class.create
Dec 15, 2022
Teodor Dutu
Dec 15, 2022
Vladimir Panteleev
Dec 15, 2022
rikki cattermole
December 15, 2022

Hi,

I am trying to convert _d_newclass to a template function.
With this, I aim to remove the old hook from rt.lifetime.d.
However, this function is used directly by TypeInfo_Class.create.
TypeInfo_Class.create cannot call the template hook because it doesn't have access to the explicit type, only to its typeid.

Being a public function, TypeInfo_Class.create can be called by user code and simply deleting it or changing it to a template as well will most likely break existing code.
For example, it will break this line in DustMite.

I think the only thing I can do is to leave the old hook in rt.lifetime.d for now as it will only be used by TypeInfo_Class.create. Then I'll remove it in the future if TypeInfo_Class.create or TypeInfo itself become deprecated.

How do you say I should proceed with this? Do you see a way to use the template _d_newclass inside TypeInfo_Class.create?

Thanks,
Teodor

December 15, 2022

On Thursday, 15 December 2022 at 16:34:26 UTC, Teodor Dutu wrote:

>

How do you say I should proceed with this? Do you see a way to use the template _d_newclass inside TypeInfo_Class.create?

I recall there was a recent-ish addition which allowed getting a type using its mangleof string. Perhaps that could be a way?

December 16, 2022
Delete it.

We are in the process of getting rid of Object.factory which would utilize this.

Code like Dustmite can create a method that you override to instantiate a new instance. This isn't end of the world.
December 15, 2022

On 12/15/22 11:34 AM, Teodor Dutu wrote:

>

How do you say I should proceed with this? Do you see a way to use the template _d_newclass inside TypeInfo_Class.create?

No, but that's just the price you pay for using TypeInfo to create classes.

Leave the function, the major goal here is to remove the link from the compiler to the old hook. Library solutions can do whatever they want.

-Steve