From 83460cd9d59555067bbdf3bad6ffbf9c06e4aadb Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Sat, 11 Feb 2017 21:16:18 -0800 Subject: [PATCH] Add Lisps and lists README section after issue #8 --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d0066a..aa39568 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,28 @@ your primary classloader. (eval '*clojure-version*) ;; {:major 1, :minor 2, :incremental 0, :qualifier ""} +#### Lisps and lists + +A quick note that can save you from despair. The third parameter to `eval-in` is a quoted list and won't be treated any differently from what we are used to in Lisps. Having said that, if you are closing over something and you use unquote like this: + + (let [list-of-strings (map str (range 10))] + (classlojure/eval-in cl + `(println ~list-of-strings))) + +You shouldn't be surprised by the dreaded `java.lang.String cannot be cast to clojure.lang.IFn`; the first item of the list is indeed a string and not a function as Lisps dictate. + +You need something more sophisticated in order for the above to work: + + (let [list-of-strings (map str (range 10))] + (classlojure/eval-in cl + `(println '~list-of-strings))) + +The order counts here. You first evaluate `list-of-strings` and get a list back which thereafter you quote so that it is not expected to have a function in first position. + ## YourKit YourKit is kindly supporting open source projects with its full-featured Java Profiler. YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products: [YourKit Java Profiler](http://www.yourkit.com/java/profiler/index.jsp) and -[YourKit .NET Profiler](http://www.yourkit.com/.net/profiler/index.jsp). \ No newline at end of file +[YourKit .NET Profiler](http://www.yourkit.com/.net/profiler/index.jsp).