Hacker News new | ask | show | jobs
by exprx 3810 days ago
Well, you could always begin another scope with each assignment.

    auto var = // this type can't be inferred because it's not used
    {
      auto var = 2;
    }
I'm too exhausted to think why this may not be applicable.
1 comments

Python:

    x = 2
    if stringy: x = '2'
    print x+x # 4 or 22???
C++:

    int x = 2;
    if(stringy) string x = "2";
    print x+x; // 4 (string x is out of scope)