Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: