D's treatment of values versus side-effect free nullary functions

Walter Bright newshound2 at digitalmars.com
Sat Jul 24 14:28:20 PDT 2010


Andrei Alexandrescu wrote:
> The analysis I discussed is a flow- and path-independent analysis. It 
> always terminates and produces conservative results (i.e. it associates 
> one Boolean with each function, not on each tuple of a function and 
> inputs. This is how the current compiler works - if you tried your 
> example, it will refuse to evaluate foo during compilation.

That's because there's an unrelated bug in it :-( Here's the corrected example:

  import std.c.stdio;

  int foo(int x, int y)
  {
     if (x == 3)
         return y + 1;
     printf("hello\n");
     return 0;
  }

  const z = foo(3, 7);

The compiler does not work as you suggest it does.


More information about the Digitalmars-d mailing list