Hacker News new | ask | show | jobs
by kazinator 2245 days ago
It's also different from how Common Lisp handles default arguments, and ... how C++ handles default arguments.

This prints

  0
  1

  #include <iostream>

  using std::cout;
  using std::endl'

  int z;

  int foo(int x = z)
  {
    return x;
  }

  int main(void)
  {
    cout << foo() << endl;
    z++;
    cout << foo() << endl;
    return 0;
  }