Missing introspection? "How exactly this type is actually used"

Ali Çehreli acehreli at yahoo.com
Fri May 20 18:23:47 UTC 2022


On 5/20/22 11:04, Adam D Ruppe wrote:
 > On Friday, 20 May 2022 at 17:45:01 UTC, Ali Çehreli wrote:
 >> What if the user never uses those costly members of that particular
 >> instantiation?
 >
 > If the functions themselves are templates, if they are never used, it
 > will never be instantiated. That's a way you can do this kind of thing.

Interesting. That sounds like a general guideline to all user-defined types.

I think the cost would be multiple compilations of those member function 
instances, N-1 of which could be eliminated by the linker.

The issue with the member variables remains: Currently, there is no way 
of determining that a member variable is used only by a set of member 
function instances that are never generated, meaning that the member 
variable could be eliminated. (For this, we are clearly talking about 
struct and class templates.) But as I understand, the compiler cannot 
see through function interfaces to determine what exactly is used on the 
other side. So we would end up with mismatched types.

Ali



More information about the Digitalmars-d mailing list