Const sucks

Walter Bright newshound1 at digitalmars.com
Mon Sep 10 15:14:40 PDT 2007


Bruce Adams wrote:
>>> o  So, we still need a method to declare a constant that will not
>>>  consume memory. We'll co-opt the future macro syntax for that:
>>> 
>>> macro x = 3; macro s = "hello";
> I'm not clear why this is even needed. Surely "static const" implies
> some level of don't consume any memory by virtue of meaning
> "available at compile time". If you need more than that, rather than
> trusting the compiler then I second "inline" rather than macro, but
> honestly I can't think of an example where this will give you a
> worthwhile performance gain (unlike an inline function).

windows.h in all its terrifying glory has 10,000 macro declarations. If 
each one occupied 4 bytes of static data, there's 40K of bloat in every exe.



More information about the Digitalmars-d mailing list