Object.factory() and exe file size bloat

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 23 04:05:16 PDT 2015


On Friday, 21 August 2015 at 06:24:34 UTC, Rikki Cattermole wrote:
> On 8/21/2015 5:06 PM, 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?
>
> I need to look over my code that I've written for my to be web 
> application server.
> But: I'm a little concerned that if there is no alternative we 
> won't be able to seriously be able to have a web application 
> server ala JSP servlet style.
>
> So while export may work, perhaps a slightly different 
> approach. If an interface/class is marked as export, it gets 
> inherited. So an child class/implementation would also be 
> export because a super interface/class was export.
> This would make me a lot happier.

I've had a look at it finally. This would definitely effect me.
Since TypeInfo_Class would still need to exist to access .init.

Humpth yes, it would be definitely desirable for me as the 
framework author to say every class that inherits from this 
interface must be visible to me. If it is not it is useless.
Transients would be desired in this use case. That way the 
average developer wouldn't have to worry about this behaviour.


More information about the Digitalmars-d mailing list