Use template _d_newclass in TypeInfo_Class.create

Teodor Dutu teodor.dutu at gmail.com
Thu Dec 15 16:34:26 UTC 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`](https://github.com/dlang/dmd/blob/b0cf6b7231124eff79ff320f45659116543e6ad2/druntime/src/rt/lifetime.d#L71-L135).
However, this function is used directly by 
[`TypeInfo_Class.create`](https://github.com/dlang/dmd/blob/b0cf6b7231124eff79ff320f45659116543e6ad2/druntime/src/object.d#L1687-L1702).
`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](https://github.com/dlang/tools/blob/204cc3620270527e186a7fcd0caac658dd5199b4/DustMite/dustmite.d#L829) 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


More information about the Digitalmars-d mailing list