News for hackers. Stuff that matters.
Re:Why Hy? by vegai_ on Tuesday May 03, 2022 @03:40PM (#31252568)
Is there any non-horror piece of code where supporting this latter case would be useful?
Re:Why Hy? by m55au on Tuesday May 03, 2022 @03:47PM (#31252657)
It is not a particularly good example. A better one would be

    a = 1
    def foo():
      x = a
      a = 2
    foo()

    > UnboundLocalError: local variable 'a' referenced before assignment
Basically a name cannot be both global and local inside the same function. Otherwise it would be a total mess.

"a = a" just means assign the value of local variable "a" to a local variable "a", so the error makes sense.