Re: transducer (+ closures) efficiency question
As with all discussions involving interoperability, I'd love to see the same questions answered for the JS target too. (This would of course apply to books such as the new Clojure Applied. ) On Jun 24, 2015 9:48 AM, Herwig Hochleitner hhochleit...@gmail.com wrote: 2015-06-24 18:19 GMT+02:00 Ben Wolfson wolf...@gmail.com: I meant a difference in speed. A var-root fetch is a volatile read, which can have several adverse performance effects. Most importantly, it hinders inlining, since the JIT has to place a guard for every inlining site of a volatile read, thus it won't so readily inline. Even when inlined, there must be a memory barrier for the guard, which can lead to pipeline flushes, bus communication and other stalls in execution. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: complex numbers in clojure
Ideally math APIs would be cross-platform #ClojureScript -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
ANN: Cordova-Om Leiningen template
I've created a Leiningen template for Om projects with support for building with Cordova (alias PhoneGap). Core.async and Sablono are included. The template generates a small Hello World app (from a gist by Keith Irwin) which can be built upon. Documenting my process and hoping it's of use to others. I have deployed it to Clojars, so Leiningen will fetch it and use it if you say % lein new cordova-om new-project-name Source is at https://github.com/nodename/cordova-om-template Comments welcome... -A -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Question: Sente and WebSockets and access from external domains
I was hoping to use sente https://github.com/ptaoussanis/sente to provide access to a server endpoint from clients in arbitrary domains, but the sente client explicity prepends its own host to the user-provided endpoint: https://github.com/ptaoussanis/sente/blob/master/src/taoensso/sente.cljx#L764 Since websockets support cross-domain I am wondering if this restriction is necessary and what my options are. Thanks -A -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] Clojure cheat sheet (v13)
Thanks Andy! -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Recruiter claims to be Rick Hickey's sister
Can I get a quick reality check on this? Thanks! -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Recruiter claims to be Rich Hickey's sister
Can I get a quick reality check on this? Thanks! -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Recruiter claims to be Rick Hickey's sister
Great, thanks a lot Robert! On Mon, Dec 2, 2013 at 3:06 PM, Robert Levy r.p.l...@gmail.com wrote: Yes Alan, Jenn Hillner is Rich Hickey's sister. I've worked with her on finding a job before, and highly recommend. -Rob On Mon, Dec 2, 2013 at 2:18 PM, Alan Shaw noden...@gmail.com wrote: Can I get a quick reality check on this? Thanks! -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: How does ! order results from async?
The go block itself (and thus any call to walker) returns a channel. This value is indeed thrown away; its utility lies entirely in the fact that the caller had to wait for it. All of the actual values from the tree are written to the supplied channel 'ch', and the ultimate caller of this function will have to take them from there. I am stupid and recursion is clearly beyond my intellect. Martin Trojer has a great blog post here which I learned a lot from but I don't understand why the final example works: http://martintrojer.github.io/clojure/2013/07/17/non-tailrecursive-functions-in-coreasync/ He offers this as an example of recursively walking a binary search tree: (defn walk [tree ch] (letfn [(walker [t] (go (when t (walker (:left t)) (! ch (:value t)) (walker (:right t)] (go (! (walker tree)) (close! ch and then he writes: This looks promising, but the results in the channel can be in any order (since there are no order guarantees in the scheduling of go processes) – this also means that some of the values might be missing since the “top” go process can be scheduled before a child one. We need a little bit more synchronisation to arrive at a working solution. and then offers this as the final working example: (defn walk [tree ch] (letfn [(walker [t] (go (when t (! (walker (:left t))) (! ch (:value t)) (! (walker (:right t))] (go (! (walker tree)) (close! ch I am confused what this line does: (! (walker (:left t))) It looks like we are pulling a value off channel that's returned from that call to walker? But why? We seem to be throwing this value away? I don't see it being stored anywhere. How does this give us synchronization? -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: How does ! order results from async?
For this value please read the value taken from this channel. On Sep 14, 2013 12:21 AM, Alan Shaw noden...@gmail.com wrote: The go block itself (and thus any call to walker) returns a channel. This value is indeed thrown away; its utility lies entirely in the fact that the caller had to wait for it. All of the actual values from the tree are written to the supplied channel 'ch', and the ultimate caller of this function will have to take them from there. I am stupid and recursion is clearly beyond my intellect. Martin Trojer has a great blog post here which I learned a lot from but I don't understand why the final example works: http://martintrojer.github.io/clojure/2013/07/17/non-tailrecursive-functions-in-coreasync/ He offers this as an example of recursively walking a binary search tree: (defn walk [tree ch] (letfn [(walker [t] (go (when t (walker (:left t)) (! ch (:value t)) (walker (:right t)] (go (! (walker tree)) (close! ch and then he writes: This looks promising, but the results in the channel can be in any order (since there are no order guarantees in the scheduling of go processes) – this also means that some of the values might be missing since the “top” go process can be scheduled before a child one. We need a little bit more synchronisation to arrive at a working solution. and then offers this as the final working example: (defn walk [tree ch] (letfn [(walker [t] (go (when t (! (walker (:left t))) (! ch (:value t)) (! (walker (:right t))] (go (! (walker tree)) (close! ch I am confused what this line does: (! (walker (:left t))) It looks like we are pulling a value off channel that's returned from that call to walker? But why? We seem to be throwing this value away? I don't see it being stored anywhere. How does this give us synchronization? -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Putting in alts! - haven't seen it used
I'm accustomed to using alts! to allow taking from a collection of core.async ports, but haven't come up with a use case for a put in alts!, either with or without takes. Have you? -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Another step towards the Connection Machine in Clojure
A core.async implementation of Per Brinch Hansen, Parallel Cellular Automata (1992): https://github.com/nodename/async-plgd#cellular -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: What's your preference, partial or closures?
I read those. Now I'm screaming :) On Aug 18, 2013 11:40 PM, Ben Wolfson wolf...@gmail.com wrote: Counterpoint! He's not crazy: https://github.com/bwo/monads/blob/master/src/monads/util.clj#L8-43 On Sun, Aug 18, 2013 at 9:20 PM, Sean Corfield seancorfi...@gmail.comwrote: You're crazy :) On Sun, Aug 18, 2013 at 9:04 PM, Chris Allen callen.2...@gmail.com wrote: Am I crazy or does this scream macro? On Saturday, August 17, 2013 6:02:03 PM UTC-7, Sean Corfield wrote: On Sat, Aug 17, 2013 at 5:43 PM, yair yair...@gmail.com wrote: What do you mean by currying in this context? Is there a way to do this in clojure apart from using partial? (defn some-func ([a b c] (process a b c)) ([a b] (fn [c] (some-func a b c))) ([a] (fn ([b] (fn [c] (some-func a b c))) ([b c] (some-func a b c) (some-func 1 2 3) ((some-func 1 2) 3) (((some-func 1) 2) 3) ((some-func 1) 2 3) -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- Ben Wolfson Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure. [Larousse, Drink entry] -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
What's your preference, partial or closures?
(defn newgrid [m initialize qi qj]... and then (let [init (partial newgrid m initialize)]... Or else: (defn newgrid [m initialize] (fn [qi qj]... and then (let [init (newgrid m initialize)]... -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
At Long Last Hoare
The Misc section, containing the Sieve of Eratosthenes and a highly concurrent (and interesting) matrix multiplier, completes my Clojurehttp://twitter.com/search?q=%23Clojure core.async http://twitter.com/search?q=%23coreasync port of the examples from Hoare's 1978 Communicating Sequential Processes paper: https://github.com/nodename/async-plgd -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Yet Moare Hoare
The Philosophers are Dining at https://github.com/nodename/async-plgd/blob/master/src/hoare/monitors.clj Comments, criticisms, corrections are appreciated. -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Confused again by core.async
Hi, I hope I can get a lightbulb on what's happening here: https://github.com/nodename/async-plgd/blob/master/src/hoare/problem.clj Testing fan-in on a pair of processes and getting nutty results. Thanks, -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
core.async: Hoare's coroutine examples in Clojure
These are now working properly and ought to be readable by core.async beginners (I hope). https://github.com/nodename/async-plgd -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: core.async: close! and control channels
The problem I am having is in the function at line 41 of https://github.com/nodename/async-plgd/blob/master/src/hoare/coroutines.clj. Any insight into this is appreciated. -A On Wed, Jul 17, 2013 at 7:23 AM, Timothy Baldridge tbaldri...@gmail.comwrote: True, but I'll mention the semantics of channels once again. Go blocks are attached to channels, and channels exist on their own as values. No where in this entire system is there some global list of channels or go blocks (except for in the executors, but let's not get into that right now). This means that entire chains of gos and channels can be reclaimed by the GC if neither end of the chain is anchored in a GC root. Timothy On Wed, Jul 17, 2013 at 8:17 AM, Laurent PETIT laurent.pe...@gmail.comwrote: 2013/7/17 Timothy Baldridge tbaldri...@gmail.com: It appears that you cannot call close! within a go block and so to signal the end of input to a channel you have to use another channel upon which the receiver can alt!. That's shouldn't be true. What problems did you run into with this? Silly suggestion : maybe the OP is trying to call close! on a channel which is unbuffered, after having put a value. I can imagine, then, that it is only when a consumer has taken the value out of the unbuffered channel, that the producer will be unblocked, and the call to close! will be executed. So maybe using a channel of size 1 may help make the symptom disappear ? And yes, channels and go's are automatically GC'd when they can no longer be access by the system. So these channels/gos get GC'd as fast as they are created. (loop [] (let [c (chan)] (go (! c)) (recur))) Timothy -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: core.async: close! and control channels
Ah, that's put me on the right track. Thanks Timothy! -A On Wed, Jul 17, 2013 at 10:16 AM, Timothy Baldridge tbaldri...@gmail.comwrote: After a channel is closed, any gets (!) from the channel will return nil. I think some part of your code is taking that nil return value and trying to forward it on to a channel. That's what the error is about. Timothy On Wed, Jul 17, 2013 at 11:02 AM, Alan Shaw noden...@gmail.com wrote: The problem I am having is in the function at line 41 of https://github.com/nodename/async-plgd/blob/master/src/hoare/coroutines.clj. Any insight into this is appreciated. -A On Wed, Jul 17, 2013 at 7:23 AM, Timothy Baldridge tbaldri...@gmail.comwrote: True, but I'll mention the semantics of channels once again. Go blocks are attached to channels, and channels exist on their own as values. No where in this entire system is there some global list of channels or go blocks (except for in the executors, but let's not get into that right now). This means that entire chains of gos and channels can be reclaimed by the GC if neither end of the chain is anchored in a GC root. Timothy On Wed, Jul 17, 2013 at 8:17 AM, Laurent PETIT laurent.pe...@gmail.comwrote: 2013/7/17 Timothy Baldridge tbaldri...@gmail.com: It appears that you cannot call close! within a go block and so to signal the end of input to a channel you have to use another channel upon which the receiver can alt!. That's shouldn't be true. What problems did you run into with this? Silly suggestion : maybe the OP is trying to call close! on a channel which is unbuffered, after having put a value. I can imagine, then, that it is only when a consumer has taken the value out of the unbuffered channel, that the producer will be unblocked, and the call to close! will be executed. So maybe using a channel of size 1 may help make the symptom disappear ? And yes, channels and go's are automatically GC'd when they can no longer be access by the system. So these channels/gos get GC'd as fast as they are created. (loop [] (let [c (chan)] (go (! c)) (recur))) Timothy -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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
core.async: close! and control channels
It appears that you cannot call close! within a go block and so to signal the end of input to a channel you have to use another channel upon which the receiver can alt!. Some channels that are not stateful, such as a plain copier, would need no such mechanism. Or would it be good to use such a thing so the channel will get collected? Further, if I want to have a chain of coroutines pipelining data, it would appear that control channels must be threaded through all of them as long as at least one of them must be notified of end of input. Is any of this correct? -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: core.async: close! and control channels
My code is at https://github.com/nodename/async-plgd . Here I reproduce Hoare's coroutines from the CSP paper, and find that none of the examples with pipelined coroutines work reliably. I'd appreciate any advice. On Tue, Jul 16, 2013 at 4:34 PM, Alan Shaw noden...@gmail.com wrote: It appears that you cannot call close! within a go block and so to signal the end of input to a channel you have to use another channel upon which the receiver can alt!. Some channels that are not stateful, such as a plain copier, would need no such mechanism. Or would it be good to use such a thing so the channel will get collected? Further, if I want to have a chain of coroutines pipelining data, it would appear that control channels must be threaded through all of them as long as at least one of them must be notified of end of input. Is any of this correct? -A -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Some docs on comparators, including mistakes to avoid, Clojure extended doc strings
Thumbs up on the comparators doc! On Apr 4, 2013 12:49 PM, Andy Fingerhut andy.finger...@gmail.com wrote: I am seriously considering the idea of working on some extended doc strings for Clojure functions. Having only scratched the surface so far, I have learned that it could take a *lot* of hours to write such documentation for every function distributed as part of Clojure, at least if written in the way I've done so far for compare, sort, and for comparator functions. The document on comparator functions alone might be of interest to a few people. You can read it here: https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md It has a few examples of good comparators, and mistakes to avoid when writing them that I have seen asked about here. I take some inspiration from what I consider to be pretty good documentation for a programming language: Perl. Type man perlfunc in a Linux or Mac OS X shell and you'll see what I mean. Useful examples, corner cases, pitfalls, etc. I like, use, and promote ClojureDocs.org, but I also like the idea of something a bit more curated. I don't have any code yet where you can type an expression in a REPL and get these docs back, but that wouldn't be hard to do. It wouldn't be very useful to implement that until there are a lot more extended doc strings written. I'll announce more later if that happens. I know Rich Morin expressed some interest in a project like this in an earlier thread [1], but if anyone is interested, feel free to contact me privately and we can talk. [1] https://mail.google.com/mail/?shva=1#search/label%3Aclojure+rich+morin/13c5fab22e24cd23 I do have a skeleton of a directory tree with regular predictable names for Markdown-format files for every public symbol in Clojure 1.5.1 (not all checked in to that Github repo yet), using Lee Hinman's lein-clojuredocs to extract that info from it and all other Clojure contrib libraries. Side note: At the end my comparators document has the beginnings of a compare any pair of values comparator mentioned by Mark Engelberg as a wish list item in a message from last November [2]. That version, called cc-cmp, still doesn't work for Clojure sets and maps, but it wouldn't be difficult to extend it to those by sorting the elements/keys and then comparing them as sequences. I suspect it would be best to write a version using multimethods or protocols that could be easily extended by others to additional types, without needing to modify the original code. [2] https://mail.google.com/mail/?shva=1#search/engelberg+compare/13b1e8a3f7f9a59d Andy -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Improving visibility of clojure-doc.org
The ordinary visitor might be forgiven for expecting that both would be found under someplace like Clojure.org... just a thought. -A On Feb 28, 2013 2:04 AM, Michael Klishin michael.s.klis...@gmail.com wrote: 2013/2/28 xavriley i...@xavierriley.co.uk On another note, I wonder whether it's worth clarifying the position of the site in relation to the other Clojure Documentations out there. I've often thought it's a shame to see http://clojuredocs.org/ fall out of regular updates. Having an up to date, searchable reference is one of the best things for a language to have. Is this likely to be rolled into clojure-doc in the future? clojuredocs.org is API reference. clojure-doc.org is guides and tutorials. -- MK http://github.com/michaelklishin http://twitter.com/michaelklishin -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Support for pmap?
Could parallel.js and web workers help? On Feb 25, 2013 6:12 PM, David Nolen dnolen.li...@gmail.com wrote: Not sure how we could given JS is single threaded. On Monday, February 25, 2013, MC Andre wrote: Does ClojureScript support pmap? -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Why is this so difficult?
Leiningen works on Windows. On Feb 15, 2013 8:32 AM, Phil Hagelberg p...@hagelb.org wrote: So for the record, the reason Leiningen doesn't work on Windows is primarily that Windows users spend a lot more time talking about how it doesn't work on Windows, and very little time actually making it work on Windows. It's like some kind of reverse Heisenberg Uncertainty Principle. Just because I am not personally interested in making it work on Windows doesn't mean I'm not open to accepting patches to do so; in fact I *am* interested in making sure motivated parties can contribute to the project. -Phil -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
ANN: Clevolution, evolutionary art in Clojure
Hi folks, My Clevolution project has been reimplemented using clisk, Mike Anderson's Clojure Image Synthesis Kit, greatly improving its speed and range of image-processing operations: http://nodename.github.com/clevolution/ -A -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: ANN: Clevolution, evolutionary art in Clojure
There is one thing that puzzles me: user= (clisk-eval (vround (vround x))) Error: java.lang.IllegalArgumentException: No matching method found: round Could be I'm just holding it wrong. -A On Wed, Jan 2, 2013 at 7:15 PM, Mikera mike.r.anderson...@gmail.com wrote: Cool project! I was hoping someone would manage to use Clisk for some evolutionary art projects. Let me know if you run into any Clisk issues. Evolutionary / generative algorithms are a great way to pressure-test APIs! On Thursday, 3 January 2013 05:58:45 UTC+8, nodename wrote: Hi folks, My Clevolution project has been reimplemented using clisk, Mike Anderson's Clojure Image Synthesis Kit, greatly improving its speed and range of image-processing operations: http://nodename.github.com/**clevolution/http://nodename.github.com/clevolution/ -A -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Little namespace question
Thanks again. This version is easier for my non-macro brain to follow. -A On Wed, Dec 19, 2012 at 8:58 AM, juan.facorro juan.faco...@gmail.comwrote: The following example shows an implementation of *eval-in* as a function. There are a some *println* added to show the namespace where the code is running at each point. ;; (ns another-ns) (defn X [w h] {:w w :h h}) ;; (ns this-ns) (defn eval-in [code ns] (let [orig-ns *ns*] (println *ns*) ; we are in this-ns (in-ns (symbol ns)) (println *ns* (resolve *ns* 'X)) ; not anymore, now it's another-ns (let [ret (eval (read-string code))] (println *ns* (resolve *ns* 'X) ret) ; it's still another-ns but now we have the return value (in-ns (ns-name orig-ns)) (println *ns*) ; back to this-ns ret))) (def generator (X 20 20)) (println (eval-in generator another-ns)) (println (eval-in (X 20 20) another-ns)) ;; Cheers, Juan On Wednesday, December 19, 2012 4:22:58 AM UTC-3, nodename wrote: As an aside, I'm curious about whether this could have been implemented without a macro. -A On Dec 18, 2012 11:06 PM, Alan Shaw node...@gmail.com wrote: Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.f...@gmail.com wrote: The macro sees it arguments as *symbols* and does not resolve to the corresponding *var* until evaluation, so the value for the local *code* var in the macro is actually the *symbol** generator.* The *eval-in* macro uses the *read-string* function to evaluate the code you provide, this function expects a string but it's getting the* **symbol** generator* instead, since that's what the macro got as a first argument. Here's a modified version of the *eval-in* macro, that delays the evaluation of the call to *read-string*: (require '[clojure.pprint :as p]) (defmacro eval-in [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval *(read-string ~code)*)] ; This line was changed (in-ns '~(ns-name *ns*)) ret#))) (p/pprint (macroexpand '(eval-in generator another-ns))) Here's the output: (do (clojure.core/in-ns 'another-ns) (clojure.core/let [ret__1879__auto__ (clojure.core/eval *(clojure.core/read-string generator)*)] ; The unquoting of code resulted in the symbol generator (clojure.core/in-ns 'test-eval) ret__1879__auto__)) If you want to use a var as an argument for the code, you could resolve the var before changing namespaces, delaying the read-string until the forms evaluation: (ns another-ns) (defn X [w h] [w h]) ;--- (ns this-ns (:require [clojure.pprint :as p])) (defmacro eval-in [code ns] `(let [code# ~code] (in-ns '~(symbol ns)) (let [ret# (eval (read-string code#))] (in-ns '~(ns-name *ns*)) ret#))) (def generator (X 300 300)) (p/pprint (eval-in generator another-ns)) Hope it helps, Juan On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote: From yesterday: (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) user= (def generator (X 400 400)) #'user/generator user= (def image (eval-in generator clevolution.version.version0-*** *1-1)) CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1) user= (def image (eval-in (X 400 400) clevolution.version.version0- 1-1)) #'user/image So it's OK to pass the explicit string but not the symbol. What am I not getting here? -A On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw node...@gmail.com wrote: Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.g...@gmail.com wrote: Do you have target ns clevolution.version.version0-1-1 required? -BG On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw node...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw node...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.g...@gmail.com wrote
Re: Little namespace question
Oh! yes it does! -A On Wed, Dec 19, 2012 at 6:39 PM, Dave Ray dave...@gmail.com wrote: It does, right? On Wednesday, December 19, 2012, Alan Shaw wrote: But returning the evaluation was a requirement... On Wed, Dec 19, 2012 at 2:58 PM, Alan Shaw noden...@gmail.com wrote: No, there was no requirement that it be a macro. Thanks! -A On Wed, Dec 19, 2012 at 7:40 AM, Dave Ray dave...@gmail.com wrote: A function seems to work fine unless I don't understand your requirement: ; normal version that takes code forms and symbols (defn eval-in [code ns] (let [old (- *ns* str symbol)] (try (in-ns ns) (eval code) (finally (in-ns old) ; sugary version that takes strings (defn eval-strs [code-str ns-str] (eval-in (read-string code-str) (symbol ns-str))) and now try it out: user= (eval-strs (def z 500) bar) #'bar/z user= (in-ns 'bar) #Namespace bar bar= z 500 Making this bullet-proof and deciding whether it's actually a good design is left as an exercise for the reader. Cheers, Dave On Tue, Dec 18, 2012 at 11:22 PM, Alan Shaw noden...@gmail.com wrote: As an aside, I'm curious about whether this could have been implemented without a macro. -A On Dec 18, 2012 11:06 PM, Alan Shaw noden...@gmail.com wrote: Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com wrote: The macro sees it arguments as symbols and does not resolve to the corresponding var until evaluation, so the value for the local code var in the macro is actually the symbol generator. The eval-in macro uses the read-string function to evaluate the code you provide, this function expects a string but it's getting the symbol generator instead, since that's what the macro got as a first argument. Here's a modified version of the eval-in macro, that delays the evaluation of the call to read-string: (require '[clojure.pprint :as p]) (defmacro eval-in [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval (read-string ~code))] ; This line was changed (in-ns '~(ns-name *ns*)) ret#))) (p/pprint (macroexpand '(eval-in generator another-ns))) Here's the output: (do (clojure.core/in-ns 'another-ns) (clojure.core/let [ret__1879__auto__ (clojure.core/eval (clojure.core/read-string generator))] ; The unquoting of code resulted in the symbol generator (clojure.core/in-ns 'test-eval) ret__1879__auto__)) If you want to use a var as an argument for the code, you could resolve the var before changing namespaces, delaying the read-string until the forms evaluation: (ns another-ns) (defn X [w h] [w h]) ;--- (ns this-ns (:require [clojure.pprint :as p])) (defmacro eval-in [code ns] `(let [code# ~code] (in-ns '~(symbol ns)) (let [ret# (eval (read-string code#))] (in-ns '~(ns-name *ns*)) ret#))) (def generator (X 300 300)) -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Little namespace question
BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw noden...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-1-1, then you need the string something.something.version-0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw noden...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) Warning - I haven't really tested this code. -BG On Tue, Dec 18, 2012 at 12:37 PM, Alan Shaw noden...@gmail.com wrote: Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient
Re: Little namespace question
Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.gh...@gmail.comwrote: Do you have target ns clevolution.version.version0-1-1 required? -BG On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw noden...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw noden...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-1-1, then you need the string something.something.version-0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw noden...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) Warning - I haven't really tested this code. -BG On Tue, Dec 18, 2012 at 12:37 PM, Alan Shaw noden...@gmail.com wrote: Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post
Re: Little namespace question
From yesterday: (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) user= (def generator (X 400 400)) #'user/generator user= (def image (eval-in generator clevolution.version.version0-1-1)) CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1) user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) #'user/image So it's OK to pass the explicit string but not the symbol. What am I not getting here? -A On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw noden...@gmail.com wrote: Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.gh...@gmail.comwrote: Do you have target ns clevolution.version.version0-1-1 required? -BG On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw noden...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw noden...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-1-1, then you need the string something.something.version-0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw noden...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) Warning - I haven't really tested this code. -BG On Tue, Dec 18, 2012 at 12:37 PM, Alan Shaw noden...@gmail.com wrote: Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also
Re: Little namespace question
Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com wrote: The macro sees it arguments as *symbols* and does not resolve to the corresponding *var* until evaluation, so the value for the local *code* var in the macro is actually the *symbol** generator.* The *eval-in* macro uses the *read-string* function to evaluate the code you provide, this function expects a string but it's getting the* **symbol ** generator* instead, since that's what the macro got as a first argument. Here's a modified version of the *eval-in* macro, that delays the evaluation of the call to *read-string*: (require '[clojure.pprint :as p]) (defmacro eval-in [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval *(read-string ~code)*)] ; This line was changed (in-ns '~(ns-name *ns*)) ret#))) (p/pprint (macroexpand '(eval-in generator another-ns))) Here's the output: (do (clojure.core/in-ns 'another-ns) (clojure.core/let [ret__1879__auto__ (clojure.core/eval *(clojure.core/read-string generator)*)] ; The unquoting of code resulted in the symbol generator (clojure.core/in-ns 'test-eval) ret__1879__auto__)) If you want to use a var as an argument for the code, you could resolve the var before changing namespaces, delaying the read-string until the forms evaluation: (ns another-ns) (defn X [w h] [w h]) ;--- (ns this-ns (:require [clojure.pprint :as p])) (defmacro eval-in [code ns] `(let [code# ~code] (in-ns '~(symbol ns)) (let [ret# (eval (read-string code#))] (in-ns '~(ns-name *ns*)) ret#))) (def generator (X 300 300)) (p/pprint (eval-in generator another-ns)) Hope it helps, Juan On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote: From yesterday: (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) user= (def generator (X 400 400)) #'user/generator user= (def image (eval-in generator clevolution.version.version0-** 1-1)) CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1) user= (def image (eval-in (X 400 400) clevolution.version.version0-** 1-1)) #'user/image So it's OK to pass the explicit string but not the symbol. What am I not getting here? -A On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw node...@gmail.com wrote: Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.g...@gmail.comwrote: Do you have target ns clevolution.version.version0-**1-1 required? -BG On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw node...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-**1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw node...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.g...@gmail.com wrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-**1-1, then you need the string something.something.version-**0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw node...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-**1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.g...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code
Re: Little namespace question
As an aside, I'm curious about whether this could have been implemented without a macro. -A On Dec 18, 2012 11:06 PM, Alan Shaw noden...@gmail.com wrote: Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com wrote: The macro sees it arguments as *symbols* and does not resolve to the corresponding *var* until evaluation, so the value for the local *code* var in the macro is actually the *symbol** generator.* The *eval-in* macro uses the *read-string* function to evaluate the code you provide, this function expects a string but it's getting the* ** symbol** generator* instead, since that's what the macro got as a first argument. Here's a modified version of the *eval-in* macro, that delays the evaluation of the call to *read-string*: (require '[clojure.pprint :as p]) (defmacro eval-in [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval *(read-string ~code)*)] ; This line was changed (in-ns '~(ns-name *ns*)) ret#))) (p/pprint (macroexpand '(eval-in generator another-ns))) Here's the output: (do (clojure.core/in-ns 'another-ns) (clojure.core/let [ret__1879__auto__ (clojure.core/eval *(clojure.core/read-string generator)*)] ; The unquoting of code resulted in the symbol generator (clojure.core/in-ns 'test-eval) ret__1879__auto__)) If you want to use a var as an argument for the code, you could resolve the var before changing namespaces, delaying the read-string until the forms evaluation: (ns another-ns) (defn X [w h] [w h]) ;--- (ns this-ns (:require [clojure.pprint :as p])) (defmacro eval-in [code ns] `(let [code# ~code] (in-ns '~(symbol ns)) (let [ret# (eval (read-string code#))] (in-ns '~(ns-name *ns*)) ret#))) (def generator (X 300 300)) (p/pprint (eval-in generator another-ns)) Hope it helps, Juan On Wednesday, December 19, 2012 1:13:00 AM UTC-3, nodename wrote: From yesterday: (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) user= (def generator (X 400 400)) #'user/generator user= (def image (eval-in generator clevolution.version.version0-** 1-1)) CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String, compiling:(NO_SOURCE_PATH:1) user= (def image (eval-in (X 400 400) clevolution.version.version0-* *1-1)) #'user/image So it's OK to pass the explicit string but not the symbol. What am I not getting here? -A On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw node...@gmail.com wrote: Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.g...@gmail.comwrote: Do you have target ns clevolution.version.version0-**1-1 required? -BG On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw node...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-**1-1)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: X in this context, compiling:(NO_SOURCE_PATH:1) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw node...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.g...@gmail.com wrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-**1-1, then you need the string something.something.version-**0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw node...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-**1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.g...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form
Little namespace question
user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Little namespace question
Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Little namespace question
Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.comwrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- László Török -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Little namespace question
Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) Warning - I haven't really tested this code. -BG On Tue, Dec 18, 2012 at 12:37 PM, Alan Shaw noden...@gmail.com wrote: Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- László Török -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Baishampayan Ghose b.ghose at gmail.com -- 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
Re: Little namespace question
Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan, What you're asking for is to derive the ns clojure.core given only core. Not sure if that's possible. The namespace constitutes the whole dotted structure and not just the last component, I am afraid. If the actual ns is something.something.version-0-1-1, then you need the string something.something.version-0-1-1 and not just version-0-1-1 [unless of course you have some other way of deriving it from info that's embedded in _your_ code or structure thereof]. -BG On Tue, Dec 18, 2012 at 1:10 PM, Alan Shaw noden...@gmail.com wrote: Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.com wrote: Alan, Something like this might work for you - (defmacro eval-in Eval a Clojure form in a different namespace and switch back to current namespace. Args: code - Clojure form as string ns - Target namespace as string [code ns] `(do (in-ns '~(symbol ns)) (let [ret# (eval '~(read-string code))] (in-ns '~(ns-name *ns*)) ret#))) Warning - I haven't really tested this code. -BG On Tue, Dec 18, 2012 at 12:37 PM, Alan Shaw noden...@gmail.com wrote: Thanks, Las! Ok say I have a file in which there is string such as (- (atan (bw-noise 902 2 0.7604615575402431 400 400)) (read-image-from-file \images/Dawn_on_Callipygea.png\)) and another version-0-0-1 and I have a namespace version-0-0-1 into which functions named atan etc. are all :referred. I want to evaluate the expression in that particular context, and not remain there when I'm done. -A On Mon, Dec 17, 2012 at 11:00 PM, László Török ltoro...@gmail.com wrote: ah, sorry, it's a bit early for me (in-ns (ns-name user-ns)) if you could post a simple example for the second part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user/user-ns user= user-ns #Namespace user user= (in-ns user-ns) ClassCastException clojure.lang.Namespace cannot be cast to clojure.lang.Symbol clojure.lang.RT$1.invoke (RT.java:226) It appears I'm not understanding how namespaces are represented. Also, is it just wrong of me to want to remember a namespace I was working in and try to go back to it later? The slightly larger context is: I'm saving an s-expression with unqualified names in it into a file as a string. Also saving a string indicating the name of the environment in which that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- László Török -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure
Can't start Rhino repl for ClojureScript
Hi, Any help wd be appreciated; this is what happened (environment is Cygwin on win7): $ lein2 trampoline cljsbuild repl-rhino Running Rhino-based ClojureScript REPL. (do (require (quote cljsbuild.repl.rhino)) (do (clojure.core/ns leiningen.core.injected) (defn- compose-hooks [f1 f2] (fn [ args] (apply f2 f1 args))) (defn- join-hooks [original hooks] (reduce compose-hooks original hooks)) (defn- run-hooks [hook original args] (apply (join-hooks original (clojure.core/deref hook)) args)) (defn- prepare-for-hooks [v] (when-not (:robert.hooke/hook (meta (clojure.core/deref v))) (let [hook (atom ())] (alter-var-root v (fn [original] (with-meta (fn [ args] (run-hooks hook original args)) (assoc (meta original) :robert.hooke/hook hook :robert.hooke/original original))) (defn- add-unless-present [coll f] (if-not (some #{f} coll) (conj coll f) coll)) (defn add-hook \Add a hook function f to target-var. Hook functions are passed the\\n target function and all their arguments and must apply the target to\\n the args if they wish to continue execution.\ [target-var f] (prepare-for-hooks target-var) (swap! (:robert.hooke/hook (meta (clojure.core/deref target-var))) add-unless-present f)) (clojure.core/ns user)) (set! *warn-on-reflection* nil) (do (cljsbuild.repl.rhino/run-repl-rhino) (clojure.core/shutdown-agents))) $ -A -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Leiningen 2.0.0-preview4
Opened issues for both failures, thanks -A On Mon, May 14, 2012 at 2:02 PM, Phil Hagelberg p...@hagelb.org wrote: On Sat, May 12, 2012 at 3:22 PM, Alan Shaw noden...@gmail.com wrote: In cygwin on win7 I get this: Could you open an issue on Github for this? I don't know enough about Windows to say what's going on here, but if it's on the issue tracker there's a better chance of getting it figured out if someone more Windows-savvy can help out. thanks, Phil -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Leiningen 2.0.0-preview4
Having another little problem, any help appreciated: alan@shotwell /cygdrive/c/Workspaces/Clojure-lein $ lein2 new startingclojure Generating a project called startingclojure based on the 'default' template. java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil at clojure.core$_cache_protocol_fn.invoke(core_deftype.clj:495) at clojure.java.io$fn__7795$G__7790__7802.invoke(io.clj:63) at clojure.java.io$reader.doInvoke(io.clj:96) at clojure.lang.RestFn.invoke(RestFn.java:410) at leiningen.new.templates$slurp_resource.invoke(templates.clj:29) at leiningen.new.templates$renderer$fn__709.doInvoke(templates.clj:79) at clojure.lang.RestFn.invoke(RestFn.java:423) at leiningen.new.default$default.invoke(default.clj:15) at clojure.lang.Var.invoke(Var.java:401) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.Var.applyTo(Var.java:518) at clojure.core$apply.invoke(core.clj:602) at leiningen.new$create.doInvoke(new.clj:54) at clojure.lang.RestFn.invoke(RestFn.java:425) at leiningen.new$create.invoke(new.clj:47) at clojure.lang.AFn.applyToHelper(AFn.java:161) at clojure.lang.RestFn.applyTo(RestFn.java:132) at clojure.core$apply.invoke(core.clj:600) at leiningen.new$new.doInvoke(new.clj:101) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:405) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:518) at clojure.core$apply.invoke(core.clj:602) at leiningen.core.main$resolve_task$fn__699.doInvoke(main.clj:66) at clojure.lang.RestFn.applyTo(RestFn.java:139) at clojure.lang.AFunction$1.doInvoke(AFunction.java:29) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:602) at leiningen.core.main$apply_task.invoke(main.clj:88) at leiningen.core.main$_main$fn__731.invoke(main.clj:140) at leiningen.core.main$_main.doInvoke(main.clj:140) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:405) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:518) at clojure.core$apply.invoke(core.clj:600) at clojure.main$main_opt.invoke(main.clj:323) at clojure.main$main.doInvoke(main.clj:426) at clojure.lang.RestFn.invoke(RestFn.java:457) at clojure.lang.Var.invoke(Var.java:413) at clojure.lang.AFn.applyToHelper(AFn.java:172) at clojure.lang.Var.applyTo(Var.java:518) at clojure.main.main(main.java:37) alan@shotwell /cygdrive/c/Workspaces/Clojure-lein $ lein2 version Leiningen 2.0.0-preview3 on Java 1.6.0_31 Java HotSpot(TM) Client VM On Sat, May 12, 2012 at 4:39 PM, John Gabriele jmg3...@gmail.com wrote: On May 12, 7:07 pm, John Gabriele jmg3...@gmail.com wrote: Whoops. Typo: Another important reason for having a good default README.md template specifically for libs is that, at some point, I'm guessing that clojars.org will extract and render them as html, and it will be nice if there's some conventions already in place. s/some conventions/some more conventions/ :) Also, re Sure, that makes sense. Feel free to open an issue and/or pull request on the lein-newnew project for it. Great. Will look into that later tonight. Thanks, ---John -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Leiningen 2.0.0-preview4
Hi, In cygwin on win7 I get this: _ $ lein2 upgrade The script at /cygdrive/c/Users/alan/bin/lein2 will be upgraded to the latest preview version. Do you want to continue [Y/n]? Y Upgrading... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 127 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0Warning: Failed to create the file /tmp/lein-3060-upgrade: No such file or Warning: directory 100 7230 100 7230 0 0 5452 0 0:00:01 0:00:01 --:--:-- 33165 curl: (23) Failed writing body (0 != 7230) $ ls -ld /tmp drwxrwxrwt+ 1 alan root 0 May 12 15:17 /tmp/ --- Not sure what to do... -A On Sat, May 12, 2012 at 1:41 PM, Phil Hagelberg p...@hagelb.org wrote: On Sat, May 12, 2012 at 11:06 AM, John Gabriele jmg3...@gmail.com wrote: After `lein self-install`, when I first ran `lein help` I get this output: https://www.refheap.com/paste/2697. Just a few questions: * What's the Clojure 1.3.0 jar required for if lein is using 1.4.0 internally? Some of the dependencies for the plugin that provides the `new` task declare it, and there's currently no way to prevent these from being fetched. I believe this is also causing 1.3.0 to be active for the repl task. This is a known issue we hope to address in preview5. * Why is it grabbing the Clojure 1.2.1 pom? (though I noticed it does not grab the 1.2.1 jar) There's probably a version range declaration somewhere that's forcing it to examine a number of versions even though it doesn't use them. It has to build a full dependency graph before deciding which version declarations actually win. By the way, I like that you can now pass extra args to `lein new` to create a project of a specific type (such as plugin). What do you think of adding 2 more stock options: application and library? What would the difference between the two be? If it's just a matter of whether there's a :main function then it might be simpler just to have a commented-out line in project.clj. If there are other differences then maybe it would be justified. Note that you can publish your own templates to Clojars, just deploy one as name/lein-template and it will be used when someone runs `lein new name myproject`. -Phil -- 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 patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en