Arc Forumnew | comments | leaders | submitlogin
-1 points by applepie 6030 days ago | link | parent

Because "=" is confusing and encourages the use of global variables.

IMHO, Arc got scope wrong, mixing definition with assignment. Didn't we learn from Python? (i.e. it's sad to see the same mistakes once and again).



4 points by almkglor 6030 days ago | link

> Didn't we learn from Python? (i.e. it's sad to see the same mistakes once and again).

Eh? What mistake? THe only mistake I see in Python is the difficult anonymous function syntax and lack of Lisp macros.

-----

1 point by applepie 6028 days ago | link

  def make_counter():
    x = 0
    def inc():
      x = x + 1
      return x
    return inc

  c1 = make_counter()
  c1() # returns 1
That's Python.

It might seem nice at first glance :)

But... oops! it doesn't work.

It doesn't work because the "x" in "x = x + 1" is _not_ the same "x" as in "x = 0".

And that happens because definition and assignment are badly mixed up.

-----

4 points by almkglor 6028 days ago | link

...and? The equivalent (and correctly running!) Arc code is:

  (def make-counter ()
    (let x 0
      (fn ()
        (= x (+ x 1)))))
So... why do you want to avoid 'let ?

-----

3 points by skenney26 6030 days ago | link

Recently I've been thinking alot about scope and would be interested in hearing you expound on what Python and Arc got wrong.

-----

1 point by bOR_ 6029 days ago | link

Isnt' the massive use of global variables not something that is only for newbies?, and from which you learn what is bad about it by experience?

in which case it is no longer a problem for most of us ;)

-----