Re: (eval `(def ~(symbol varname) lineseq)

2014-04-28 Thread Carlo Zancanaro
On Mon, Apr 28, 2014 at 06:06:32PM +1000, Peter B. West wrote: > This is the technique used in the old contrib/io.clj read-lines > function, isn't it? That's handy to know. Correct. > Still, Stuart is skeptical about it. I don't think it's a good general solution to the problem, so Stuart's ske

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-28 Thread Peter B. West
On 28 Apr 2014, at 10:57 am, Carlo Zancanaro wrote: > ... > There are other ways to manage resource scope, though. For instance, you > could have your "lazy-lines" function return a lazy-sequence which will > close the file on completely reading the stream: > > (defn lazy-lines [resource] >

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-28 Thread Peter B. West
Thanks Mark, I'll keep that in mind. At this stage I'm just exploring. Peter On 28 Apr 2014, at 1:03 pm, Marc Limotte wrote: > I don't know the details of your particular use, but for a general solution > to the resource management problem, maybe Stuart Sierra's component system > would work

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Marc Limotte
I don't know the details of your particular use, but for a general solution to the resource management problem, maybe Stuart Sierra's componentsystem would work for you. marc On Sun, Apr 27, 2014 at 10:30 AM, Peter B. West wrote: > > On 27 Apr 2014, at

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Carlo Zancanaro
On Mon, Apr 28, 2014 at 12:30:00AM +1000, Peter B. West wrote: > I have no ambitions to solve the general problem; just to find a > workable solution for my own use. What is your own use? Your current solution involves using a shared global variable to communicate between two functions, and tying

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Peter B. West
On 27 Apr 2014, at 7:40 pm, Carlo Zancanaro wrote: > I'm struggling to understand the problem that you're actually trying to > solve. The solution that you are proposing doesn't seem like an elegant > solution to any problem, so could you elaborate on what you're trying to > do? > http://dev.c

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-27 Thread Carlo Zancanaro
I'm struggling to understand the problem that you're actually trying to solve. The solution that you are proposing doesn't seem like an elegant solution to any problem, so could you elaborate on what you're trying to do? On Fri, Apr 25, 2014 at 08:58:42AM -0700, Peter West wrote: > One interesting

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-25 Thread Peter West
I've just managed to get back to this. On Tuesday, 8 April 2014 17:06:31 UTC+10, Carlo wrote: > > On Mon, Apr 07, 2014 at 11:23:31PM -0700, Peter West wrote: > > On Tuesday, 8 April 2014 12:20:16 UTC+10, Carlo wrote: > > > Your issue here is that the symbol "lineseq" in the eval form doesn't >

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-08 Thread Carlo Zancanaro
On Mon, Apr 07, 2014 at 11:23:31PM -0700, Peter West wrote: > On Tuesday, 8 April 2014 12:20:16 UTC+10, Carlo wrote: > > Your issue here is that the symbol "lineseq" in the eval form doesn't > > have a name to refer to. You do have a local binding for lineseq, but > > it's not visible to the eval

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-07 Thread Peter West
Carlo, See below. On Tuesday, 8 April 2014 12:20:16 UTC+10, Carlo wrote: > > On Mon, Apr 07, 2014 at 04:08:03AM -0700, Peter West wrote: > > I'm trying to understand the difference between two alternatives in the > > following code that reads from a resource file. > > > > (defn vcf-res-reader

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-07 Thread Carlo Zancanaro
On Mon, Apr 07, 2014 at 04:08:03AM -0700, Peter West wrote: > 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 >

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-07 Thread Peter West
Thanks for the suggestion, but it doesn't work. With alternative 1, I still get the Unbound error, but I then get the same error with alternative 2. That is, they now both throw the same error. Any other suggestions? On Monday, 7 April 2014 23:21:12 UTC+10, mlimotte wrote: > > To use alterna

Re: (eval `(def ~(symbol varname) lineseq)

2014-04-07 Thread Marc Limotte
To use alternative 1, you need ~lineseq in your eval: (eval `(def ~(symbol varname) ~lineseq)) If you don't unquote lineseq like this, then you are def'ing "cards" to the *symbol* lineseq. When you later access "cards", it is evaluated to returns the symbol lineseq. But since lineseq was a lo