Does immutable class memeber needed to be marked as 'static'?
HOSOKAWA Kenchi
hskwk at inter7.jp
Fri Aug 7 12:58:39 PDT 2009
I'm just migrating to shared, and I have some questions to switch static variables to immutable.
I'm confused about how to treat 'static immutable' class members and function local constants which is determined at compile time or 'static this'.
According to "Const and Immutable" article, it seems that immutable value requires only single memory instance which is able to be referenced from anywhere, any class instance, any threads or any function in any stack.
Put all of them into a ROM, yep!
But wait, here is function local immutable which seems not to be in a ROM.
'static immutable' class members may have single memory instance, so that they seem not to need 'static' marking.
Function local constants, on the other hand, may need to be marked as 'static immutable' or 'invariant' if we need unique value among all threads.
I'm not confident about them, so please let me know how to treat them.
More information about the Digitalmars-d-learn
mailing list