const challenge

Jason House jason.james.house at gmail.com
Wed Jan 30 14:09:59 PST 2008


Jason House Wrote:

> 1. Create a usage example that can only be solved by stripping const out, or adopting bad coding practices (global variables?).  I suspect this may bring back old examples about why transitive const is bad.  Please avoid flames such as "const is useless" or "my favorite language does not have const and it's great"


Here's an example I remember seeing posted.  IMHO, it sounds like a rather annoying thing to handle.  It can be solved by stripping out the const references to class A or possibly replacing "executionLog x" with some global variable reference.  I could imagine this being problematic with multi-threaded or other large applications that have distinct logs for different components/threads.

class A{
  version(debug){
    executionLog x;
  }
   ... // includes some writing to log for debugging
}
class B{
  const class A; // can't work while debugging
  ...
}



More information about the Digitalmars-d mailing list