Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Clojure why use :only []

Tags:

clojure

The source for lazy-xml has the following:

(:use [clojure.xml :as xml :only []]
      [clojure.contrib.seq :only [fill-queue]])

What is the purpose of using clojure.xml but listing nothing for the :only arguments?

like image 265
Andrew Avatar asked Oct 16 '11 17:10

Andrew


1 Answers

Notice the :as xml which when combined with the :only [] seems to make that line equivalent to (:require [clojure.xml :as xml]). That style might be useful if you want to copy some vars into the local namespace (i.e., a non-empty :only), but allow the rest of that namespace to be explicitly aliased via :as. Since that's not what he's doing, it really should just be a :require.

like image 173
Alex Taggart Avatar answered Sep 25 '22 21:09

Alex Taggart