Skip to content
Compact keyword arguments for clojure
Clojure
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc
src/defk
target
test/defk
.lein-failures
.travis.yml
LICENSE
README.md
project.clj

README.md

Build Status

defk

A Clojure library designed to make keyword arguments not just easier but so much easier in fact that you might just never use anything else again.

Usage

Instead of using defn to define your function, use defk. Now anyone who calls your function gets keyword argument semantics automatically. An example is easier:

(defk foo [a b]
  (- a b))

(let [a 1, b 2]
  (foo b a)) ; <- returns 1 - 2, NOT 2 - 1. How? Because the NAME a and
             ; b are used, not the positions of those variables at the call site

You can of course also pass in the value of variables with other names or literals:

(let [c 2]
  (foo a=1 b=c))

(foo a=(+ 1 2 3) b=2)

The underlying function can be called directly like so:

(foo-raw {:a 1, :b 2})

License

Copyright © 2015 Anders Hovmöller

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

You can’t perform that action at this time.