Re: Using macro to generate part of fn

2010-09-18 Thread Stuart Campbell
> > Macroexpansion is part of the expression evaluation mechanism. In your > example > > >(defn foo > ([bar] (foo bar :default)) > (special-fn-spec)) > > the whole defn-form is macroexpanded first, yielding something like > >(def foo (fn ([bar] (foo bar :default))

Macro closing over atom gives "Can't embed object in code" error.

2010-09-18 Thread Nathan Sorenson
I am playing around with a macro to define accessor functions for a closed-over atom. Here is a simplified example: (defmacro hidden-atom [] (let [a (atom :hello)] `(defn get-value [] (deref ~a When I evaluate this macro, I get the error: "Can't embed object in code, maybe print-dup not

Re: Displaying POSTed string from form text-field in Compojure

2010-09-18 Thread Victor Olteanu
Miki, Thanks a lot - the mystery has been solved. It had to do with the way I was handling the POST route. It seems it needs explicit 'binding' as you mentioned (POST "/" {params :params} (view-output (params "my_datum" or (POST "/" {{a "my_datum"} :params} ...) Thanks again! Victo

Re: lein-daemon problems [RESOLVED]

2010-09-18 Thread ericdwhite
On Aug 7, 2:10 am, Mark Rathwell wrote: > Anyone using lein-deamon and have success getting it working? When trying > to start a daemon with 'lein daemon start daemon-name', I'm getting > java.lang.IllegalArgumentException: > No matching method: with-bindings (daemonProxy.clj:27). The entire erro

Re: lein-daemon problems

2010-09-18 Thread ericdwhite
On Aug 7, 2:10 am, Mark Rathwell wrote: > Anyone using lein-deamon and have success getting it working?  When trying > to start a daemon with 'lein daemon start daemon-name', I'm getting > java.lang.IllegalArgumentException: > No matching method: with-bindings (daemonProxy.clj:27). The entire erro

Re: practical clojure

2010-09-18 Thread Jeff Heon
On Sep 17, 8:23 pm, David J wrote: > I second faenvie's request for "applications of Clojure" books, > especially on AI. AI is the reason I started looking at a Lisp in the > first place. I'd also like to see Clojure become *the* language for > statistics, though I understand that R statistician

Re: what's up with user.clj?

2010-09-18 Thread Kevin Downey
you can also run into issues with things being on the classpath for your project, but not being on the classpath for lein, but user.clj being on the classpath for both, so when lein runs it can't find things your user.clj tries to load On Sat, Sep 11, 2010 at 8:17 AM, Stuart Sierra wrote: > Don't

Displaying source of function typed into the REPL?

2010-09-18 Thread Sean Corfield
OK, this feels like a really dumb question... I'm playing around in the REPL, I type in a function, I use it and continue to work on other stuff... I can't remember what the function looked like and I want to display the source of it again... I know I can go back through the REPL history but mayb

Re: Timed caches?

2010-09-18 Thread Sean Corfield
On Sat, Sep 18, 2010 at 1:12 PM, Eric Lavigne wrote: > It has been built into a library, so you won't need to implement it. > > http://github.com/alienscience/cache-dot-clj Thanx! I saw this mentioned in another thread recently but didn't make the connection with the strategy-based caches. -- Se

Re: Timed caches?

2010-09-18 Thread Eric Lavigne
> It would be great if something like this was built into the standard > libraries... or am I in a minority of users with such requirements? > > At least it gives me some pointers on how to implement timed caches... > It has been built into a library, so you won't need to implement it. http://git

Re: Timed caches?

2010-09-18 Thread Sean Corfield
On Sat, Sep 18, 2010 at 11:00 AM, Wilson MacGyver wrote: > Check out http://kotka.de/blog/2010/03/The_Rule_of_Three.html for a very > flexible implementation of memoiz Very nice. A good illustration of a lot of Clojure features too, especially with the detailed follow-up: http://kotka.de/blog/20

Re: Timed caches?

2010-09-18 Thread gary ng
On Sat, Sep 18, 2010 at 10:40 AM, Sean Corfield wrote: > Since memoize seems to be 'forever' and caching in general smells of > mutable state, I wondered how folks are tackling this sort of thing in > Clojure? Are you simply dropping down to Java libraries and being > 'non-functional' or is there

Re: Timed caches?

2010-09-18 Thread Wilson MacGyver
Check out http://kotka.de/blog/2010/03/The_Rule_of_Three.html for a very flexible implementation of memoiz On Sep 18, 2010 1:40 PM, "Sean Corfield" wrote: Working in the web dev world, I'm fairly used to systems offering ways to cache data for a period of time to improve performance - to reduce

Timed caches?

2010-09-18 Thread Sean Corfield
Working in the web dev world, I'm fairly used to systems offering ways to cache data for a period of time to improve performance - to reduce database traffic, to reduce complex data manipulation. The pattern is pretty much always: if ( thing not in cache ) { do expensive calculation / data loa

Re: disk-backed memoize?

2010-09-18 Thread David McNeil
> http://github.com/alienscience/cache-dot-clj Thanks for the link. That is helpful. > Would JDBC suit your needs as a storage medium? I suppose that would work, but I am thinking that an ehcache based plugin for cache-dot-clj might be a good solution. -David -- You received this message beca

Re: Using macro to generate part of fn

2010-09-18 Thread Konrad Hinsen
On 18 Sep 2010, at 07:15, Stuart Campbell wrote: In the following contrived example, I get an error when macroexpanding (defn foo ...): (defmacro special-fn-spec [] '([bar baz] (println bar baz))) (defn foo ([bar] (foo bar :default)) (special-fn-spec)) The error is: Parameter declarat

Re: Using macro to generate part of fn

2010-09-18 Thread Nicolas Oury
in a (def f [] E), only a E is going to be macro-expanded. (I think the rule of thumb is that macro are only expanded in a position where an expression is.) You can build : (defmacro macro-expanding-defn [name l] ) using a combination of macro-expand, defn and macro? (You can also do a simpler

Re: disk-backed memoize?

2010-09-18 Thread Saul Hazledine
On Sep 18, 3:00 am, David McNeil wrote: > Is there a disk-backed memoize available? I have an application where > I would like the cache of values to survive restarts of the app. > I don't know of one but in the next few weeks I was planning to add memcache functionality to cache-dot-clj to suppo