News for hackers. Stuff that matters.
Re:Why I chose Common Lisp over Python, Ruby, and Clojure by zephjc on Wednesday December 02, 2009 @06:36PM (#973300)
IMO, it's generally bad form for a program to be dynamically creating named functions, filling the namespace.

That's what inner functions are for. This isn't the best example, but you get the idea:

  def foo(mylist):
    def n_to_the_n(n):
      if n > 1:
        return n**n
      return 1
    return [n_to_the_n(i) for i in mylist]
Re:Why I chose Common Lisp over Python, Ruby, and Clojure by pwnstigator on Wednesday December 02, 2009 @09:08PM (#973502)
Do the inner functions get cleaned up after you exit the function body?

I'm used to Lisps, where def/defun/define/defn imply internment. For example, in Clojure:

  (defn foo [list]
    (defn n-to-nth [n] (Math/pow n n))
    (map n-to-nth list))
Would intern the symbol 'n-to-nth in the current namespace. So every time I see "def", I think of something that has that (mild, almost always innocuous) side effect.
Re:Why I chose Common Lisp over Python, Ruby, and Clojure by zephjc on Thursday December 03, 2009 @01:33AM (#973856)
The inner function just falls out of scope, and is presumably collected.

  >>> def foo(mylist):
  ...   def n_to_the_n(n):
  ...     if n > 1:
  ...       return n**n
  ...     return 1
  ...   return [n_to_the_n(i) for i in mylist]
  ... 
  >>> print foo([1,2,3,4,5])
  [1, 4, 27, 256, 3125]
  >>> foo
  <function foo at 0x6e5f0>
  >>> n_to_the_n
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  NameError: name 'n_to_the_n' is not defined
  >>>
Note that I only made the inner function longer than necessary for illustrative purposes :-)
Re:Why I chose Common Lisp over Python, Ruby, and Clojure by foldr on Wednesday December 30, 2009 @07:13AM (#1022322)
>I'm used to Lisps, where def/defun/define/defn imply internment. For example, in Clojure:

With regard to 'define', it doesn't work like that in Scheme. A define in a function body behaves just like a let.