Skip to content

Instantly share code, notes, and snippets.

@freeeve
Forked from szamuboy/core.clj
Created October 15, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeeve/3893259 to your computer and use it in GitHub Desktop.
Save freeeve/3893259 to your computer and use it in GitHub Desktop.
Evaling an anonymous function with closure
(ns why-is-that.core)
(def test-1 (list (fn [arg]
arg) 1))
;; (eval test-1) -> 1
(def test-2 (list ((fn []
(fn [arg]
['hello arg]))) 1))
;; (eval test-2) -> [hello 1]
(def test-3 (list ((fn [argname]
(fn [arg]
[argname arg])) 'test) 1))
;; (eval test-3) -> IllegalArgumentException No matching ctor found for class why_is_that.core$fn__1971$fn__1972 clojure.lang.Reflector.invokeConstructor (Reflector.java:163)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment