Object.factory() and exe file size bloat

Dmitry Olshansky via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 20 22:12:11 PDT 2015


On 21-Aug-2015 08:06, 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?

+1000 Though I'd kill the whole object factory if I had a chance. It 
looks a lot like Java-woannabe feature that may be better done with 
UDA's and meta-programming (like e.g. run--time type info can be based 
on compile-time one).

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list