ELisp doesn't support closures
posted by hitesh on 2008-07-19
I'm hacking some ELisp functions recently and I realize that ELisp doesn't have a filter function or support closures. That's disappointing. One sort of takes it for granted nowadays that a decent language will have both. AFAIK ELisp was written before there was a Common Lisp standard. But even then, I'm surprised it didn't evolve with the times.
I don't mind writing my own filter function since I'm only going to have to do it once. But not having closures is a little bigger impact.
Instead of being able to write something like this ...
(defun string-match-c (s)
(lambda (x) (string-match s x)))
I'll have to write this instead.
(defun string-match-c (str)
(lexical-let ((s str))
(lambda (x) (string-match s x))))
Usage is the same for both.
(filter (string-match-c "ba") '("foo" "bar" "baz"))
;; => ("bar" "baz")
But they really can't compare to Haskell, which doesn't need a string-match-c function defined since it supports partial application.
filter (isPrefixOf "ba") ["foo", "bar", "baz"]
Emacs is still my favorite editor, but I sure wish it was using Common Lisp, Scheme or Haskell.
Resources
Referrers
- http://www.artima.com/forums/flat.jsp?forum=123&thread=235029
- http://www.google.com/reader/view/
- http://del.icio.us/gerd.storm?url=http%3A%2F%2Fwww.jasani.org%2F2008%2F07%2F19%2Felisp-doesnt-support-closures&title=ELisp%20doesn%27t%20support%20closures&v=4
- http://search.live.com/results.aspx?q=string
- http://search.live.com/results.aspx?q=string&form=QBHP
- http://www.artima.com/buzz/community.jsp?forum=123
- http://www.artima.com/buzz/index.jsp
- http://www.google.ca/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=elisp+closures&btnG=Search&meta=
- http://www.google.co.uk/search?q=closures+elisp&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a
- http://www.google.com
About
Hitesh wrote his first program on a punch card in 1979 ... he's been debugging it ever since.