Skip to content

Instantly share code, notes, and snippets.

@kamisori
Last active August 12, 2020 05:46
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 kamisori/e4e26ad15000959244c6b985742cf258 to your computer and use it in GitHub Desktop.
Save kamisori/e4e26ad15000959244c6b985742cf258 to your computer and use it in GitHub Desktop.
I'm working on a webcomic framework for fun and I ran into the following "compile error: (macro) expected even number of arguments on line 25, column 8" When I comment the non-working version of this (lines 23 - 28) and use one of the working versions which are the same except they don't use the fn shorthand, everything is fine. Tried with: 06c2…
(import hypertext)
(import ./src/data-access :as da)
(import ./src/data-presentation :as dp)
(import ./src/debug :as dbg)
(import sqlite3 :as sql)
#goes to dp when done:
(defn render-contents--works [page-contents]
(defn make-html [content]
(let [image-url (string "/blob/" (content :blobid))]
(hypertext/from-data
~(img {:src ,image-url}))))
(def sorted-contents (sorted-by |($ :position) page-contents))
(map make-html sorted-contents))
(defn render-contents--works-2 [page-contents]
(def sorted-contents (sorted-by |($ :position) page-contents))
(map (fn [content] (let [image-url (string "/blob/" (content :blobid))]
(hypertext/from-data
~(img {:src ,image-url}))))
sorted-contents))
(defn render-contents--doesnt [page-contents]
(def sorted-contents (sorted-by |($ :position) page-contents))
(map |(let [image-url (string "/blob/" ($ :blobid))]
(hypertext/from-data
~(img {:src ,image-url})))
sorted-contents))
@kamisori
Copy link
Author

Originally I ran into this while being behind in 1.11.1 but now I tried with 06c268c274972692611a5ae27881adf5cb447ec3 , doesnt work either

@andrewchambers
Copy link

# compiles
(fn [v] (let [x v] ~{:x ,x}))

# doesn't compile
|(let [x $] ~{:x ,x})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment