Arc Forumnew | comments | leaders | submitlogin
4 points by almkglor 6061 days ago | link | parent

> 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 6060 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 6059 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 ?

-----