On Thu, Jul 9, 2009 at 16:43, eyeris<drewpvo...@gmail.com> wrote:
>
> I ran the code you pasted here. It didn't throw an IOException for me.
> I am running 1.0.

I suspect that You're Doing it Wrong.

You'll see the exception only if you actually try to evaluate the lazy
sequence returned by byte-seq.

(import [java.io InputStream FileInputStream])

(defn byte-seq
  [#^java.io.InputStream stream]
  (lazy-seq
    (let [b (. stream (read))]
      (if (>= b 0)
        (cons b (byte-seq stream))))))

(defn most []
  (with-open [st (FileInputStream. "/home/smithma/.bashrc")]
    (drop 5 (byte-seq st))))

(def x (most))  ;; this is OK, it just binds x to the lazy seq
returned by (most)

(first x) ;; not ok, as it tries to get the first element of x, which dies
             ;; since the file we're reading from is already closed.

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

Reply via email to