On Thursday 08 January 2009 01:28, James Reeves wrote:
> On Jan 7, 7:14 pm, "Brian Doyle" <brianpdo...@gmail.com> wrote:
> >    (defn write-bytes
> >      "Writes the bytes from the in-stream to the given filename."
> >      [#^java.io.InputStream in-stream #^String filename]
> >      (with-open [out-stream (new FileOutputStream filename)]
> >        (let [buffer (make-array (Byte/TYPE) 4096)]
> >          (loop [bytes (.read in-stream buffer)]
> >            (if (not (neg? bytes))
> >              (do
> >                (.write out-stream buffer 0 bytes)
> >                (recur (.read in-stream buffer))))))))
>
> Might I suggest that write-bytes be renamed write-stream, or even
> spit- stream? Also it would be useful if it was divided into two
> functions:

Please, no more spitting and slurping. These names are unpleasant. I 
really don't want to think about saliva and ingestion when programming.

As for -bytes vs -stream, Streams operate on bytes in Java. Readers and 
Writers operate on characters. (A schism that never ceases to cause me 
problems in I/O programming..) So I don't think the suffix matters.

However a function that both reads and writes should probably be called 
copy- or transfer-<something>


> ...
>
> - James


Randall Schulz

--~--~---------~--~----~------------~-------~--~----~
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
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