2011-01-10 122 views
14

我的命名空間聲明重裝一個命名空間時,看起來是這樣的:獲取IllegalStateException異常在REPL

(ns test.foo 
    (:use 
    [clj-http.client :only (get) :as client] 
    [net.cgrand.enlive-html :only (select) :as html])) 

它工作正常,在REPL,我第一次使用它。然後,當我修改代碼,並嘗試在REPL如下:

(use :reload 'test.foo) 

我得到:

java.lang.IllegalStateException: get already refers to: #'clj-http.client/get in namespace: test.foo (foo.clj:1) 

我與逆時針的窗口,並與leiningen嘗試(雷音REPL)。

回答

9

你不應該不小心影響核心fns。你必須明確你的意圖:

(ns test.foo 
    (:refer-clojure :exclude [get]) ; suppress the shadowing warning 
    (:require [clojure.core :as core]) ; allow to still reach clojure.core/get through core/get 
    (:use 
    [clj-http.client :only (get) :as client] 
    [net.cgrand.enlive-html :only (select) :as html])) 
+0

非常感謝Christophe。我想我不能期望比Clojure高手更好地回答我的問題; o) – Damien 2011-01-10 17:14:17

相關問題