How to check if an array is a manifest constant?

Jonathan M Davis jmdavisProg at gmx.com
Sun Apr 3 17:33:23 PDT 2011


On 2011-04-03 17:25, bearophile wrote:
> Jonathan M Davis:
> > But there should be no need to worry about whether something is a
> > manifest constant or not.
> 
> I'd like in DMD a way to know if something is a compile-time constant.
> There is a GCC extension that sometimes is able to do it, named
> __builtin_constant_p:
> http://www.delorie.com/gnu/docs/gcc/gcc_81.html#IDX629

To what end? Why would you care? It matters whether a value is mutable, const, 
or immutable, but what does it matter if it was calculated at compile time or 
not? Unless it's a property, it's definitely going to have been calculated 
before you use it. The only reason that I see that it matters at the moment is 
due to bugs in dmd. Once those are fixed, it should be irrelevant.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list