In search for a Clojure bencode implentation, I found the following source code.

(defn- decode-list [stream]
  (loop [result []]
    (let [c (char (.read stream))]
      (if (= c \e)
        result
        (recur (conj result (decode stream (int c))))))))

(defn decode [stream & i]
  (let [indicator (if (nil? i) (.read stream) (first i))]
    (cond
     (and (>= indicator 48)
          (<= indicator 57)) (decode-string stream indicator)
          (= (char indicator) \i) (decode-number stream \e)
          (= (char indicator) \l) (decode-list stream)
          (= (char indicator) \d) (decode-map stream))))

(taken from http://nakkaya.com/2009/11/02/decoding-bencoded-streams-in-clojure/)



The example functions do not work for me, because decode tries to call decode-list which tries to call decode.
This leads me to the following questions:
1. What is the (technical) reason the compiler can't just "look up" all functions before using them?
2. What is the standard way or best practice to work around such constructs?


Greetings,
Marcel

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to