From: Paul Rubin on 11 May 2010 21:31 Nobody <nobody(a)nowhere.com> writes: >> 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
From: Alia Khouri on 12 May 2010 04:01 Paul Rubin: > I like learnyouahaskell.com if you want to get some exposure to Haskell, > probably the archetypal functional language these days. I've been > fooling with it on and off for the past couple years. I'm still not > convinced that it's that good a vehicle for practical general purpose > software development, but there are some specific areas where it works > out just beautifully. And in terms of the challenges it presents and > the amount I've learned from it, it's one of the most interesting things > I've done as a programmer in as long as I can remember. It really is > mind altering. Completely agree with you. Learnyouahaskell.com is as good as it gets to learn haskell: haven't had so much fun learning a language since I picked up python :-) For similarly mind-altering pleasure, have a look at pure-lang [http:// code.google.com/p/pure-lang/] which describes itself as: "Pure is a modern-style functional programming language based on term rewriting. It offers equational definitions with pattern matching, full symbolic rewriting capabilities, dynamic typing, eager and lazy evaluation, lexical closures, built-in list and matrix support and an easy-to-use C interface. The interpreter uses LLVM as a backend to JIT- compile Pure programs to fast native code." Enjoy! AK
From: Lawrence D'Oliveiro on 12 May 2010 20:29 In message <pan.2010.05.11.20.07.09.579000(a)nowhere.com>, Nobody wrote: > On Tue, 11 May 2010 23:13:10 +1200, Lawrence D'Oliveiro wrote: > >>> But the beauty is that Python is multi-paradigm ... >> >> The trouble with “multi-paradigm” is that it offends the zealots on >> all sides. > > Is that how you view people who like languages to exhibit a degree of > consistency? Interesting, I never knew “consistency” was a synonym for “faith”... > Some people would prefer to have a manageable set of rules > rather than having to remember the results of all of the possible > combinations of interactions between language features. What are you accusing Python of, exactly?
From: Nobody on 14 May 2010 15:08 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.
From: Chris Rebert on 14 May 2010 15:15
On Fri, May 14, 2010 at 12:08 PM, Nobody <nobody(a)nowhere.com> wrote: > 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 Ahem (emphasis mine): """ ==This syntax is *ghci-specific*== The syntax for 'let' that ghci accepts is not the same as we would use at the âtop levelâ of a normal Haskell program. """ -- http://book.realworldhaskell.org/read/getting-started.html Cheers, Chris -- http://blog.rebertia.com |