On Tue, 11 May 2010 18:31:03 -0700, Paul Rubin wrote: >>> is called an "equation" rather than an "assignment". It declares "x is >>> equal to 3", rather than directing x to be set to 3. If someplace else >>> in the program you say "x = 4", that is an error, normally caught by >>> the compiler, since x cannot be equal to both 3 and 4. >> >> In both ML and Haskell, bindings are explicitly scoped, i.e. >> let x = 3 in ... (Haskell) > > I'm not talking about nested bindings. I'm talking about two different > bindings of the same symbol in the same scope: > > $ cat meow.hs > x = 3 > x = 4 > $ ghc meow.hs > > meow.hs:2:0: > Multiple declarations of `Main.x' > Declared at: meow.hs:1:0 > meow.hs:2:0
It may be worth noting the interactive behaviour: $ ghci GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. Prelude> let x = 7 Prelude> let f y = x + y Prelude> f 3 10 Prelude> let x = 5 Prelude> f 3 10 The main point is that variables aren't mutable state. An important secondary point is that, unlike Python, free (global) variables in a function body are substituted when the function is defined, not when it's called. -- http://mail.python.org/mailman/listinfo/python-list