www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - enum, immutable or const for run-time constants?

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
What's the preferred way of declaring run-time constant values in 
D from the point of view of

1, compile-time performance
2. run-time performance
3. code-size
4. load-time
5. locality of reference module global or function global (static)
Jan 26 2015
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Mon, 26 Jan 2015 20:04:58 +0000, Nordl=C3=B6w wrote:

 What's the preferred way of declaring run-time constant values in D from
 the point of view of
=20
 1, compile-time performance 2. run-time performance 3. code-size 4.
 load-time 5. locality of reference module global or function global
 (static)
`const`/`immutable` is going to binary. `enum` is not. so it you don't=20 need it in memory, use `enum`.=
Jan 26 2015