Re: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread jarppe


On Sunday, December 16, 2012 9:57:26 PM UTC+2, Jonathan Fischer Friberg 
wrote:

 I don't know why it doesn't work. However, changing defgreeter to the 
 following seems work.

 (defmacro defgreeter [greeter-name]
   (let [greeter (make-greeter)]
 `(def ~greeter-name ~greeter)))
  

Might be a clue. :)


Strange. That is definitely a clue, but for what? :)

-- 
-jarppe

-- 
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: How to structure a Clojure day for noobs?

2012-12-17 Thread Marko Topolnik


 I think, however, that there is a risk of a disconnect, where newcomers 
 don't really grasp that there is a JVM running and that code is actually 
 compiled and injected into it, and that it's for real. They are used to 
 mickey mouse interactive tools that don't provide the real thing, and 
 struggle to bridge the apparent gap between running code in the REPL and 
 properly compiling and running files. There is no gap, but one needs to 
 explain that, I think.


I think this is a pivot point for everything in Clojure. The harder the 
mental switch, the more important to make it right away. Without 
understanding that, it will be very hard to maintain a clear picture of how 
everything fits together, especially when you start changing functions and 
reloading them. 

-- 
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: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread Ben Smith-Mannschott
Your macro:

 *(*~greeter user-name#*)*

*
*

Is producing a list of a function or closure followed by a symbol. The
first element of the list your macro builds must instead be an expression
that can be evaluated to a function. (For example a symbol naming a
function or an (fn [] ...) expression.)

Ben


On Sunday, December 16, 2012, jarppe wrote:

 Hi,

 I have this macro (complete file https://www.refheap.com/paste/7633):

 *(*defmacro defgreeter [greeter-name]

   *(*let [greeter *(*make-greeter*)*]

 `*(*do

*(*defn ~greeter-name [user-name#]

  *(*~greeter user-name#*)**)**)**)**)*


 It works as expected when make-greeter is defined like this:

 *(*defn make-greeter []

   *(*fn [user-name]

 *(*str Hello,  user-name*)**)**)*


 I can use it like this:

 *(*defgreeter hello*)*

 *(*hello jarppe*)*

 How ever, if I change make-greeter to this I get IllegalArgumentException:

 *(*defn make-greeter []

   *(*let [message hello]

 *(*fn [user-name]

   *(*str message ,  user-name*)**)**)**)*


 Interestingly, this does not work either:

 *(*defn make-greeter []

   *(*constantly what erver*)**)*

 What am I missing?

 --
 -jarppe

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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: Running a clojure script

2012-12-17 Thread Shantanu Kumar


On Monday, 17 December 2012 00:23:08 UTC+5:30, puzzler wrote:

 On Sun, Dec 16, 2012 at 10:06 AM, Armando Blancas 
 abm2...@gmail.comjavascript:
  wrote:

  I'm not going out of my way to be pseudonymous, it just seems to be a 
 feature of the group. 

  

  
 I thought, Mark asking how to run a script? An usurper!
  


 Ah yes.  My understanding of Clojure runs fairly deep, but when it comes 
 to understanding the mundane aspects of how to build and run Clojure and 
 Clojure files from java/maven/etc, I am but a babe in the woods :)   I have 
 my toolchain that works for me (most of the time) and keeps me sheltered 
 from those details, but once I get outside of that, I'm lost.


(Disclaimer: shameless plug)

For running Clojure scripts (with dependency support) you can also look at 
lein-exec:

https://github.com/kumarshantanu/lein-exec

Shantanu

-- 
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: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread Marko Topolnik
On Monday, December 17, 2012 9:28:20 AM UTC+1, bsmith.occs wrote:

 Your macro:

  *(*~greeter user-name#*)*

 *
 *

 Is producing a list of a function or closure followed by a symbol. The 
 first element of the list your macro builds must instead be an expression 
 that can be evaluated to a function. (For example a symbol naming a 
 function or an (fn [] ...) expression.)  


This doesn't help to explain how come it fails only for closures. Does it 
mean that, when it works, it works by accident?

-Marko
 

-- 
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: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread Alex Baranosky
Function values can't be read by the reader.  I'm not sure how any versions
of this code work.

On Mon, Dec 17, 2012 at 12:32 AM, Marko Topolnik
marko.topol...@gmail.comwrote:

 On Monday, December 17, 2012 9:28:20 AM UTC+1, bsmith.occs wrote:

 Your macro:

  *(*~greeter user-name#*)*

 *
 *

 Is producing a list of a function or closure followed by a symbol. The
 first element of the list your macro builds must instead be an expression
 that can be evaluated to a function. (For example a symbol naming a
 function or an (fn [] ...) expression.)


 This doesn't help to explain how come it fails only for closures. Does it
 mean that, when it works, it works by accident?

 -Marko


 --
 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: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
Hi,

I expect the cost of calling `identity` to be negligible. Not for sure, but 
the JVM might even inline it at run-time, or there might be optimizations 
for it in clojure.core during compilation... I cannot comment on that. But 
even with a full virtual call, it should be faster than iterating the whole 
map again.

Also, that `map-vals` is still indeed clunkier ;) Different usages, but for 
me whenever I use `group-by` I very often find I prefer to map the values 
too (to get a nice streamlined data structure to be passed around for 
further processing). Just my experience. It was very handy in .NET, and I 
think it was there for this reason.

Regards,
Daniel

On Monday, December 17, 2012 8:21:44 AM UTC, Alex Baranosky wrote:

 I haven't run into this issue (yet).  My first devil's advocate thought 
 was to suggest that you could map over the data after calling the group-by.

 (- (group-by :type animals)
  (map-vals #(map :name %)))

 There are two problems with this.  One, it uses a custom util function 
 `map-vals` so it is a bit of a cheat.  Two, even with that it still looks 
 pretty clunky.  

 How does the `identity` effect performance?  I wouldn't think much.

 Alex

 On Fri, Dec 14, 2012 at 9:58 AM, Daniel Dinnyes 
 dinn...@gmail.comjavascript:
  wrote:

 Hi,

 I would like to suggest an enhancement to the  clojure.core/group-by  
 function. The idea came from using Enumerable.GroupBy 
 http://msdn.microsoft.com/en-us/library/bb534304.aspxextension method 
 in .NET quite much. It is really handy to have an optional value-mapper 
 function which transforms the elements before adding them to the collection 
 under the key. It is backward compatible, because calling the overload with 
 2 parameters can call the 3 parameter one with clojure.corj/identity as 
 value-mapper function.

 The implementation is easy-peasy (almost the same as the original):

 (defn group-by
   ([f g coll]
  (persistent!
   (reduce
(fn [ret x]
  (let [k (f x)]
(assoc! ret k (conj (get ret k []) (g x)
(transient {}) coll)))
   ([f coll]
  (group-by f identity coll)))

 Without the value-mapper argument it is very awkward to achieve the same 
 structure after the group-by call. Also, doing the transformation before 
 the group-by is often impossible, because the key function depends on some 
 property of the source element, which would be removed after the 
 transformation.

 To demonstrate the usage, check out the below calls:

 (def animals [{:name Betsy :type :cow}
   {:name Murmur :type :cat}
   {:name Lessie :type :dog}
   {:name Dingo :type :dog}
   {:name Rosie :type :cat}
   {:name Rex :type :dog}
   {:name Alf :type :cat}])

 (group-by :type animals) ; old usage
  ... ugly stuff

 (group-by :type :name animals) ; new usage
  {:cow [Betsy], :cat [Murmur Rosie Alf], :dog [Lessie Dingo 
 Rex]}

 (group-by :type #(.toUpperCase (:name %)) animals) ; hell yeah!
  {:cow [BETSY], :cat [MURMUR ROSIE ALF], :dog [LESSIE DINGO 
 REX]}

 It would be so cool to have this in the core. What do you guys think?

 Regards,
 Daniel Dinnyes

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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: JavaFX and Clojure

2012-12-17 Thread Stathis Sideris
Have you considered using the doto macro in order to avoid having to repeat 
the component as the first argument of all the setters?

(let [btn (Button.)]
  (.setLayoutX btn 100)
  (.setLayoutY btn 150)
  (.setText btn Hello World!))

becomes:

(doto (Button.)
  (.setLayoutX 100)
  (.setLayoutY 150)
  (.setText Hello World!))

On Sunday, 16 December 2012 13:37:46 UTC, Christian Sperandio wrote:

 I did some changes.

 First and foremost, I change the project's name to a more formal one: it 
 has became clj-javafx and the link is now 
 https://github.com/chrix75/clj-javafx

 I cleaned the code too, thus:

- I remove the ugly Thread/sleep for promise and deliver
- make the code cleaner



 Le dimanche 16 décembre 2012 00:24:34 UTC+1, Christian Sperandio a écrit :

 I had a test to show how it work.


 Le samedi 15 décembre 2012 22:10:50 UTC+1, Christian Sperandio a écrit :

 Hi,

 After some studies about JavaFX with Clojure, and bricks broke with my 
 head, I wrote a sort of wrapper to work more easily with both.
 It's here : https://github.com/chrix75/javafx-clj

 You can play with JavaFX in your REPL and you have the macro with-javax 
 and wit-javafx-let that let you write JavaFX code  without managing the 
 JavaFX runtime thread.

 I hope it can help.

 Chris



-- 
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: Confused about comp

2012-12-17 Thread Dick Davies
On 16 December 2012 10:59, Peter West peter.b.w...@gmail.com wrote:

 This effect is, on the face of it, unpredictable: you just have to know that
 that is what apply does.  Users of clojure learn that pretty quickly. I've
 just learned it. Doc doesn't help.

 user= (doc apply)

If you're using leiningen (2 at least, maybe 1?) then a

(user/clojuredocs apply)

is a much better how do I drive this thing? than a straight (doc ...) call.

-- 
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


New Clojure user group in Israel

2012-12-17 Thread Daniel Szmulewicz
Hi everybody, 

Happy to announce that Israel has its first Clojure user group.

http://www.meetup.com/Clojure-Israel/

Sincerely,

Daniel Szmulewicz

-- 
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: core/group-by with optional value-mapper function

2012-12-17 Thread Daniel Dinnyes
Also note that I wrote in my first post that Without the value-mapper 
argument it is very awkward to achieve the same structure after the 
group-by call. The `map-vals` function is almost the closest you can get 
to map values after a group-by in a streamlined and clean manner. There is `
fmaphttp://clojuredocs.org/clojure_contrib/clojure.contrib.generic.functor/fmap`
 
in the contrib which does a similar thing already though.

An even cleaner mapper would be something like a `map-multi-vals`, so that 
you can do something like this:

(- (group-by :type animals)
 (map-multi-vals :name))

That's the cleanest one can get with a separate value-mapper. In my opinion 
that has little added benefit though, and possibly the performance is worse 
too. The only benefit would be separation of concern: you can map values of 
a multi-map without knowing how it was created. Now think about it: how 
often would you use `map-multi-vals` separately, not right after a 
group-by? My impression is that whenever an multi-map is created, it almost 
always involves in some way a `group-by` - which itself is a special case 
of `reduce`. There is always a `reduce` somewhere, whether an `into`, a 
`for`, or some imperative iteration. Only `group-by` is the simplest for 
this specific purpose of creating a multi-map. 

My argument therefore is that whenever you need a multi-value mapping, it 
is always preceded by a group-by, and therefore I feel the right place for 
the value-mapper is as an optional parameter for `group-by` itself.

What do you think?

Cheers,
Daniel

On Monday, December 17, 2012 10:13:17 AM UTC, Daniel Dinnyes wrote:

 Hi,

 I expect the cost of calling `identity` to be negligible. Not for sure, 
 but the JVM might even inline it at run-time, or there might be 
 optimizations for it in clojure.core during compilation... I cannot comment 
 on that. But even with a full virtual call, it should be faster than 
 iterating the whole map again.

 Also, that `map-vals` is still indeed clunkier ;) Different usages, but 
 for me whenever I use `group-by` I very often find I prefer to map the 
 values too (to get a nice streamlined data structure to be passed around 
 for further processing). Just my experience. It was very handy in .NET, and 
 I think it was there for this reason.

 Regards,
 Daniel

 On Monday, December 17, 2012 8:21:44 AM UTC, Alex Baranosky wrote:

 I haven't run into this issue (yet).  My first devil's advocate thought 
 was to suggest that you could map over the data after calling the group-by.

 (- (group-by :type animals)
  (map-vals #(map :name %)))

 There are two problems with this.  One, it uses a custom util function 
 `map-vals` so it is a bit of a cheat.  Two, even with that it still looks 
 pretty clunky.  

 How does the `identity` effect performance?  I wouldn't think much.

 Alex

 On Fri, Dec 14, 2012 at 9:58 AM, Daniel Dinnyes dinn...@gmail.comwrote:

 Hi,

 I would like to suggest an enhancement to the  clojure.core/group-by  
 function. The idea came from using Enumerable.GroupBy 
 http://msdn.microsoft.com/en-us/library/bb534304.aspxextension method 
 in .NET quite much. It is really handy to have an optional value-mapper 
 function which transforms the elements before adding them to the collection 
 under the key. It is backward compatible, because calling the overload with 
 2 parameters can call the 3 parameter one with clojure.corj/identity as 
 value-mapper function.

 The implementation is easy-peasy (almost the same as the original):

 (defn group-by
   ([f g coll]
  (persistent!
   (reduce
(fn [ret x]
  (let [k (f x)]
(assoc! ret k (conj (get ret k []) (g x)
(transient {}) coll)))
   ([f coll]
  (group-by f identity coll)))

 Without the value-mapper argument it is very awkward to achieve the same 
 structure after the group-by call. Also, doing the transformation before 
 the group-by is often impossible, because the key function depends on some 
 property of the source element, which would be removed after the 
 transformation.

 To demonstrate the usage, check out the below calls:

 (def animals [{:name Betsy :type :cow}
   {:name Murmur :type :cat}
   {:name Lessie :type :dog}
   {:name Dingo :type :dog}
   {:name Rosie :type :cat}
   {:name Rex :type :dog}
   {:name Alf :type :cat}])

 (group-by :type animals) ; old usage
  ... ugly stuff

 (group-by :type :name animals) ; new usage
  {:cow [Betsy], :cat [Murmur Rosie Alf], :dog [Lessie Dingo 
 Rex]}

 (group-by :type #(.toUpperCase (:name %)) animals) ; hell yeah!
  {:cow [BETSY], :cat [MURMUR ROSIE ALF], :dog [LESSIE DINGO 
 REX]}

 It would be so cool to have this in the core. What do you guys think?

 Regards,
 Daniel Dinnyes

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com
 

Re: Confused about comp

2012-12-17 Thread Peter West
Thanks. That's much better.


On Monday, December 17, 2012 8:53:22 PM UTC+10, Dick Davies wrote:


 If you're using leiningen (2 at least, maybe 1?) then a 

 (user/clojuredocs apply) 

 is a much better how do I drive this thing? than a straight (doc ...) 
 call. 


-- 
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: core/group-by with optional value-mapper function

2012-12-17 Thread László Török
Hi,

I have come across use cases in the past where an additional transformation
step was indeed very handy and I wrote my own version of group-by, one
identical to Daniel's.

Maybe a function worthwhile for c.c.incubator.

Las

2012/12/17 Daniel Dinnyes dinny...@gmail.com

 Also note that I wrote in my first post that Without the value-mapper
 argument it is very awkward to achieve the same structure after the
 group-by call. The `map-vals` function is almost the closest you can get
 to map values after a group-by in a streamlined and clean manner. There is `
 fmaphttp://clojuredocs.org/clojure_contrib/clojure.contrib.generic.functor/fmap`
 in the contrib which does a similar thing already though.

 An even cleaner mapper would be something like a `map-multi-vals`, so that
 you can do something like this:

 (- (group-by :type animals)
  (map-multi-vals :name))

 That's the cleanest one can get with a separate value-mapper. In my
 opinion that has little added benefit though, and possibly the performance
 is worse too. The only benefit would be separation of concern: you can map
 values of a multi-map without knowing how it was created. Now think about
 it: how often would you use `map-multi-vals` separately, not right after a
 group-by? My impression is that whenever an multi-map is created, it almost
 always involves in some way a `group-by` - which itself is a special case
 of `reduce`. There is always a `reduce` somewhere, whether an `into`, a
 `for`, or some imperative iteration. Only `group-by` is the simplest for
 this specific purpose of creating a multi-map.

 My argument therefore is that whenever you need a multi-value mapping, it
 is always preceded by a group-by, and therefore I feel the right place for
 the value-mapper is as an optional parameter for `group-by` itself.

 What do you think?

 Cheers,
 Daniel


 On Monday, December 17, 2012 10:13:17 AM UTC, Daniel Dinnyes wrote:

 Hi,

 I expect the cost of calling `identity` to be negligible. Not for sure,
 but the JVM might even inline it at run-time, or there might be
 optimizations for it in clojure.core during compilation... I cannot comment
 on that. But even with a full virtual call, it should be faster than
 iterating the whole map again.

 Also, that `map-vals` is still indeed clunkier ;) Different usages, but
 for me whenever I use `group-by` I very often find I prefer to map the
 values too (to get a nice streamlined data structure to be passed around
 for further processing). Just my experience. It was very handy in .NET, and
 I think it was there for this reason.

 Regards,
 Daniel

 On Monday, December 17, 2012 8:21:44 AM UTC, Alex Baranosky wrote:

 I haven't run into this issue (yet).  My first devil's advocate thought
 was to suggest that you could map over the data after calling the group-by.

 (- (group-by :type animals)
  (map-vals #(map :name %)))

 There are two problems with this.  One, it uses a custom util function
 `map-vals` so it is a bit of a cheat.  Two, even with that it still looks
 pretty clunky.

 How does the `identity` effect performance?  I wouldn't think much.

 Alex

 On Fri, Dec 14, 2012 at 9:58 AM, Daniel Dinnyes dinn...@gmail.comwrote:

 Hi,

 I would like to suggest an enhancement to the  clojure.core/group-by
 function. The idea came from using Enumerable.GroupBy
 http://msdn.microsoft.com/en-us/library/bb534304.aspxextension
 method in .NET quite much. It is really handy to have an optional
 value-mapper function which transforms the elements before adding them to
 the collection under the key. It is backward compatible, because calling
 the overload with 2 parameters can call the 3 parameter one with
 clojure.corj/identity as value-mapper function.

 The implementation is easy-peasy (almost the same as the original):

 (defn group-by
   ([f g coll]
  (persistent!
   (reduce
(fn [ret x]
  (let [k (f x)]
(assoc! ret k (conj (get ret k []) (g x)
(transient {}) coll)))
   ([f coll]
  (group-by f identity coll)))

 Without the value-mapper argument it is very awkward to achieve the
 same structure after the group-by call. Also, doing the transformation
 before the group-by is often impossible, because the key function depends
 on some property of the source element, which would be removed after the
 transformation.

 To demonstrate the usage, check out the below calls:

 (def animals [{:name Betsy :type :cow}
   {:name Murmur :type :cat}
   {:name Lessie :type :dog}
   {:name Dingo :type :dog}
   {:name Rosie :type :cat}
   {:name Rex :type :dog}
   {:name Alf :type :cat}])

 (group-by :type animals) ; old usage
  ... ugly stuff

 (group-by :type :name animals) ; new usage
  {:cow [Betsy], :cat [Murmur Rosie Alf], :dog [Lessie
 Dingo Rex]}

 (group-by :type #(.toUpperCase (:name %)) animals) ; hell yeah!
  {:cow [BETSY], :cat [MURMUR ROSIE ALF], :dog [LESSIE
 DINGO REX]}

 

Tail call in multi method?

2012-12-17 Thread bruce li
Hello, everyone.

I'm currently trying to model an automata using multi-method. So in my
code, I have something like:

(defmethod trans :state
 [state]
 ; ...
 (trans ..

In the last line, the trans will be called with some different state.

However, it seems that such call still consumes stack and I quickly come to
a stack overflow error when the states are reached multiple times.

I'm wondering if there is some ways to optimize the code.

Thanks!

-- 
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: Tail call in multi method?

2012-12-17 Thread juan.facorro
What about recur http://clojure.org/special_forms#recur? 

It's a special form used for tail call optimizations.

Juan

On Monday, December 17, 2012 1:32:31 PM UTC-3, bruce li wrote:

 Hello, everyone.

 I'm currently trying to model an automata using multi-method. So in my 
 code, I have something like:

 (defmethod trans :state
  [state]
  ; ...
  (trans ..

 In the last line, the trans will be called with some different state.

 However, it seems that such call still consumes stack and I quickly come 
 to a stack overflow error when the states are reached multiple times.

 I'm wondering if there is some ways to optimize the code.

 Thanks!


-- 
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: Tail call in multi method?

2012-12-17 Thread Jonas
recur doesn't work well with multimethods:

(defmulti foo identity)
 
(defmethod foo 1 [n]
  (recur (dec n)))
 
(defmethod foo 0 [n]
  :ok)
 
(foo 1) ;; runs forever

Jonas

On Monday, December 17, 2012 6:56:34 PM UTC+2, juan.facorro wrote:

 What about recur http://clojure.org/special_forms#recur? 

 It's a special form used for tail call optimizations.

 Juan

 On Monday, December 17, 2012 1:32:31 PM UTC-3, bruce li wrote:

 Hello, everyone.

 I'm currently trying to model an automata using multi-method. So in my 
 code, I have something like:

 (defmethod trans :state
  [state]
  ; ...
  (trans ..

 In the last line, the trans will be called with some different state.

 However, it seems that such call still consumes stack and I quickly come 
 to a stack overflow error when the states are reached multiple times.

 I'm wondering if there is some ways to optimize the code.

 Thanks!



-- 
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: Tail call in multi method?

2012-12-17 Thread juan.facorro
You're right, it fails when the call to recur should dispatch to another 
method.

But as long as you are calling the same implementation it does seem to work:

*(ns multi-recur)*
*
*
*(defmulti tail-call #(first %))*
*
*
*(defmethod tail-call :recur [x n]*
*  (if (zero? n)*
*(println x Made it to n)*
*(recur x (dec n*
**
*(defmethod tail-call :overflow [x n]*
*  (if (zero? n)*
*(println x Made it to n)*
*(tail-call x (dec n*
*  *
*(tail-call :recur 5000)*
*(tail-call :overflow 5000)*

I don't know any work arounds for the situation where there dispatch 
resolves to another method implementation.

Juan

On Monday, December 17, 2012 2:08:39 PM UTC-3, Jonas wrote:

 recur doesn't work well with multimethods:

 (defmulti foo identity)
  
 (defmethod foo 1 [n]
   (recur (dec n)))
  
 (defmethod foo 0 [n]
   :ok)
  
 (foo 1) ;; runs forever

 Jonas

 On Monday, December 17, 2012 6:56:34 PM UTC+2, juan.facorro wrote:

 What about recur http://clojure.org/special_forms#recur? 

 It's a special form used for tail call optimizations.

 Juan

 On Monday, December 17, 2012 1:32:31 PM UTC-3, bruce li wrote:

 Hello, everyone.

 I'm currently trying to model an automata using multi-method. So in my 
 code, I have something like:

 (defmethod trans :state
  [state]
  ; ...
  (trans ..

 In the last line, the trans will be called with some different state.

 However, it seems that such call still consumes stack and I quickly come 
 to a stack overflow error when the states are reached multiple times.

 I'm wondering if there is some ways to optimize the code.

 Thanks!



-- 
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: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread Ben Smith-Mannschott
On Mon, Dec 17, 2012 at 11:08 AM, Alex Baranosky 
alexander.barano...@gmail.com wrote:

 Function values can't be read by the reader.  I'm not sure how any
 versions of this code work.


It is true that a function value can not be printed and then read back in,
but I don't think that's relevant here. The macro transforms one in-memory
list into another in-memory list structure. This doesn't involve the reader.



 On Mon, Dec 17, 2012 at 12:32 AM, Marko Topolnik marko.topol...@gmail.com
  wrote:

 On Monday, December 17, 2012 9:28:20 AM UTC+1, bsmith.occs wrote:

 Your macro:

  *(*~greeter user-name#*)*

 *
 *

 Is producing a list of a function or closure followed by a symbol. The
 first element of the list your macro builds must instead be an expression
 that can be evaluated to a function. (For example a symbol naming a
 function or an (fn [] ...) expression.)


 This doesn't help to explain how come it fails only for closures. Does it
 mean that, when it works, it works by accident?

 -Marko


Yes, I would *guess* that it works by accident.

-- 
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: Tail call in multi method?

2012-12-17 Thread Chas Emerick
`recur` throws control flow to the nearest `loop` head or fn body, and each 
method is itself a function, so `recur` within a method body will simply jump 
to the start of the method, _not_ tail-call the multimethod.  e.g.:

= (defmulti foo type)
#'user/foo
= (defmethod foo Long
 [x]
 (assert (integer? x) (str x isn't an integer!  (pr-str x)))
 (recur (str x)))
#MultiFn clojure.lang.MultiFn@4f0ab3f2
= (foo 5)
AssertionError Assert failed: x isn't an integer! 4
(integer? x)  user/eval1831/fn--1832 (NO_SOURCE_FILE:3)

What you're trying to do is really a special case of mutual recursion: because 
Clojure's methods are separate functions, calling back through the multimethod 
(and its dispatch fn) will always consume stack space.  The general solution 
for this is to use `trampoline`, which will continuously call through functions 
returned from calling a function until a non-function value is returned.  This 
would allow you to make your multimethod mutually-recursive, as long as those 
recursive calls are made by returning a function (that the user of the 
multimethod would `trampoline` through):

= (defmethod foo String
 [x]
 (str got  x !))
#MultiFn clojure.lang.MultiFn@4f0ab3f2
= (defmethod foo Long
 [x]
 #(foo (str x)))
#MultiFn clojure.lang.MultiFn@4f0ab3f2
= (foo 5)
#user$eval1888$fn__1889$fn__1890 user$eval1888$fn__1889$fn__1890@3852fdeb
= (trampoline foo 5)
got 5!

From an API standpoint, you would presumably name the multimethod itself 
something like `trans*`, and expose only a helper function `trans` that would 
implicitly trampoline through any functions returned by `trans*`.  There is a 
cost associated with trampolining isn't zero, but won't swamp actual work as 
long as the methods are doing something nontrivial anyway.

Another option you might consider is using agents.  I see your methods already 
take a single state argument; this would then make it really easy to lift the 
automata onto an agent (or set of agents).  That state would become the agents' 
state, and recursive calls would become a `send` (or `send-off` if you're 
doing IO or other blocking things) to the same agent (e.g. `(send *agent* 
trans)`).  

Cheers,

- Chas

--
http://cemerick.com
[Clojure Programming from O'Reilly](http://www.clojurebook.com)

On Dec 17, 2012, at 11:56 AM, juan.facorro wrote:

 What about recur? 
 
 It's a special form used for tail call optimizations.
 
 Juan
 
 On Monday, December 17, 2012 1:32:31 PM UTC-3, bruce li wrote:
 Hello, everyone.
 
 I'm currently trying to model an automata using multi-method. So in my code, 
 I have something like:
 
 (defmethod trans :state
  [state]
  ; ...
  (trans ..
 
 In the last line, the trans will be called with some different state.
 
 However, it seems that such call still consumes stack and I quickly come to a 
 stack overflow error when the states are reached multiple times.
 
 I'm wondering if there is some ways to optimize the code.
 
 Thanks!
 
 -- 
 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: Tail call in multi method?

2012-12-17 Thread Ben Wolfson
On Mon, Dec 17, 2012 at 9:32 AM, Chas Emerick c...@cemerick.com wrote:

 What you're trying to do is really a special case of mutual recursion:
 because Clojure's methods are separate functions, calling back through the
 multimethod (and its dispatch fn) will always consume stack space.  The
 general solution for this is to use `trampoline`, which will continuously
 call through functions returned from calling a function until a non-function
 value is returned.  This would allow you to make your multimethod
 mutually-recursive, as long as those recursive calls are made by returning a
 function (that the user of the multimethod would `trampoline` through):

Also as long as you don't want to return a function from the multimethod, no?

-- 
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


Re: Tail call in multi method?

2012-12-17 Thread Chas Emerick
On Dec 17, 2012, at 12:39 PM, Ben Wolfson wrote:

 On Mon, Dec 17, 2012 at 9:32 AM, Chas Emerick c...@cemerick.com wrote:
 
 What you're trying to do is really a special case of mutual recursion:
 because Clojure's methods are separate functions, calling back through the
 multimethod (and its dispatch fn) will always consume stack space.  The
 general solution for this is to use `trampoline`, which will continuously
 call through functions returned from calling a function until a non-function
 value is returned.  This would allow you to make your multimethod
 mutually-recursive, as long as those recursive calls are made by returning a
 function (that the user of the multimethod would `trampoline` through):
 
 Also as long as you don't want to return a function from the multimethod, no?

Correct.  As noted in the docs for `trampoline`:

...if you want to return a fn as a final value, you must wrap it in 
some data structure and unpack it after trampoline returns.

I can't say I've ever needed to write mutually-recursive higher-order 
functions.  I can only presume that doing so while needing to meet trampoline's 
contract for that corner case would be fairly cumbersome.

IIRC, `trampoline` predated functions supporting metadata by some time.  If it 
were written again now, it might specify that metadata should be used to 
indicate that a function should be called-through, rather than returned as a 
non-intermediate value.  e.g.:

(defn meta-trampoline
  ([f]
 (let [ret (f)]
   (if (and (fn? ret) (- ret meta :trampoline))
 (recur ret)
 ret)))
  ([f  args]
 (meta-trampoline #(apply f args

With this, you can return whatever you want/need to, as long as you mark the 
self- or mutually-recursive calls with {:trampoline true} metadata:

= (defmethod foo String
 [x]
 #(str I got  x , you gave me  %))
#MultiFn clojure.lang.MultiFn@4f0ab3f2
= (defmethod foo Long
 [x]
 ^:trampoline #(foo (str x)))
#MultiFn clojure.lang.MultiFn@4f0ab3f2
= (meta-trampoline foo 5)
#user$eval1992$fn__1993$fn__1994 user$eval1992$fn__1993$fn__1994@7466a008
= (*1 6)
I got 5, you gave me 6

Cheers,

- Chas

-- 
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: Why I get IllegalArgumentException: No matching ctor found

2012-12-17 Thread Marko Topolnik
On Mon, Dec 17, 2012 at 11:08 AM, Alex Baranosky 
alexander...@gmail.comjavascript:
 wrote:

 Function values can't be read by the reader.  I'm not sure how any 
 versions of this code work.  


 It is true that a function value can not be printed and then read back in, 
 but I don't think that's relevant here. The macro transforms one in-memory 
 list into another in-memory list structure. This doesn't involve the reader.


Let's look at this example:

(defmacro defgreeter [greeter-name]
  (let [greeter (java.util.Random.)]
`(defn ~greeter-name [user-name#]
 (.nextInt ~greeter

It fails with

Can't embed object in code, maybe print-dup not defined: 
java.util.Random@1572aa51

How does this error relate to OP's? Since here printing does seem to be 
involved.
  

-- 
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: Belgian Clojure base meetup?

2012-12-17 Thread Sébastien Wagener
Hi Thomas,

I'm from Luxembourg. If the meetup isn't too far away from the border, I
would be interested.

Sébastien


2012/12/16 Thomas Goossens cont...@thomasgoossens.be

 If you are from Belgium, Don't get too excited - yet - .

 I've been wondering about organising a small meetup somewhere next
 semester. (I peeked at our northern neighbours:
 http://www.meetup.com/The-Amsterdam-Clojure-Meetup-Group/events/88386392/)

 Though, I have no idea at all how many people here in Belgium are actively
 using clojure and would be interested in such a thing.

 Its not a plan, just being curious and checking whether it would be worth
 the time.

 So if you are from Belgium, give me a shout!

 --
 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: ANN: lein-clr 0.2.0 for ClojureCLR

2012-12-17 Thread dmiller
Aaron,

tools.logging and nrepl are important.  I'm glad to see the effort.
I haven't forgotten about your single-DLL work.
I'm going to have plenty of time next week if you can get something to me.

-David



On Saturday, December 15, 2012 5:15:16 PM UTC-6, Aaron wrote:

 Cool.  I'm just seeing this now.  I actually spent some time a while back 
 getting a very simple nleiningen working in ClojureCLR.  I had nuget 
 downloads working and also the ability to AOT compile namespaces and merge 
 them into a single DLL.  It's not fully ready for prime time yet though, in 
 part because it depends on some custom modifications to the ClojureCLR 
 compiler.  In the long run, I'd like to work together on getting a full 
 lein clr implementation working.  I'd love to discuss further if you have 
 time.

 By the way Dave - speaking of custom modifications to ClojureCLR, this 
 past week, my colleague and I merged your latest master with our changes (
 https://github.com/kocubinski/clojure-clr).  I hope to put together some 
 formal patches soon which clearly identify the changes I'm suggesting for 
 the main compiler.

 While we're at it, a few other things I'm working on or have working in 
 clojure-clr are:
 tools.logging and pinvoke (https://github.com/aaronc/ClojureClrEx) - 
 logging is mostly ported but with only one backend working, 
 pinvoke/dllimport works great, but no docs
 a nice interface to WPF (https://github.com/aaronc/ClojureWpf) - pretty 
 stable, but again no docs yet
 nrepl (https://github.com/aaronc/tools.nrepl/tree/clr) - needs quite a 
 bit more work

 Unfortunately, I haven't been too diligent with documentation, but I hope 
 to correct that as time allows.  

 On Sunday, November 18, 2012 4:03:03 PM UTC-5, Shantanu Kumar wrote:

 Hi,

 I pushed lein-clr 0.2.0 https://github.com/kumarshantanu/lein-clr JARs 
 to Clojars a little while ago. The focus of this release is to

 1. add dependency support (via NuGet/wget/curl, Leiningen :dependencies)
 2. lower the bar to get started with ClojureCLR (with automated download 
 of ClojureCLR)
 3. remove the need to call `assembly-load-from` in code

 The changelog and TODO are here: 
 https://github.com/kumarshantanu/lein-clr/blob/master/CHANGES.md

 I hope this release is usable enough to start building ClojureCLR apps 
 and libraries with it. This is an early project and can certainly use 
 feedback and contribution. Please let me know what you think.

 Shantanu



-- 
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: core/group-by with optional value-mapper function

2012-12-17 Thread Alex Baranosky
I think it sounds like a nice addition, after mulling it over a little.

On Mon, Dec 17, 2012 at 4:47 AM, László Török ltoro...@gmail.com wrote:

 Hi,

 I have come across use cases in the past where an additional
 transformation step was indeed very handy and I wrote my own version of
 group-by, one identical to Daniel's.

 Maybe a function worthwhile for c.c.incubator.

 Las


 2012/12/17 Daniel Dinnyes dinny...@gmail.com

 Also note that I wrote in my first post that Without the value-mapper
 argument it is very awkward to achieve the same structure after the
 group-by call. The `map-vals` function is almost the closest you can get
 to map values after a group-by in a streamlined and clean manner. There is `
 fmaphttp://clojuredocs.org/clojure_contrib/clojure.contrib.generic.functor/fmap`
 in the contrib which does a similar thing already though.

 An even cleaner mapper would be something like a `map-multi-vals`, so
 that you can do something like this:

 (- (group-by :type animals)
  (map-multi-vals :name))

 That's the cleanest one can get with a separate value-mapper. In my
 opinion that has little added benefit though, and possibly the performance
 is worse too. The only benefit would be separation of concern: you can map
 values of a multi-map without knowing how it was created. Now think about
 it: how often would you use `map-multi-vals` separately, not right after a
 group-by? My impression is that whenever an multi-map is created, it almost
 always involves in some way a `group-by` - which itself is a special case
 of `reduce`. There is always a `reduce` somewhere, whether an `into`, a
 `for`, or some imperative iteration. Only `group-by` is the simplest for
 this specific purpose of creating a multi-map.

 My argument therefore is that whenever you need a multi-value mapping, it
 is always preceded by a group-by, and therefore I feel the right place for
 the value-mapper is as an optional parameter for `group-by` itself.

 What do you think?

 Cheers,
 Daniel


 On Monday, December 17, 2012 10:13:17 AM UTC, Daniel Dinnyes wrote:

 Hi,

 I expect the cost of calling `identity` to be negligible. Not for sure,
 but the JVM might even inline it at run-time, or there might be
 optimizations for it in clojure.core during compilation... I cannot comment
 on that. But even with a full virtual call, it should be faster than
 iterating the whole map again.

 Also, that `map-vals` is still indeed clunkier ;) Different usages, but
 for me whenever I use `group-by` I very often find I prefer to map the
 values too (to get a nice streamlined data structure to be passed around
 for further processing). Just my experience. It was very handy in .NET, and
 I think it was there for this reason.

 Regards,
 Daniel

 On Monday, December 17, 2012 8:21:44 AM UTC, Alex Baranosky wrote:

 I haven't run into this issue (yet).  My first devil's advocate thought
 was to suggest that you could map over the data after calling the group-by.

 (- (group-by :type animals)
  (map-vals #(map :name %)))

 There are two problems with this.  One, it uses a custom util function
 `map-vals` so it is a bit of a cheat.  Two, even with that it still looks
 pretty clunky.

 How does the `identity` effect performance?  I wouldn't think much.

 Alex

 On Fri, Dec 14, 2012 at 9:58 AM, Daniel Dinnyes dinn...@gmail.comwrote:

 Hi,

 I would like to suggest an enhancement to the  clojure.core/group-by
 function. The idea came from using Enumerable.GroupBy
 http://msdn.microsoft.com/en-us/library/bb534304.aspxextension
 method in .NET quite much. It is really handy to have an optional
 value-mapper function which transforms the elements before adding them to
 the collection under the key. It is backward compatible, because calling
 the overload with 2 parameters can call the 3 parameter one with
 clojure.corj/identity as value-mapper function.

 The implementation is easy-peasy (almost the same as the original):

 (defn group-by
   ([f g coll]
  (persistent!
   (reduce
(fn [ret x]
  (let [k (f x)]
(assoc! ret k (conj (get ret k []) (g x)
(transient {}) coll)))
   ([f coll]
  (group-by f identity coll)))

 Without the value-mapper argument it is very awkward to achieve the
 same structure after the group-by call. Also, doing the transformation
 before the group-by is often impossible, because the key function depends
 on some property of the source element, which would be removed after the
 transformation.

 To demonstrate the usage, check out the below calls:

 (def animals [{:name Betsy :type :cow}
   {:name Murmur :type :cat}
   {:name Lessie :type :dog}
   {:name Dingo :type :dog}
   {:name Rosie :type :cat}
   {:name Rex :type :dog}
   {:name Alf :type :cat}])

 (group-by :type animals) ; old usage
  ... ugly stuff

 (group-by :type :name animals) ; new usage
  {:cow [Betsy], :cat [Murmur Rosie Alf], :dog 

Re: ClojureCLR errors on Mono Linux

2012-12-17 Thread dmiller
Shantanu,

I don't have a Linux box available at this point to test, but I'll try it 
on Mac w/ Mono when I get a chance.
I don't have a clue how a field disappears between platforms.

-David


On Saturday, December 15, 2012 10:15:21 PM UTC-6, Shantanu Kumar wrote:

 Hi,

 I noticed the following ClojureCLR errors using Mono 2.10 on Ubuntu 12.04 
 (they do not happen on Windows using either .NET or Mono):

 1. when running Clojure.Compile.exe:

 Exception: System.MissingFieldException: Field 'clojure.lang.RT.OutVar' 
 not found.

 2. when using Clojure.Main.exe:

 Exception: System.TypeLoadException: Could not load type 'Clojure.CljMain' 
 from assembly 'Clojure.Main, Version=1.0.0.0, Culture=neutral, 
 PublicKeyToken=null'.

 It would be great if anybody can let me know what's going on.

 Shantanu


-- 
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: Belgian Clojure base meetup?

2012-12-17 Thread Joop Kiefte
I have joined the Amsterdam Clojurians before, but live in Vroenhoven now
(near Maastricht, relatively close to Liége). Maybe a meetup around here
would be something? :)


2012/12/17 Sébastien Wagener sebastien.wage...@gmail.com

 Hi Thomas,

 I'm from Luxembourg. If the meetup isn't too far away from the border, I
 would be interested.

 Sébastien


 2012/12/16 Thomas Goossens cont...@thomasgoossens.be

 If you are from Belgium, Don't get too excited - yet - .

 I've been wondering about organising a small meetup somewhere next
 semester. (I peeked at our northern neighbours:
 http://www.meetup.com/The-Amsterdam-Clojure-Meetup-Group/events/88386392/
 )

 Though, I have no idea at all how many people here in Belgium are
 actively using clojure and would be interested in such a thing.

 Its not a plan, just being curious and checking whether it would be worth
 the time.

 So if you are from Belgium, give me a shout!

 --
 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: ANN: lein-clr 0.2.0 for ClojureCLR

2012-12-17 Thread Aaron Craelius
Ok, sounds good.  I can do that.  I have 2-3 pretty specific changes that I
can outline.  I also have one bug fix (support for IntPtr and UIntPtr in
HostExpr).  Should I maybe start a separate thread in this group describing
the proposed changes or should we do this via JIRA or github?  I'm not
really sure whether the best method for doing this is git format-patch
(which generates a lot of patches) or some other method.


On Mon, Dec 17, 2012 at 4:14 PM, dmiller dmiller2...@gmail.com wrote:

 Aaron,

 tools.logging and nrepl are important.  I'm glad to see the effort.
 I haven't forgotten about your single-DLL work.
 I'm going to have plenty of time next week if you can get something to me.

 -David



 On Saturday, December 15, 2012 5:15:16 PM UTC-6, Aaron wrote:

 Cool.  I'm just seeing this now.  I actually spent some time a while back
 getting a very simple nleiningen working in ClojureCLR.  I had nuget
 downloads working and also the ability to AOT compile namespaces and merge
 them into a single DLL.  It's not fully ready for prime time yet though, in
 part because it depends on some custom modifications to the ClojureCLR
 compiler.  In the long run, I'd like to work together on getting a full
 lein clr implementation working.  I'd love to discuss further if you have
 time.

 By the way Dave - speaking of custom modifications to ClojureCLR, this
 past week, my colleague and I merged your latest master with our changes (
 https://github.com/**kocubinski/clojure-clrhttps://github.com/kocubinski/clojure-clr).
  I hope to put together some formal patches soon which clearly identify the
 changes I'm suggesting for the main compiler.

 While we're at it, a few other things I'm working on or have working in
 clojure-clr are:
 tools.logging and pinvoke 
 (https://github.com/aaronc/**ClojureClrExhttps://github.com/aaronc/ClojureClrEx)
 - logging is mostly ported but with only one backend working,
 pinvoke/dllimport works great, but no docs
 a nice interface to WPF 
 (https://github.com/aaronc/**ClojureWpfhttps://github.com/aaronc/ClojureWpf)
 - pretty stable, but again no docs yet
 nrepl 
 (https://github.com/aaronc/**tools.nrepl/tree/clrhttps://github.com/aaronc/tools.nrepl/tree/clr)
 - needs quite a bit more work

 Unfortunately, I haven't been too diligent with documentation, but I hope
 to correct that as time allows.

 On Sunday, November 18, 2012 4:03:03 PM UTC-5, Shantanu Kumar wrote:

 Hi,

 I pushed lein-clr 0.2.0 
 https://github.com/**kumarshantanu/lein-clrhttps://github.com/kumarshantanu/lein-clr
  JARs
 to Clojars a little while ago. The focus of this release is to

 1. add dependency support (via NuGet/wget/curl, Leiningen :dependencies)
 2. lower the bar to get started with ClojureCLR (with automated download
 of ClojureCLR)
 3. remove the need to call `assembly-load-from` in code

 The changelog and TODO are here: https://github.com/**
 kumarshantanu/lein-clr/blob/**master/CHANGES.mdhttps://github.com/kumarshantanu/lein-clr/blob/master/CHANGES.md

 I hope this release is usable enough to start building ClojureCLR apps
 and libraries with it. This is an early project and can certainly use
 feedback and contribution. Please let me know what you think.

 Shantanu

  --
 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: Using functions from Java packages

2012-12-17 Thread greg r
Another possibility is the macro memfn.  From the documentation:

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/memfn

Regards,
Greg

-- 
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: Using functions from Java packages

2012-12-17 Thread greg r
Another possibility is the macro memfn.  From the documentation:

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/memfn

Regards,
Greg

-- 
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: How to structure a Clojure day for noobs?

2012-12-17 Thread Peter Buckley
1. install Leiningen and learn the basics
2. get everyone an editing environment, with the option of using either
Emacs, IntelliJ, or Eclipse

I would have people do this in advance, or provide a canned environment
that has a better chance of just working. There's decent odds that these
two steps will eat up a bunch of your time and leave people feeling left
out when their install/editor/integration is not quite right.

Personally I found the C-x-e of evaluating an s-exp in emacs to be the
magic that makes clojure a bajillionty times better than any other
programming language, so I'm partial to something like the emacs starter
kit. But something like labrepl or eclipse+counterclockwise might be easier
for people to start with.

On Mon, Dec 17, 2012 at 3:26 AM, Marko Topolnik marko.topol...@gmail.comwrote:


 I think, however, that there is a risk of a disconnect, where newcomers
 don't really grasp that there is a JVM running and that code is actually
 compiled and injected into it, and that it's for real. They are used to
 mickey mouse interactive tools that don't provide the real thing, and
 struggle to bridge the apparent gap between running code in the REPL and
 properly compiling and running files. There is no gap, but one needs to
 explain that, I think.


 I think this is a pivot point for everything in Clojure. The harder the
 mental switch, the more important to make it right away. Without
 understanding that, it will be very hard to maintain a clear picture of how
 everything fits together, especially when you start changing functions and
 reloading them.

 --
 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




-- 
The king’s heart is like a stream of water directed by the Lord; He guides
it wherever He pleases.

-- 
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

Best way to include a passwords file in a project?

2012-12-17 Thread Marco Munizaga
I'm currently doing something like src/project/passwords.clj and git 
ignoring that, does anyone have a better solution? maybe a way to place the 
passwords.clj alongside project.clj in the root directory? Would this be 
possible through leiningen profiles?


Thanks

-- 
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

clojure-contrib migrations

2012-12-17 Thread Christopher Meiklejohn
Hi there,

I'm inquiring regarding the clojure-contrib migration process.  I'd like to 
offer to step up and maintain clojure-contrib.graph, mainly starting with 
converting the defstructs over to defrecords so I can start playing around 
in ClojureScript with this library.  What's the process moving forward?

- Chris

-- 
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: Clojure Full Syntactical Reference

2012-12-17 Thread Karim A. Nassar
When using nrepl in emacs (cdoc fn) emits:

CompilerException java.lang.RuntimeException: Unable to resolve symbol:
cdoc in this context, compiling:(NO_SOURCE_PATH:1)

However, in lein repl I see:

Loading clojuredocs-client...

How do I make nrepl as smart as lein repl?



On Fri, Dec 14, 2012 at 10:08 PM, Andy Fingerhut
andy.finger...@gmail.comwrote:

 I would recommend checking out

 http://clojuredocs.org

 If you use Leiningen version 2, you can get similar output with these two
 commands:

 lein repl
 user= (doc first)
 user= (cdoc first)

 doc gives the doc string built into Clojure.  cdoc gives the examples
 from ClojureDocs.org for that symbol, as long as you have an Internet
 connection.

 Andy

 On Dec 14, 2012, at 3:40 PM, linc...@redhandgaming.net wrote:

  I'm learning Clojure, and I learn best by jumping in. I'm interested in
 using Noir. Noir has a full API reference, so when I'm reading other
 people's Noir code, I can just look up the exact function and see what it
 does.
 
  I can't find a similar thing for Clojure. I'm looking through other
 people's Clojure code. I see something like (keyword (or (first m) :dev))
 and I don't really know where to start understanding this. I know enough to
 know that keyword, or, and first are all functions - and with a google
 search or two, I can figure out what 'first' does. But I can't easily find
 out what 'or' and 'keyword' do, because when I google those things, I get
 all kinds of screwy results, completely unrelated to what I'm trying to
 find out.
 
  Where can I find, or does there exist, a place where I can view all
 Clojure's built in functions with a short description of their arguments
 and what they do?

 --
 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: [ANN] tools.namespace 0.2.2 and Flow 0.1.0

2012-12-17 Thread Mikera
Hi Stuart,

Re: tools.namespace, I've found some similar functions in the bultitude 
library (https://github.com/Raynes/bultitude/tree/master/src/bultitude). 
Apparently it addresses 
specific needs that clojure.tools.namespace did not provide.

Is one of these recommended over the other, or is there a plan to merge 
these so that 
we get the best of both?

On Friday, 14 December 2012 21:52:40 UTC+8, Stuart Sierra wrote:


 Changelog  more info:

   https://github.com/clojure/tools.namespace


-- 
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

Little namespace question

2012-12-17 Thread Alan Shaw
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

2012-12-17 Thread László Török
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

Re: Little namespace question

2012-12-17 Thread Alan Shaw
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: clojure-contrib migrations

2012-12-17 Thread Andy Fingerhut
If you want it to remain a Clojure contrib library with a clojure.* namespace, 
you'll need to sign a Clojure CA to be able to make contributions to it.

http://clojure.org/contributing

If you want to make it a project on Github or somewhere else, you would 
probably need to keep the existing license, which I'm guessing is the Eclipse 
public license.

Andy

On Dec 17, 2012, at 3:44 PM, Christopher Meiklejohn wrote:

 Hi there,
 
 I'm inquiring regarding the clojure-contrib migration process.  I'd like to 
 offer to step up and maintain clojure-contrib.graph, mainly starting with 
 converting the defstructs over to defrecords so I can start playing around in 
 ClojureScript with this library.  What's the process moving forward?
 
 - Chris

-- 
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

2012-12-17 Thread László Török
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.comjavascript:_e({}, 'cvml', 'ltoro...@gmail.com');
  wrote:

 Try (in-ns 'user-ns)

 Las
 On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.comjavascript:_e({}, 
 'cvml', '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.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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

Re: Little namespace question

2012-12-17 Thread Alan Shaw
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

2012-12-17 Thread Baishampayan Ghose
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 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

2012-12-17 Thread Alan Shaw
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

2012-12-17 Thread Baishampayan Ghose
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@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.
  

Re: Little namespace question

2012-12-17 Thread Alan Shaw
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