On Wed, 2010-11-17 at 23:21 -0800, Jonathan M Davis wrote: [ . . . ] > Well. yes. enums are definitely tha case for compile time constants. The > question > is for runtime. And why would you suggest immutable over const for runtime?
Why use enums rather than immutable for values that are known at compile time? immutable is really immutable whereas const implies that there is the possibility of change -- at least that is how I read the documentation and TDPL. [ . . . ] > I really don't see any reason why const vs immutable would make any > difference > for a local variable except insofar as a function takes an immutable argument > rather than a const one. I would think that both would be optimized > identically, > but I don't know. I am a fan of single assignment so I put immutable on all my variables except for loop control variables and accumulators. I haven't yet seen a need for const. Interesting, and possibly not irrelevant, side note: In a moment of complete stupidity I spelled immutable as invariant so had code like: invariant n = 1000000000 ; invariant delta = 1.0 / n ; instead of: immutable n = 1000000000 ; immutable delta = 1.0 / n ; and it all worked just fine. I have no idea how or why, but it did! -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
signature.asc
Description: This is a digitally signed message part