define should be the keyword for manifest constants

Steven Schveighoffer schveiguy at yahoo.com
Thu Dec 13 13:33:34 PST 2007


"Janice Caron" wrote
> On 12/13/07, Steven Schveighoffer wrote:
>> How would the compiler know when compiling a module with a constant 
>> whether
>> some other module is going to take the address of that constant?
>
> You're thinking old-school. D is new-school. Imports don't just import
> symbols, they import abstract symbol trees. Saying "How would the
> compiler know when compiling a module with a constant whether some
> other module is going to take the address of that constant?" is like
> saying "How would the compiler know whether a template needs to be
> instantiated?". The point is, it doesn't need to - it just exports the
> AST.

OK, so what is the big deal then?  Why do we need manifest constants?  I 
assume this is a problem because we are talking about fixing it.  I was 
assuming that Jason's proposed solution (the compiler decides when to have 
manifest constants and when to have addressable constants) was impossible, 
and that the reason it is good to have manifest constants is because 
otherwise the compiler creates space for all non-manifest constants.  Is 
this not the case?  If not, why have a difference between manifest constant 
declarations and normal constant declarations?

And if I'm not mistaken, import imports source code, just like #include 
included header files...

-Steve





More information about the Digitalmars-d mailing list