Unofficial wish list status.(Jul 2008)

Walter Bright newshound1 at digitalmars.com
Mon Jul 21 16:14:49 PDT 2008


Jason House wrote:
> By far, my biggest complaint is that the const system makes only one
> of the following two methods compile.  It forces programmers to
> settle for using global variables to bypass const restrictions.  It
> also touches upon why the purity is required when doing
> multithreading.  I can't fully embrace const until it stops
> encouraging global variables and the gap between purity and const is
> reduced/eliminated.
> 
> =============
  logFile log; class foo{ void bar() invariant{
> log.write("Hello World"); } } ============= class Foo{ logFile log; 
> void bar() invariant{ log.write("Hello World"); } } =============

But the bar() function is not invariant, nor can it be pure if it writes 
things to global state. I am not sure why bar() needs to be pure, but it 
*cannot* be pure if it changes either global state or the state of one 
of its arguments.



More information about the Digitalmars-d mailing list