Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Operating System dependent dispatch of multimethods in clojure

This is me trying out clojure's multimethods for a problem I'm trying to solve. See this Stack Overflow question for follow up.

Note that implementation namespaces are named utils-linux and utils-windows instead of utils.linux and because Gists can't have subdirectories.

(ns main
(:use utils))
(require (case current-os
:linux 'utils-linux
:windows 'utils-windows))
(ns utils)
(def current-os (-> (System/getProperty "")
(defmulti where-am-i
(fn [& _] current-os))
(ns utils-linux
(:use utils))
(defmethod where-am-i :linux
(prn (str "I am running on " (System/getProperty ""))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.