Manifest constants: why enum instead of invariant?
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Tue Apr 29 12:41:55 PDT 2008
Don wrote:
> Bruno Medeiros wrote:
>>
>> Around how many bytes are we talking about here, just to get a
>> concrete idea, does anyone know? I'm not familiar with the windows
>> headers nor their D bindings, although I recently checked some of the
>> windows d headers and there were many manifest constants. But I still
>> don't know if their size would amount to something that significant.
>> If for example, you have a cmd line program that prints one page of
>> it's syntax/usage, just that single string would occupy the same space
>> as 400 manifest constants or more.
>
>
> void main() {} --> 79kB exe.
> -------
> import win32.core;
> void main() {} --> 108kB exe.
>
> So it looks like it's less than 32K. Less than 40% of the size of the
> phobos runtime and gc. And a good linker would remove it ALL.
>
It is more than I expected, but I still don't find such size significant
enough.
>
> BTW, I was the one who requested the feature in the first place.
> It was important for template metaprogramming. When you do something
> complicated, the obj files contain masses of compile-time constants. (I
> was experiencing 5Mb obj files where only a single int was used at
> runtime!) It takes ages to save such a large obj file.
> Since you cannot take the address of such constants, there's no reason
> for them to be retained, and I requested that they be discarded from the
> obj file.
>
5Mb!? Well, that's certainly significant enough then. Still the feature
is only valid because the compiler/linker doesn't discard them.
Hopefully in the future that will change, and the compiler won't
generate unnecessary symbols in the first place.
--
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list