Arc Forumnew | comments | leaders | submitlogin
6 points by parenthesis 6425 days ago | link | parent

As I understand it

  (def foo () nil)
is (roughly) equivalent to

  (= foo (fn () nil))
So, regardless of the context of the (def foo ...), if there isn't a local foo, it's the global foo that is bound to the new function.

To have a local function foo:

  (def foo () nil)

  (def bar ()
    (let foo (fn () t)
      (foo)))
And then

  (bar) -> t
  (foo) -> nil


1 point by tger 6425 days ago | link

Thanks for your reply! My confusion stemmed from the fact that I thought that def behaved like define in Scheme (i.e. establishing a new binding), which apparently was not the case.

-----