What is EvalReader?

2010-02-19 Thread timc
The API documentation refers to EvalReader: Quote *read-eval* - var - When set to logical false, the EvalReader (#=(...)) is disabled in the read/load in the thread-local binding. Unquote Is #= an undocumented reader macro character? And what is the EvalReader anyway? It doesn't appeared to be d

Re: Common Lisp's append

2010-02-19 Thread Chouser
On Thu, Feb 18, 2010 at 11:18 PM, Mike K wrote: > Hey Clojurians, > > I'm a Clojure and Common Lisp newbie. I heard that Norvig's PAIP was a > good book to study idiomatic CL code, so I've embarked on a project to > translate the examples to / work the exercises in Clojure.  I hope to > complete t

Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
Hi, I'm having problems with nested syntax-quotes, or something. This works fine: (use 'clojure.contrib.macro-utils) (def *a* nil) ;; good (defmacro my-macro [& body] `(let [name# {#'*a* :new}] (macrolet [(~(symbol 'with-my-macrolet) [& body#] (concat (list

Re: Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
Oh, and so it's not too miserable to understand what my example is doing, it's just binding *a* to :new using with-bindings. ;) I know it looks like a Rube Goldberg way to do it, but it's a distilled, abstract example taken from: http://github.com/tjg/tjg-utils/blob/master/src/tjg-utils.clj#L92

Re: Common Lisp's append

2010-02-19 Thread takasa
Hi Mike, I am also a newbie for Clojure. On 19 February 2010 15:18, Mike K wrote: > Regarding "append" from CL: ISTM that this is similar to "concat" in > Clojure.  I tried the following definition: How about this? user=> (defn append [& parts] parts) #'user/append user=> (append '(a b c) '(d

Re: What is EvalReader?

2010-02-19 Thread Chris Perkins
On Feb 19, 4:32 am, timc wrote: > Is #= an undocumented reader macro character? > Interesting - I had never heard of it either. It appears to allow you to execute code at read-time. user=> (read-string "(foo (+ 2 3) bar)") (foo (+ 2 3) bar) user=> (read-string "(foo #=(+ 2 3) bar)") (foo 5 bar)

Re: What is EvalReader?

2010-02-19 Thread Tayssir John Gabbour
On Feb 19, 1:12 pm, Chris Perkins wrote: > On Feb 19, 4:32 am, timc wrote: > > Is #= an undocumented reader macro character? > > Interesting - I had never heard of it either. It appears to allow you > to execute code at read-time. > > user=> (read-string "(foo (+ 2 3) bar)") > (foo (+ 2 3) bar)

Re: What is EvalReader?

2010-02-19 Thread Adrian Cuthbertson
Have a look at clojure/core_print.clj in the clojure source. It is indeed used with serialization - see print-dup. Here's an example of usage; (import '(java.io File FileWriter PushbackReader FileReader)) (defn rec-save "Save a clojure form to file. Returns the called form." [#^File file frm]

compojure stop server?

2010-02-19 Thread Brian Wolf
Hi, Is there something like a (stop-server) I don't see anything here http://compojure.org/docs thanks Brian -- 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 Note that posts from new memb

Re: compojure stop server?

2010-02-19 Thread David Nolen
Unfortunately most of the examples don't illustrate how to set this is for brevity's sake. In my own code I do the following: (defonce *app* (atom nil)) (defn start-app [] (if (not (nil? @*app*)) (stop @*app*)) (reset! *app* (run-server {:port 8080} "/*" (servl

Re: Emacs/Slime -- Slime wont eval but *inferior-lisp* will (Help a newbie out)

2010-02-19 Thread Phil Hagelberg
On Tue, Feb 16, 2010 at 11:17 PM, joseph hirn wrote: > I do not have a ~/.swank-clojure directory. I do have a swank- > clojure-1.1.0 directory from the swank install via elpa in ~/.emacs.d/ > swank-clojure-1.1.0 but I have tried deleting that manually several > times and reinstalling it via elpa,

Re: Nested syntax-quotes...

2010-02-19 Thread Michał Marczyk
You missed a quote (~name# -> ~'name#); this works fine: (defmacro my-macro [& body] `(let [name# {#'*a* :new}] (macrolet [(~(symbol 'with-my-macrolet) [& body#] `(with-bindings ~'name# ~...@body#))] ~...@body)) Since

Re: newbie question: Please help me stop creating constructors

2010-02-19 Thread Yaron
With this approach how would I test the individual functions defined inside of the let? Wouldn't they be invisible to me and the test framework which would only see "sell-or-rent"? On Feb 18, 4:27 pm, John Williams wrote: > I'm no Clojure guru myself, but one approach you may want to consider is

Re: Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
Hi, On Feb 19, 6:16 pm, Michał Marczyk wrote: > You missed a quote (~name# -> ~'name#); this works fine: > > (defmacro my-macro [& body] > `(let [name# {#'*a* :new}] > (macrolet [(~(symbol 'with-my-macrolet) > [& body#] >`(with-bindings ~'name# >

Random thoughts on c.c.error-kit

2010-02-19 Thread Tayssir John Gabbour
Hi! I've been playing with error-kit, and like a ranting guy on the street I'd like to share random thoughts... * I'll probably come to rely on error-kit, or something like it. Suppose you're playing with nakkaya's distributed computing thingie ¹; you could hook simple listeners to do stuff when

Re: commute misunderstanding

2010-02-19 Thread Аркадий Рост
It seems I have an example that shows difference between commute and alter. Here it is: (defn my-inc [x] (dosync (Thread/sleep 1000) (inc x))) alter*** (def x (ref 0)) (do (def fut (future (do (Thread/sleep 300) (dosync (alter x inc)) @x))) (dosync (println @x)(alter x my-inc)(pr

Re: Clojure function varargs (not Java interop varargs)

2010-02-19 Thread Julien
Thanks Timothy. That did the trick. One small comment below. On Feb 19, 12:11 am, Timothy Pratley wrote: > On 19 February 2010 18:04, Julien wrote: > > > > > Question #1 > > > I want to write a vararg function that does something like this: > > > (map vector [1 2 3] [4 5 6]) > > which yields > >

Canonical method to limit runtime of an evaluation?

2010-02-19 Thread p.bernard
Two Question: 1. Is there a canonical method to limit eval execution time in the REPL. i.e (A method to force a limitation on the number of seconds allowed to evaluate an clojure input resulting in a short circuited exit of the eval request.) 2. Is there a canonical method to limit the execution t

cljaws - wrapper for Amazon Web Service libraries

2010-02-19 Thread Tobias Löfgren
I'm doing some work with Amazon Web Services and have started to build a thin wrapper for the typica and jets3t java-libraries. It is far from complete, but has basic support to do real stuff with SQS, S3 and SDB. http://github.com/ugglan/cljaws Some example usage: ; enqueue the names of all my

ANN: Fleet — templating system

2010-02-19 Thread Ilia Ablamonov
Hello, I would like to announce an implementation of ERB/JSP/etc -like approach for templating with (I really believe) clear and idiomatic syntax and design decisions. Detailed description and code: http://github.com/Flamefork/fleet On Clojars: http://clojars.org/fleet I would appreciate any cr

Re: Common Lisp's append

2010-02-19 Thread takasa
I was totally misunderstood the question. Please ignore my response. Takasa -- 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 Note that posts from new members are moderated - please be patie

Re: newbie question: Please help me stop creating constructors

2010-02-19 Thread John Williams
Right, nesting everything inside a single function makes it impossible to unit test the inner functions--they don't even have names in the global scope! In retrospect, I think the solution I posted is more cute than it is practical. Passing around a map of intermediate values seems to be the winn

Re: can the :test metadata be used to constrain the range of a variable?

2010-02-19 Thread Stuart Sierra
On Feb 17, 6:26 am, Timothy Pratley wrote: > :test can be used to store a unit test (typically for a function) but > you should use clojure.test for writing unit tests, just ignore :test clojure.test uses :test metadata, so it is somewhat compatible. -SS -- You received this message because yo

Re: newbie question: Please help me stop creating constructors

2010-02-19 Thread Yaron
> Looks pretty good to me. I like your use of preconditions and the   > number of tests. I think your indentation is a little deep (I go for   > two spaces, myself), and I never use :Capital keywords, but otherwise   > great. > The indentation was just what the Clojure plugin for Eclipse was set t

Re: newbie question: Please help me stop creating constructors

2010-02-19 Thread Richard Newman
I have to think that's preferable to submitting 30+ arguments to rent and sell. Or were you suggesting a different approach? The different approach only works with a different approach :) The way you've structured run-calculator, using the map is best, because 30 arguments is crazy. Your n

Re: Canonical method to limit runtime of an evaluation?

2010-02-19 Thread Timothy Pratley
On 20 February 2010 07:22, p.bernard wrote: > Two Question: > 1. Is there a canonical method to limit eval execution time in the > REPL.  i.e (A method to force a limitation on the number of seconds > allowed to evaluate an clojure input resulting in a short circuited > exit of the eval request.)

Re: Common Lisp's append

2010-02-19 Thread Baishampayan Ghose
Mike, Finally, can anyone recommend a good free common lisp implementation that runs well with slime / emacs under Windows? SBCL is excellent. So is Clozure CL. Regards, BG -- Baishampayan Ghose -- You received this message because you are subscribed to the Google Groups "Clojure" group. To