On Friday, 21 August 2015 at 05:06:47 UTC, Walter Bright wrote:
This function:

  http://dlang.org/phobos/object.html#.Object.factory

enables a program to instantiate any class defined in the program. To make it work, though, every class in the program has to have a TypeInfo generated for it. This leads to bloat:

  https://issues.dlang.org/show_bug.cgi?id=14758

and sometimes the bloat can be overwhelming.

The solution seems straightforward - only have Object.factory be able to instantiate classes marked as 'export'. This only makes sense anyway.

What do you think?

An alternative which would be more work but wouldn't break code would be to put the "all the classes" structure in a separate section, which is only referenced by Object.factory. Thus, the structure will be GC-ed by the linker, unless Object.factory is actually used somewhere in the program.

Not sure how this would tie in with shared objects though. Maybe this needs to be combined with your "export" idea.

Reply via email to