using with-open to initialize unknown number of readers/writers in Clojure -


say have file used n readers , m writers. when know n , m's value, if n==3 , m==1, write code this:

(use 'clojure.java.io) (with-open [rdr1 (reader file)             rdr2 (reader file)             rdr3 (reader file)             wtr1 (writer file)]     (time-to-work-out-guys)) 

now case is, app user determines values of n , m, have no idea value n , m have. there way still can use with-open initialize readers/writers , job?

because open-with macro instead of function, way build macro generates call open-with , use eval compile @ runtime. while technically answer yes, can't recommend doing so. open-with convenience not fit cases.

in case makes more sense write own (try .... (finally ...)) statement.


Comments

Popular posts from this blog

codeigniter - Fatal error: Call to undefined function lang() in CI Merchant using CardSave -

python - Received unregistered task using Celery with Django -

c# - Delving into the world of XML (Windows Phone) Error I dont understand (The ' ' character, hexadecimal value 0x20, cannot be included in a name.) -