What can be done to reduce executable size?
Sean Kelly
sean at invisibleduck.org
Fri Dec 16 11:07:14 PST 2011
On Dec 16, 2011, at 11:04 AM, Andrei Alexandrescu wrote:
> On 12/16/11 12:40 PM, Jonathan M Davis wrote:
>> On Friday, December 16, 2011 11:45:42 Andrei Alexandrescu wrote:
>>> I am pretty sure they don't need static this(). Only last night I
>>> removed static this() from core.time.
>>
>> I don't know how you could do that in core.time, since ticksPerSec and
>> appOrigin are immutable and have to be set at runtime. How on earth can you do
>> that without a static constructor?
>>
>> std.datetime has the same problem with the added fun of having to avoid
>> breaking purity, because the functions for getting the singletons are pure.
>
> This goes back to the issue of lazy initialization. Today you need a cast to do that. Here's my code:
>
> static @trusted @property long ticksPerSec() pure nothrow
> {
> return (cast(immutable(long) function() pure nothrow) &ticksPerSecImpl)();
> }
This is fine, but the whole point of static ctors in D is to eliminate all the stupid workarounds required to use statics in C++. I'd much rather we find a way to make the use of static ctors more efficient than give up on the feature.
More information about the Digitalmars-d
mailing list