ModuleInfo, Object.localClasses(), and Object.find() - any users?

H. S. Teoh hsteoh at qfbox.info
Fri Dec 9 22:35:54 UTC 2022


On Fri, Dec 09, 2022 at 02:20:28PM -0800, Walter Bright via Digitalmars-d wrote:
> Currently, the ModuleInfo struct generated for each module also
> includes a pointer to the ClassInfo for every class in that module.

Wow.  I had no idea such a thing even exists!


> The only reference to this data is in the functions
> Object.localClasses() and Object.find(). The idea is to be able to
> instantiate a class via a text string rather than a link to the name.
> 
> This adds a lot of extra size.
> 
> 1. Does anybody use Object.localClasses() or Object.find() ?

I don't.  Didn't even know they existed.


> 2. Does anybody need them?

Not me.


> 3. Could it be changed to only include the classes marked `export` ?

Sounds like a reasonably safe approach.


> 4. Could we just remove it entirely?

No idea if some D project somewhere out there might use it, so the
spectre of code breakage is there...

But maybe it's possible to make this pay-as-you-go?  I.e., if nobody
actually calls Object.localClasses or Object.find, then it won't be
included.  Only if somebody actually references it, it will be included.
Sorta like a template.  But I've no idea how feasible it is to implement
such a thing.


T

-- 
I am not young enough to know everything. -- Oscar Wilde


More information about the Digitalmars-d mailing list