I'm trying to understand the difference between two alternatives in the
following code that reads from a resource file.
(defn vcf-res-reader
>
> [res]
>
> (->> res
>
> io/resource
>
> io/reader))
>
>
>> (defn lines-only
>
> [varname prom resource]
>
> (with-open [r (vcf-res-reader resource)
>
> ; alternative 1
>
> ;lineseq (line-seq r)
>
> ]
>
> ; alternative 2
>
> (def lineseq (line-seq r))
>
> (eval `(def ~(symbol varname) lineseq))
>
>
>> @prom))
>
>
>> (defn lazy-lines
>
> [varname prom resource]
>
> (future
>
> (lines-only varname prom resource)
>
> ))
>
>
>
As the code stands, with alternative 2 enabled, the eval setting a named
var to the value of "linseq" works as intended. However, if I disable
alternative 2 and enable alternative 1, and I attempt to access the named
var ("cards" in this case), I get
#<Unbound Unbound: #'vcf.core/cards>
What's going on?
--
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.