David Williams
David Williams

Reputation: 8654

Clojure: Require png-extract doesnt work with []'s?

Why does this work:

(ns image-test.core 
    (:gen-class) 
    (:require (png-extract) 
              [clojure.string :as string])) 

but this fails:

(ns image-test.core 
     (:gen-class) 
     (:require [png-extract :as png] 
               [clojure.string :as string]))

I thought [] were always ok in require. Please edify.

Upvotes: 0

Views: 67

Answers (2)

amalloy
amalloy

Reputation: 91857

(:require (png-extract)) is a no-op, "succeeding" by doing nothing. Using parens here means you're starting a prefix list, like (:require (clojure set string)) to require clojure.set and clojure.string; since you don't put any namespaces after the png-extract, it's not requiring anything at all. Using []s is correct, but it's failing because there's something wrong with the png-extract namespace: perhaps it doesn't exist, or is broken in some way.

Upvotes: 2

Arthur Ulfeldt
Arthur Ulfeldt

Reputation: 91534

Here is an example using both forms:

image-test.core> (ns image-test.core
                  (:gen-class)
                  (require [clojure.string :as foo ] 
                           [clojure.string :as string]))
nil
image-test.core> (ns image-test.core
                  (:gen-class)
                  (require (clojure.string)
                           [clojure.string :as string]))

Perhaps something with the png-extract dependency?

Upvotes: 1

Related Questions