Fork me on GitHub
#ring-swagger
<
2018-04-18
>
adc1703:04:33

I’ve been reading through the following page from the compojure-api wiki, and I’m confused by a few things. https://github.com/metosin/compojure-api/wiki/Creating-your-own-metadata-handlers 1. What are let/letk bindings, and what is the difference between them? I can’t find an explanation anywhere in the wiki. 2. How is the vector passed into :let/:letk/:middleware/etc. used by compojure-api? I know that it’s probably going to be macro-expanded, but beyond that it’s unclear how the arg is processed. 3. Why in the example is the _ arg re-used in the method body? Isn’t _ a convention for when an arg is unnecessary? I suspect that once I understand let/letk bindings better, this will all become clearer, but answers to any of the above would be appreciated.

miikka07:04:57

1. letk/fnk/defnk bindings is explained here: https://github.com/plumatic/plumbing/tree/master/src/plumbing/fnk (it talks only about defnk, but letk uses the same syntax)

adc1715:04:57

@U1NDXLDUG in that link, defnk is a way of assigning args to vars in a function by passing them as :var arg. But that’s pretty much already how let bindings function…“let left-val equal right-val”. So what’s the difference in the context of a let binding?

miikka15:04:54

The destructuring syntax is different from the standard one

adc1716:04:25

Ok, I was confused by the use of function definitions. So instead of (let [{:keys [foo]} foo-map]) with a letk binding you could just do (let [foo foo-map]).

miikka07:04:02

(don't know about 2/3)