Re: Do functions never get inlined by jvm?

2013-04-25 Thread David Nolen
primitive hinted fns will get inlined. You can also play the same kinds of
games that Clojure does with definterface+deftype and fns that declare
:inline metadata.

If you don't want to learn the subtleties of Clojure performance tuning
then you can always write your performance critical bits in Java and call
into it. Some folks, like the people at Prismatic, seem to be doing pretty
well writing all their performance critical code in Clojure, but they've
built some tools to avoid the various potential pitfalls.


On Thu, Apr 25, 2013 at 9:19 AM, Alice dofflt...@gmail.com wrote:

 I create many small methods in java without worrying about the
 performance since it's usually the target of inline optimization. For
 example,

 public class Foo {
   public static long inc(long l) {
 return ++l;
   }

   public static long f1() {
 long l = 0;
 for (int i=0; i  10; i++) {
   l++;
 }
 return l;
   }

   public static long f2() {
 long l = 0;
 for (int i=0; i  10; i++) {
   l = inc(l);
 }
 return l;
   }
 }

 (time (Foo/f1))
 (time (Foo/f1))
 (time (Foo/f1))
 (time (Foo/f2))
 (time (Foo/f2))
 (time (Foo/f2))

 Elapsed time: 23.309532 msecs
 Elapsed time: 23.333039 msecs
 Elapsed time: 21.714753 msecs
 Elapsed time: 22.943366 msecs
 Elapsed time: 21.612783 msecs
 Elapsed time: 21.71376 msecs


 But clojure funtions seem to be never get inlined.

 (def obj (Object.))

 (defn getObj [] obj)

 (defn f1 [] obj)
 (defn f2 [] (getObj))

 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f2)))
 (time (dotimes [n 1] (f2)))
 (time (dotimes [n 1] (f2)))

 Elapsed time: 67.758744 msecs
 Elapsed time: 68.555306 msecs
 Elapsed time: 68.725147 msecs
 Elapsed time: 104.810459 msecs
 Elapsed time: 103.273618 msecs
 Elapsed time: 103.374595 msecs

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Alice
Primitive hinted funtions seem to be not an exception.

(defn my-inc ^long [^long l] (inc l))

(defn f1 [^long l] (inc l))
(defn f2 [^long l] (my-inc l))

(time (dotimes [n 1] (f1 1)))
(time (dotimes [n 1] (f1 1)))
(time (dotimes [n 1] (f1 1)))
(time (dotimes [n 1] (f2 1)))
(time (dotimes [n 1] (f2 1)))
(time (dotimes [n 1] (f2 1)))

Elapsed time: 68.683431 msecs
Elapsed time: 68.964182 msecs
Elapsed time: 68.105047 msecs
Elapsed time: 108.576746 msecs
Elapsed time: 100.992193 msecs
Elapsed time: 100.945511 msecs

On Apr 25, 10:32 pm, David Nolen dnolen.li...@gmail.com wrote:
 primitive hinted fns will get inlined. You can also play the same kinds of
 games that Clojure does with definterface+deftype and fns that declare
 :inline metadata.

 If you don't want to learn the subtleties of Clojure performance tuning
 then you can always write your performance critical bits in Java and call
 into it. Some folks, like the people at Prismatic, seem to be doing pretty
 well writing all their performance critical code in Clojure, but they've
 built some tools to avoid the various potential pitfalls.







 On Thu, Apr 25, 2013 at 9:19 AM, Alice dofflt...@gmail.com wrote:
  I create many small methods in java without worrying about the
  performance since it's usually the target of inline optimization. For
  example,

  public class Foo {
    public static long inc(long l) {
      return ++l;
    }

    public static long f1() {
      long l = 0;
      for (int i=0; i  10; i++) {
        l++;
      }
      return l;
    }

    public static long f2() {
      long l = 0;
      for (int i=0; i  10; i++) {
        l = inc(l);
      }
      return l;
    }
  }

  (time (Foo/f1))
  (time (Foo/f1))
  (time (Foo/f1))
  (time (Foo/f2))
  (time (Foo/f2))
  (time (Foo/f2))

  Elapsed time: 23.309532 msecs
  Elapsed time: 23.333039 msecs
  Elapsed time: 21.714753 msecs
  Elapsed time: 22.943366 msecs
  Elapsed time: 21.612783 msecs
  Elapsed time: 21.71376 msecs

  But clojure funtions seem to be never get inlined.

  (def obj (Object.))

  (defn getObj [] obj)

  (defn f1 [] obj)
  (defn f2 [] (getObj))

  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f2)))
  (time (dotimes [n 1] (f2)))
  (time (dotimes [n 1] (f2)))

  Elapsed time: 67.758744 msecs
  Elapsed time: 68.555306 msecs
  Elapsed time: 68.725147 msecs
  Elapsed time: 104.810459 msecs
  Elapsed time: 103.273618 msecs
  Elapsed time: 103.374595 msecs

  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Ambrose Bonnaire-Sergeant
jvm.tools.analyzer is a nice tool for exploration in this area.

I don't personally know all the subtleties here, but after some playing I
managed to emit an unboxing function.
I could tell from the AST.

https://gist.github.com/frenchy64/5459989

Thanks,
Ambrose


On Thu, Apr 25, 2013 at 9:44 PM, Alice dofflt...@gmail.com wrote:

 Primitive hinted funtions seem to be not an exception.

 (defn my-inc ^long [^long l] (inc l))

 (defn f1 [^long l] (inc l))
 (defn f2 [^long l] (my-inc l))

 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f2 1)))
 (time (dotimes [n 1] (f2 1)))
 (time (dotimes [n 1] (f2 1)))

 Elapsed time: 68.683431 msecs
 Elapsed time: 68.964182 msecs
 Elapsed time: 68.105047 msecs
 Elapsed time: 108.576746 msecs
 Elapsed time: 100.992193 msecs
 Elapsed time: 100.945511 msecs

 On Apr 25, 10:32 pm, David Nolen dnolen.li...@gmail.com wrote:
  primitive hinted fns will get inlined. You can also play the same kinds
 of
  games that Clojure does with definterface+deftype and fns that declare
  :inline metadata.
 
  If you don't want to learn the subtleties of Clojure performance tuning
  then you can always write your performance critical bits in Java and call
  into it. Some folks, like the people at Prismatic, seem to be doing
 pretty
  well writing all their performance critical code in Clojure, but they've
  built some tools to avoid the various potential pitfalls.
 
 
 
 
 
 
 
  On Thu, Apr 25, 2013 at 9:19 AM, Alice dofflt...@gmail.com wrote:
   I create many small methods in java without worrying about the
   performance since it's usually the target of inline optimization. For
   example,
 
   public class Foo {
 public static long inc(long l) {
   return ++l;
 }
 
 public static long f1() {
   long l = 0;
   for (int i=0; i  10; i++) {
 l++;
   }
   return l;
 }
 
 public static long f2() {
   long l = 0;
   for (int i=0; i  10; i++) {
 l = inc(l);
   }
   return l;
 }
   }
 
   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f2))
   (time (Foo/f2))
   (time (Foo/f2))
 
   Elapsed time: 23.309532 msecs
   Elapsed time: 23.333039 msecs
   Elapsed time: 21.714753 msecs
   Elapsed time: 22.943366 msecs
   Elapsed time: 21.612783 msecs
   Elapsed time: 21.71376 msecs
 
   But clojure funtions seem to be never get inlined.
 
   (def obj (Object.))
 
   (defn getObj [] obj)
 
   (defn f1 [] obj)
   (defn f2 [] (getObj))
 
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))
 
   Elapsed time: 67.758744 msecs
   Elapsed time: 68.555306 msecs
   Elapsed time: 68.725147 msecs
   Elapsed time: 104.810459 msecs
   Elapsed time: 103.273618 msecs
   Elapsed time: 103.374595 msecs
 
   --
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clojure@googlegroups.com
   Note that posts from new members are moderated - please be patient with
   your first post.
   To unsubscribe from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
   ---
   You received this message because you are subscribed to the Google
 Groups
   Clojure group.
   To unsubscribe from this group and stop receiving emails from it, send
 an
   email to clojure+unsubscr...@googlegroups.com.
   For more options, visithttps://groups.google.com/groups/opt_out.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 

Re: Do functions never get inlined by jvm?

2013-04-25 Thread Phil Hagelberg
Three repetitions is not nearly enough to get a feel for how hotspot
optimizes functions when it detects they're in a tight loop. I don't know
how javac works, but Clojure doesn't optimize much for cases where hotspot
can do a much better job over time.

-Phil

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Jonathan Fischer Friberg
If that's a problem, you could try https://github.com/hugoduncan/criterium


On Thu, Apr 25, 2013 at 5:38 PM, Phil Hagelberg p...@hagelb.org wrote:

 Three repetitions is not nearly enough to get a feel for how hotspot
 optimizes functions when it detects they're in a tight loop. I don't know
 how javac works, but Clojure doesn't optimize much for cases where hotspot
 can do a much better job over time.

 -Phil

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread David Nolen
You have to be very careful with microbenchmarks like this. I recommend
writing less trivial benchmarks. For example
http://github.com/clojure/test.benchmark/blob/master/src/main/clojure/alioth/spectral_norm.clj

This code demonstrates performance on par with plain Java. There are many
other similar examples in the test.benchark project.

David


On Thu, Apr 25, 2013 at 9:44 AM, Alice dofflt...@gmail.com wrote:

 Primitive hinted funtions seem to be not an exception.

 (defn my-inc ^long [^long l] (inc l))

 (defn f1 [^long l] (inc l))
 (defn f2 [^long l] (my-inc l))

 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f1 1)))
 (time (dotimes [n 1] (f2 1)))
 (time (dotimes [n 1] (f2 1)))
 (time (dotimes [n 1] (f2 1)))

 Elapsed time: 68.683431 msecs
 Elapsed time: 68.964182 msecs
 Elapsed time: 68.105047 msecs
 Elapsed time: 108.576746 msecs
 Elapsed time: 100.992193 msecs
 Elapsed time: 100.945511 msecs

 On Apr 25, 10:32 pm, David Nolen dnolen.li...@gmail.com wrote:
  primitive hinted fns will get inlined. You can also play the same kinds
 of
  games that Clojure does with definterface+deftype and fns that declare
  :inline metadata.
 
  If you don't want to learn the subtleties of Clojure performance tuning
  then you can always write your performance critical bits in Java and call
  into it. Some folks, like the people at Prismatic, seem to be doing
 pretty
  well writing all their performance critical code in Clojure, but they've
  built some tools to avoid the various potential pitfalls.
 
 
 
 
 
 
 
  On Thu, Apr 25, 2013 at 9:19 AM, Alice dofflt...@gmail.com wrote:
   I create many small methods in java without worrying about the
   performance since it's usually the target of inline optimization. For
   example,
 
   public class Foo {
 public static long inc(long l) {
   return ++l;
 }
 
 public static long f1() {
   long l = 0;
   for (int i=0; i  10; i++) {
 l++;
   }
   return l;
 }
 
 public static long f2() {
   long l = 0;
   for (int i=0; i  10; i++) {
 l = inc(l);
   }
   return l;
 }
   }
 
   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f2))
   (time (Foo/f2))
   (time (Foo/f2))
 
   Elapsed time: 23.309532 msecs
   Elapsed time: 23.333039 msecs
   Elapsed time: 21.714753 msecs
   Elapsed time: 22.943366 msecs
   Elapsed time: 21.612783 msecs
   Elapsed time: 21.71376 msecs
 
   But clojure funtions seem to be never get inlined.
 
   (def obj (Object.))
 
   (defn getObj [] obj)
 
   (defn f1 [] obj)
   (defn f2 [] (getObj))
 
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))
 
   Elapsed time: 67.758744 msecs
   Elapsed time: 68.555306 msecs
   Elapsed time: 68.725147 msecs
   Elapsed time: 104.810459 msecs
   Elapsed time: 103.273618 msecs
   Elapsed time: 103.374595 msecs
 
   --
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clojure@googlegroups.com
   Note that posts from new members are moderated - please be patient with
   your first post.
   To unsubscribe from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
   ---
   You received this message because you are subscribed to the Google
 Groups
   Clojure group.
   To unsubscribe from this group and stop receiving emails from it, send
 an
   email to clojure+unsubscr...@googlegroups.com.
   For more options, visithttps://groups.google.com/groups/opt_out.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Do functions never get inlined by jvm?

2013-04-25 Thread Alice
Found this blog post written by fogus:

To provide this level of flexibility Clojure establishes a level of
indirection. Specifically, all function lookups through a Var occur,
at the lowest level, through an atomic volatile. This happens every
time that a function bound using the def/defn special forms is called.
This indirection is not amenable to HotSpot optimizations.

http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/

On Apr 25, 10:19 pm, Alice dofflt...@gmail.com wrote:
 I create many small methods in java without worrying about the
 performance since it's usually the target of inline optimization. For
 example,

 public class Foo {
   public static long inc(long l) {
     return ++l;
   }

   public static long f1() {
     long l = 0;
     for (int i=0; i  10; i++) {
       l++;
     }
     return l;
   }

   public static long f2() {
     long l = 0;
     for (int i=0; i  10; i++) {
       l = inc(l);
     }
     return l;
   }

 }

 (time (Foo/f1))
 (time (Foo/f1))
 (time (Foo/f1))
 (time (Foo/f2))
 (time (Foo/f2))
 (time (Foo/f2))

 Elapsed time: 23.309532 msecs
 Elapsed time: 23.333039 msecs
 Elapsed time: 21.714753 msecs
 Elapsed time: 22.943366 msecs
 Elapsed time: 21.612783 msecs
 Elapsed time: 21.71376 msecs

 But clojure funtions seem to be never get inlined.

 (def obj (Object.))

 (defn getObj [] obj)

 (defn f1 [] obj)
 (defn f2 [] (getObj))

 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f1)))
 (time (dotimes [n 1] (f2)))
 (time (dotimes [n 1] (f2)))
 (time (dotimes [n 1] (f2)))

 Elapsed time: 67.758744 msecs
 Elapsed time: 68.555306 msecs
 Elapsed time: 68.725147 msecs
 Elapsed time: 104.810459 msecs
 Elapsed time: 103.273618 msecs
 Elapsed time: 103.374595 msecs

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread David Nolen
Which is out of date.


On Thu, Apr 25, 2013 at 12:47 PM, Alice dofflt...@gmail.com wrote:

 Found this blog post written by fogus:

 To provide this level of flexibility Clojure establishes a level of
 indirection. Specifically, all function lookups through a Var occur,
 at the lowest level, through an atomic volatile. This happens every
 time that a function bound using the def/defn special forms is called.
 This indirection is not amenable to HotSpot optimizations.


 http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/

 On Apr 25, 10:19 pm, Alice dofflt...@gmail.com wrote:
  I create many small methods in java without worrying about the
  performance since it's usually the target of inline optimization. For
  example,
 
  public class Foo {
public static long inc(long l) {
  return ++l;
}
 
public static long f1() {
  long l = 0;
  for (int i=0; i  10; i++) {
l++;
  }
  return l;
}
 
public static long f2() {
  long l = 0;
  for (int i=0; i  10; i++) {
l = inc(l);
  }
  return l;
}
 
  }
 
  (time (Foo/f1))
  (time (Foo/f1))
  (time (Foo/f1))
  (time (Foo/f2))
  (time (Foo/f2))
  (time (Foo/f2))
 
  Elapsed time: 23.309532 msecs
  Elapsed time: 23.333039 msecs
  Elapsed time: 21.714753 msecs
  Elapsed time: 22.943366 msecs
  Elapsed time: 21.612783 msecs
  Elapsed time: 21.71376 msecs
 
  But clojure funtions seem to be never get inlined.
 
  (def obj (Object.))
 
  (defn getObj [] obj)
 
  (defn f1 [] obj)
  (defn f2 [] (getObj))
 
  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f1)))
  (time (dotimes [n 1] (f2)))
  (time (dotimes [n 1] (f2)))
  (time (dotimes [n 1] (f2)))
 
  Elapsed time: 67.758744 msecs
  Elapsed time: 68.555306 msecs
  Elapsed time: 68.725147 msecs
  Elapsed time: 104.810459 msecs
  Elapsed time: 103.273618 msecs
  Elapsed time: 103.374595 msecs

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Alice
Care to elaborate which part is out of date?

On Apr 26, 1:48 am, David Nolen dnolen.li...@gmail.com wrote:
 Which is out of date.







 On Thu, Apr 25, 2013 at 12:47 PM, Alice dofflt...@gmail.com wrote:
  Found this blog post written by fogus:

  To provide this level of flexibility Clojure establishes a level of
  indirection. Specifically, all function lookups through a Var occur,
  at the lowest level, through an atomic volatile. This happens every
  time that a function bound using the def/defn special forms is called.
  This indirection is not amenable to HotSpot optimizations.

 http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic...

  On Apr 25, 10:19 pm, Alice dofflt...@gmail.com wrote:
   I create many small methods in java without worrying about the
   performance since it's usually the target of inline optimization. For
   example,

   public class Foo {
     public static long inc(long l) {
       return ++l;
     }

     public static long f1() {
       long l = 0;
       for (int i=0; i  10; i++) {
         l++;
       }
       return l;
     }

     public static long f2() {
       long l = 0;
       for (int i=0; i  10; i++) {
         l = inc(l);
       }
       return l;
     }

   }

   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f1))
   (time (Foo/f2))
   (time (Foo/f2))
   (time (Foo/f2))

   Elapsed time: 23.309532 msecs
   Elapsed time: 23.333039 msecs
   Elapsed time: 21.714753 msecs
   Elapsed time: 22.943366 msecs
   Elapsed time: 21.612783 msecs
   Elapsed time: 21.71376 msecs

   But clojure funtions seem to be never get inlined.

   (def obj (Object.))

   (defn getObj [] obj)

   (defn f1 [] obj)
   (defn f2 [] (getObj))

   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f1)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))
   (time (dotimes [n 1] (f2)))

   Elapsed time: 67.758744 msecs
   Elapsed time: 68.555306 msecs
   Elapsed time: 68.725147 msecs
   Elapsed time: 104.810459 msecs
   Elapsed time: 103.273618 msecs
   Elapsed time: 103.374595 msecs

  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 David Nolen dnolen.li...@gmail.com

 + :inline metadata


Which is not documented anywhere and might as well not exist for regular
Clojure users.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread David Nolen
(doc definline)


On Thu, Apr 25, 2013 at 1:17 PM, Michael Klishin 
michael.s.klis...@gmail.com wrote:


 2013/4/25 David Nolen dnolen.li...@gmail.com

 + :inline metadata


 Which is not documented anywhere and might as well not exist for regular
 Clojure users.
 --
 MK

 http://github.com/michaelklishin
 http://twitter.com/michaelklishin

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 David Nolen dnolen.li...@gmail.com

 (doc definline)


Macro
  Experimental - like defmacro, except defines a named function whose
  body is the expansion, calls to which may be expanded inline as if
  it were a macro. Cannot be used with variadic () args.

If you think this is useful to regular users (who have no idea about the
compiler internals or JVM), you may want to reconsider.

Also, if I don't know definline exists, how do I find out? Books, docs
don't mention it.
1 page on clojure.org that you have to find doesn't count.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Softaddicts
user= (apropos inline)
(definline)
user= (doc inline)
..




 2013/4/25 David Nolen dnolen.li...@gmail.com
 
  (doc definline)
 
 
 Macro
   Experimental - like defmacro, except defines a named function whose
   body is the expansion, calls to which may be expanded inline as if
   it were a macro. Cannot be used with variadic () args.
 
 If you think this is useful to regular users (who have no idea about the
 compiler internals or JVM), you may want to reconsider.
 
 Also, if I don't know definline exists, how do I find out? Books, docs
 don't mention it.
 1 page on clojure.org that you have to find doesn't count.
 -- 
 MK
 
 http://github.com/michaelklishin
 http://twitter.com/michaelklishin
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 Softaddicts lprefonta...@softaddicts.ca

 user= (apropos inline)
 (definline)


Yeah, yeah. It all starts with (apropos apropos), right?

I knew it.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Softaddicts
You asked a simple question, you got a plain answer.
Now if you are still grunting there's not much I can do about that.

I do agree that the doc string could be a bit more descriptive.
But what does it mean to be understandable by normal users ?
I am still trying to size what is a normal Lisp user these days.
No single answer seems to fit so far.

When I first used Lisp, inlining meant writing pseudo assembly code
right through your Lisp code most of the time using a macro.
Procedural languages had most of the time
extension directives to allow you to force inlining at your will.

Inlining is a concept that existed for more than 40 years in many programming
languages. It's not anything new. Now if you want to use it but do not
understand the implications, well it's not the doc string that will explain
it to you.

To me, definline looks simpler than any of the above.

Luc

 2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
  user= (apropos inline)
  (definline)
 
 
 Yeah, yeah. It all starts with (apropos apropos), right?
 
 I knew it.
 -- 
 MK
 
 http://github.com/michaelklishin
 http://twitter.com/michaelklishin
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 Softaddicts lprefonta...@softaddicts.ca

 Inlining is a concept that existed for more than 40 years in many
 programming
 languages. It's not anything new.


The OP probably know what inlining is because, hm, the subject has that
word.
Then she is recommended to use something that only technically has
documentation (and is marked as experimental) and is not known or used by
many.

I've pointed that out. Problem?
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Gary Trakhman
You could come up with definline yourself by thinking about what inlining
is and wrapping things in macros, it seems to me the real problem definline
solves is to also be able to use the output as a function, which is more
about keeping convenience than performance gains.

I think the people who want to know about this stuff will find it, it took
me a couple hours myself when I worked through this thought process a year
or so ago.

/lurk


On Thu, Apr 25, 2013 at 2:05 PM, Softaddicts lprefonta...@softaddicts.cawrote:

 You asked a simple question, you got a plain answer.
 Now if you are still grunting there's not much I can do about that.

 I do agree that the doc string could be a bit more descriptive.
 But what does it mean to be understandable by normal users ?
 I am still trying to size what is a normal Lisp user these days.
 No single answer seems to fit so far.

 When I first used Lisp, inlining meant writing pseudo assembly code
 right through your Lisp code most of the time using a macro.
 Procedural languages had most of the time
 extension directives to allow you to force inlining at your will.

 Inlining is a concept that existed for more than 40 years in many
 programming
 languages. It's not anything new. Now if you want to use it but do not
 understand the implications, well it's not the doc string that will explain
 it to you.

 To me, definline looks simpler than any of the above.

 Luc

  2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
   user= (apropos inline)
   (definline)
  
 
  Yeah, yeah. It all starts with (apropos apropos), right?
 
  I knew it.
  --
  MK
 
  http://github.com/michaelklishin
  http://twitter.com/michaelklishin
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Softaddicts
Well you looked quite outraged that it could not be found easily. I 
demonstrated 
that doc strings can be easily searched.

Of course my answer comes in total antagonism with your usual position about 
the 
bad state of the existing documentation which is incomplete, wrong, ... and so 
forth.

Your reaction does not suprise me, your behavior is quite predictable.
Like an old vinyl record with all these scratches being played over and over
again.

Definline may be tagged as experimental but defrecord, defprotocol, ... are 
marked
as being in alpha stage. Does this prevents you from using them ?

I hope so, especially in production.

Luc P.


 2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
  Inlining is a concept that existed for more than 40 years in many
  programming
  languages. It's not anything new.
 
 
 The OP probably know what inlining is because, hm, the subject has that
 word.
 Then she is recommended to use something that only technically has
 documentation (and is marked as experimental) and is not known or used by
 many.
 
 I've pointed that out. Problem?
 -- 
 MK
 
 http://github.com/michaelklishin
 http://twitter.com/michaelklishin
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 Softaddicts lprefonta...@softaddicts.ca

 Of course my answer comes in total antagonism with your usual position
 about the
 bad state of the existing documentation which is incomplete, wrong, ...
 and so forth.

Your reaction does not suprise me, your behavior is quite predictable.
 Like an old vinyl record with all these scratches being played over and
 over
 again.


Nothing has changed w.r.t. Clojure/core's attitude towards documentation
and making it easy
for other people to contribute documentation improvements that are rapidly
integrated instead of
gathering dust in JIRA for many months.

Why would I suddenly start singing praises to something that is broken and
does not change?

Sorry pal, someone has to periodically remind those in control of Clojure
that we are exactly
where we were years ago. And that the entire community has to put up with
this.


 Definline may be tagged as experimental but defrecord, defprotocol, ...
 are marked
 as being in alpha stage. Does this prevents you from using them ?


Those are mentioned in every book and are widely used. It would be crazy to
break
those by now. Makes a bit of difference when it comes to recommending
features to people, don't you
think?
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Softaddicts
May I suggest you an upgrade  ?

http://www.ehow.com/how_6949396_record-78-vinyl-records-cd.html

 2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
  Of course my answer comes in total antagonism with your usual position
  about the
  bad state of the existing documentation which is incomplete, wrong, ...
  and so forth.
 
 Your reaction does not suprise me, your behavior is quite predictable.
  Like an old vinyl record with all these scratches being played over and
  over
  again.
 
 
 Nothing has changed w.r.t. Clojure/core's attitude towards documentation
 and making it easy
 for other people to contribute documentation improvements that are rapidly
 integrated instead of
 gathering dust in JIRA for many months.
 
 Why would I suddenly start singing praises to something that is broken and
 does not change?
 
 Sorry pal, someone has to periodically remind those in control of Clojure
 that we are exactly
 where we were years ago. And that the entire community has to put up with
 this.
 
 
  Definline may be tagged as experimental but defrecord, defprotocol, ...
  are marked
  as being in alpha stage. Does this prevents you from using them ?
 
 
 Those are mentioned in every book and are widely used. It would be crazy to
 break
 those by now. Makes a bit of difference when it comes to recommending
 features to people, don't you
 think?
 -- 
 MK
 
 http://github.com/michaelklishin
 http://twitter.com/michaelklishin
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
--
Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Gary Trakhman
Good vinyls are considered higher quality by audiophiles, because there are
less stages in between the mastering and amplification.  There is more
potential of better performance.

It can be considered a real-world case of inlining.


On Thu, Apr 25, 2013 at 3:16 PM, Softaddicts lprefonta...@softaddicts.cawrote:

 May I suggest you an upgrade  ?

 http://www.ehow.com/how_6949396_record-78-vinyl-records-cd.html

  2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
   Of course my answer comes in total antagonism with your usual position
   about the
   bad state of the existing documentation which is incomplete, wrong, ...
   and so forth.
  
  Your reaction does not suprise me, your behavior is quite predictable.
   Like an old vinyl record with all these scratches being played over and
   over
   again.
  
  
  Nothing has changed w.r.t. Clojure/core's attitude towards documentation
  and making it easy
  for other people to contribute documentation improvements that are
 rapidly
  integrated instead of
  gathering dust in JIRA for many months.
 
  Why would I suddenly start singing praises to something that is broken
 and
  does not change?
 
  Sorry pal, someone has to periodically remind those in control of Clojure
  that we are exactly
  where we were years ago. And that the entire community has to put up with
  this.
 
 
   Definline may be tagged as experimental but defrecord, defprotocol, ...
   are marked
   as being in alpha stage. Does this prevents you from using them ?
  
 
  Those are mentioned in every book and are widely used. It would be crazy
 to
  break
  those by now. Makes a bit of difference when it comes to recommending
  features to people, don't you
  think?
  --
  MK
 
  http://github.com/michaelklishin
  http://twitter.com/michaelklishin
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread Michael Klishin
2013/4/25 Softaddicts lprefonta...@softaddicts.ca

 May I suggest you an upgrade  ?

 http://www.ehow.com/how_6949396_record-78-vinyl-records-cd.html


Ah, a batch of fresh preaching from Mr. Defend Clojure/core At All Costs.

Best Canadian export since Wayne Gretzky!
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do functions never get inlined by jvm?

2013-04-25 Thread gaz jones
There seems to be some rule that given sufficient time and enough
participants, all threads deteriorate into an argument about the current
state of clojure documentation and a huge post from Tim Daly regarding
literate programming in 3...2...1...


On Thu, Apr 25, 2013 at 2:23 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 Good vinyls are considered higher quality by audiophiles, because there
 are less stages in between the mastering and amplification.  There is more
 potential of better performance.

 It can be considered a real-world case of inlining.


 On Thu, Apr 25, 2013 at 3:16 PM, Softaddicts 
 lprefonta...@softaddicts.cawrote:

 May I suggest you an upgrade  ?

 http://www.ehow.com/how_6949396_record-78-vinyl-records-cd.html

  2013/4/25 Softaddicts lprefonta...@softaddicts.ca
 
   Of course my answer comes in total antagonism with your usual position
   about the
   bad state of the existing documentation which is incomplete, wrong,
 ...
   and so forth.
  
  Your reaction does not suprise me, your behavior is quite predictable.
   Like an old vinyl record with all these scratches being played over
 and
   over
   again.
  
  
  Nothing has changed w.r.t. Clojure/core's attitude towards documentation
  and making it easy
  for other people to contribute documentation improvements that are
 rapidly
  integrated instead of
  gathering dust in JIRA for many months.
 
  Why would I suddenly start singing praises to something that is broken
 and
  does not change?
 
  Sorry pal, someone has to periodically remind those in control of
 Clojure
  that we are exactly
  where we were years ago. And that the entire community has to put up
 with
  this.
 
 
   Definline may be tagged as experimental but defrecord, defprotocol,
 ...
   are marked
   as being in alpha stage. Does this prevents you from using them ?
  
 
  Those are mentioned in every book and are widely used. It would be
 crazy to
  break
  those by now. Makes a bit of difference when it comes to recommending
  features to people, don't you
  think?
  --
  MK
 
  http://github.com/michaelklishin
  http://twitter.com/michaelklishin
 
  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 --
 Softaddictslprefonta...@softaddicts.ca sent by ibisMail from my ipad!

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: Do functions never get inlined by jvm?

2013-04-25 Thread u1204
...0? :-)

Tim Daly

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Do you know which language the clojure is written by?

2013-04-22 Thread ljcppunix
Hi,
Do you know which language the clojure is written by?

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do you know which language the clojure is written by?

2013-04-22 Thread dennis zhuang
Java.

But there is some clojure version written in ruby,python,c# and javascript.


2013/4/22 ljcppu...@gmail.com

 Hi,
 Do you know which language the clojure is written by?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
庄晓丹
Email:killme2...@gmail.com xzhu...@avos.com
Site:   http://fnil.net
Twitter:  @killme2008

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Do you know which language the clojure is written by?

2013-04-22 Thread Michael Klishin
2013/4/22 dennis zhuang killme2...@gmail.com

 But there is some clojure version written in ruby,python,c# and javascript.


ClojureScript compiler is not implemented in JavaScript, it emits
JavaScript but implemented
in Clojure. Hopefully will be self-hosted one day!
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Something goofy you can do in Clojure.

2013-04-09 Thread Cedric Greevey
This may look mildly surprising, and suggests one more thing *not* to ever
do in production code:

user= (+ .3 1.7)
2.1
user=

:)

Shouldn't be hard to figure out how to put a repl in a state where that
expression will evaluate to that result. I'm sure mathematicians everywhere
are deeply offended by the clojure reader now. :)

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Something goofy you can do in Clojure.

2013-04-09 Thread Mark Engelberg
What version are you running?

As far as I know, .3 isn't even a valid representation for a number --
you'd have to write it as 0.3.  So I'm not sure where you're running that
code snippet such that you don't get an immediate error.

On 1.5.1:

= (+ 0.3 1.7)
2.0

That said, I think most programmers know that floating point
representations of numbers are inexact.  That's why, if you care about
exactness, you should write:

= (+ 0.3M 1.7M)
2.0M

On Tue, Apr 9, 2013 at 1:53 AM, Cedric Greevey cgree...@gmail.com wrote:

 This may look mildly surprising, and suggests one more thing *not* to ever
 do in production code:

 user= (+ .3 1.7)
 2.1
 user=

 :)

 Shouldn't be hard to figure out how to put a repl in a state where that
 expression will evaluate to that result. I'm sure mathematicians everywhere
 are deeply offended by the clojure reader now. :)

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Something goofy you can do in Clojure.

2013-04-09 Thread Jim foo.bar

Hey Mark, don't get paranoid :)... this is all Cedric did!

user= (def .3 0.4)
#'user/.3
user= (+ .3 1.7)
2.1

Jim



On 09/04/13 10:46, Mark Engelberg wrote:

What version are you running?

As far as I know, .3 isn't even a valid representation for a number -- 
you'd have to write it as 0.3.  So I'm not sure where you're running 
that code snippet such that you don't get an immediate error.


On 1.5.1:

= (+ 0.3 1.7)
2.0

That said, I think most programmers know that floating point 
representations of numbers are inexact.  That's why, if you care about 
exactness, you should write:


= (+ 0.3M 1.7M)
2.0M

On Tue, Apr 9, 2013 at 1:53 AM, Cedric Greevey cgree...@gmail.com 
mailto:cgree...@gmail.com wrote:


This may look mildly surprising, and suggests one more thing *not*
to ever do in production code:

user= (+ .3 1.7)
2.1
user=

:)

Shouldn't be hard to figure out how to put a repl in a state where
that expression will evaluate to that result. I'm sure
mathematicians everywhere are deeply offended by the clojure
reader now. :)

-- 
-- 
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
mailto: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
mailto: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 unsubscribe from this group and stop receiving emails from it,
send an email to clojure+unsubscr...@googlegroups.com
mailto:clojure%2bunsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient 
with your first post.

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google 
Groups Clojure group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.




--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups Clojure group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Something goofy you can do in Clojure.

2013-04-09 Thread Niels van Klaveren
In Clojure 1.5.1:

= (+ .3 1.7)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: .3 
in this context, compiling:(NO_SOURCE_PATH:1:1) 

So the only way you can do this is if you def'd .3 before

= (def .3 0.4)
= (+ .3 1.7)
2.1

On Tuesday, April 9, 2013 10:53:06 AM UTC+2, Cedric Greevey wrote:

 This may look mildly surprising, and suggests one more thing *not* to ever 
 do in production code:

 user= (+ .3 1.7)
 2.1
 user=

 :)

 Shouldn't be hard to figure out how to put a repl in a state where that 
 expression will evaluate to that result. I'm sure mathematicians everywhere 
 are deeply offended by the clojure reader now. :)



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Something goofy you can do in Clojure.

2013-04-09 Thread Gary Verhaegen
Technically, this is a user error, since . (dot) is not a valid character
inside user-defined symbols. Clojure does mostly take the stance that it is
a sharp tool and you are allowed to cut yourself, should you really want to.

See http://clojure.org/reader for reference, especially these two sentences
:

Symbols begin with a non-numeric character and can contain alphanumeric
characters and *, +, !, -, _, and ?
Symbols beginning or ending with '.' are reserved by Clojure.


On 9 April 2013 11:51, Niels van Klaveren niels.vanklave...@gmail.comwrote:

 In Clojure 1.5.1:

 = (+ .3 1.7)
 CompilerException java.lang.RuntimeException: Unable to resolve symbol: .3
 in this context, compiling:(NO_SOURCE_PATH:1:1)

 So the only way you can do this is if you def'd .3 before

 = (def .3 0.4)
 = (+ .3 1.7)
 2.1


 On Tuesday, April 9, 2013 10:53:06 AM UTC+2, Cedric Greevey wrote:

 This may look mildly surprising, and suggests one more thing *not* to
 ever do in production code:

 user= (+ .3 1.7)
 2.1
 user=

 :)

 Shouldn't be hard to figure out how to put a repl in a state where that
 expression will evaluate to that result. I'm sure mathematicians everywhere
 are deeply offended by the clojure reader now. :)

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Something goofy you can do in Clojure.

2013-04-09 Thread Mark Engelberg
Ah.  That's pretty funny :)

On Tue, Apr 9, 2013 at 2:48 AM, Jim foo.bar jimpil1...@gmail.com wrote:

  Hey Mark, don't get paranoid :)... this is all Cedric did!

 user= (def .3 0.4)
 #'user/.3

 user= (+ .3 1.7)
 2.1

 Jim




 On 09/04/13 10:46, Mark Engelberg wrote:

 What version are you running?

 As far as I know, .3 isn't even a valid representation for a number --
 you'd have to write it as 0.3.  So I'm not sure where you're running that
 code snippet such that you don't get an immediate error.

 On 1.5.1:

 = (+ 0.3 1.7)
 2.0

 That said, I think most programmers know that floating point
 representations of numbers are inexact.  That's why, if you care about
 exactness, you should write:

 = (+ 0.3M 1.7M)
 2.0M

 On Tue, Apr 9, 2013 at 1:53 AM, Cedric Greevey cgree...@gmail.com wrote:

   This may look mildly surprising, and suggests one more thing *not* to
 ever do in production code:

  user= (+ .3 1.7)
 2.1
  user=

 :)

  Shouldn't be hard to figure out how to put a repl in a state where that
 expression will evaluate to that result. I'm sure mathematicians everywhere
 are deeply offended by the clojure reader now. :)

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: IMPORTANT: For Potential GSoC 2012 mentors, do this now please!

2013-04-09 Thread Mikera
I'm also stuck on this. I see the My Dashboard link, but no list of 
projects. does someone need to accept me as a mentor first perhaps?

On Tuesday, 10 April 2012 00:54:46 UTC+8, David Nolen wrote:

 You don't see a My Dashboard link?

 On Mon, Apr 9, 2012 at 12:52 PM, Phil Hagelberg ph...@hagelb.orgjavascript:
  wrote:

 On Mon, Apr 9, 2012 at 7:17 AM, David Nolen 
 dnolen...@gmail.comjavascript: 
 wrote:
  Yes apply to be a mentor - sorry it wasn't more clear - this could have 
 been
  done at anytime.
 
  Also important DO NOT associate yourself with a proposal in Confluence 
 - you
  MUST do this in Melange.

 Feeling a bit slow... I don't see any proposals listed for Clojure in
 Melange even though I've been accepted as a mentor:

 http://www.google-melange.com/gsoc/org/google/gsoc2012/clojure

 How does one associate themselves with a proposal?

 -Phil

 --
 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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: IMPORTANT: For Potential GSoC 2012 mentors, do this now please!

2013-04-09 Thread Daniel Solano Gómez
Hello, Mike,

On Tue Apr  9 17:31 2013, Mikera wrote:
 I'm also stuck on this. I see the My Dashboard link, but no list of 
 projects. does someone need to accept me as a mentor first perhaps?

I got your mentorship application and you should be approved now as a
mentor.  I plan on writing some more detailed instructions for students
and mentors in the next few days.  I haven't yet had the chance to look
around and figure out the Melange app.

Sincerely,

Daniel



 
 On Tuesday, 10 April 2012 00:54:46 UTC+8, David Nolen wrote:
 
  You don't see a My Dashboard link?
 
  On Mon, Apr 9, 2012 at 12:52 PM, Phil Hagelberg 
  ph...@hagelb.orgjavascript:
   wrote:
 
  On Mon, Apr 9, 2012 at 7:17 AM, David Nolen 
  dnolen...@gmail.comjavascript: 
  wrote:
   Yes apply to be a mentor - sorry it wasn't more clear - this could have 
  been
   done at anytime.
  
   Also important DO NOT associate yourself with a proposal in Confluence 
  - you
   MUST do this in Melange.
 
  Feeling a bit slow... I don't see any proposals listed for Clojure in
  Melange even though I've been accepted as a mentor:
 
  http://www.google-melange.com/gsoc/org/google/gsoc2012/clojure
 
  How does one associate themselves with a proposal?
 
  -Phil
 
  --
  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
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 


signature.asc
Description: Digital signature


Re: If there is no nil values, why do I get null pointer exception?

2013-03-22 Thread Gary Verhaegen
I would guess the NPE comes from the form (xml/emit-str
(xml/map-Element next-movie-as-map)), given that (conj nil nil) does
not throw.

Perhaps try to isolate the problem in a smaller chunk of code, and
then file a bug with the data.xml library?

On 21 March 2013 19:16, larry google groups lawrencecloj...@gmail.com wrote:

 I am getting a null pointer exception in the line where I conj into the
 vector. I added the pprint so I could see what was going on. I am confused
 by the outcome:

 (defn convert-json-to-xml [json-as-flat-maps]
   (reduce
(fn [vector-of-strings next-movie-as-map]
  (println next move as map: )
  (println (pp/pprint next-movie-as-map))
  (if (seq next-movie-as-map)
(conj vector-of-strings (xml/emit-str (xml/map-Element
 next-movie-as-map)))
vector-of-strings))
[]
json-as-flat-maps))

 The pprint is showing me this:

 {:film_64209.9096316473 513e67e3c07f5dd74551,
  :cast_member_64209.9096316473 5148c50dc07f5db4233a,
  :title_64209.9096316473 Sound design,
  :director ,
  :runtime 5,
  :movie-id 513e67e3c07f5dd74551,
  :title Two Islands,
  :thumb

 https://s3.amazonaws.com/tribeca_cms_production/uploads/uploads/film/photo_1/513e67e3c07f5dd74551/small_TWO_ISLANDS_2_pubs.jpg;,
  :categories [Documentary],
  :youtube_url ,
  :website_url ,
  :name_64209.9096316473 Svante Colérus,
  :description
  Two Islands is film about two enormous waste dumps in New York City. The
 first was once the largest dump in the world. The other, a cemetery of
 unknowns, is still in use. Two Islands bluntly asks, what does the existence
 of these two huge mountains of economic and social waste and rejected
 surplus tell us about our civilization and the so-called richest nation in
 the world? What kind of legacy will future archaeologists see?}


 Any thoughts about what triggers a null pointer exception? I am using this
 XML library:

 http://clojure.github.com/data.xml/






 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: If there is no nil values, why do I get null pointer exception?

2013-03-22 Thread larry google groups
Thank you. 

I need to import this json and convert it to XML or CSV:

http://tribecafilm.com/api/xomo/films.json

I'm guessing that the problem is the nested vector of cast members, which 
my project manager has asked me to flatten (I think she is planning work 
with this in Microsoft Excel, eventually). 

I start with rows like this: 

  ;;
  ;; {
  ;; 
Thumb_img_url:https:\/\/s3.amazonaws.com\/tribeca_cms_production\/uploads\/uploads\/film\/photo_1\/513a82d1c07f5d471377\/small_odayaka__1_PUBS.jpg,
  ;; website_url:,
  ;; director:,
  ;; large_img_url:null,
  ;; youtube_url:,
  ;; title:Odayaka,
  ;; runtime:100,
  ;; id:513a82d1c07f5d471377,
  ;; categories:[Drama],
  ;; description:The Great East Japan Earthquake has just 
struck, the waters of the ensuing tsunami finally rolling back into the 
sea. In the comparative safety of Tokyo, two wives and a child living in 
the same apartment building have nothing to do but wait for their 
husbands\u2019 return. Nobuteru Uchida finds a striking emotional core to 
the shock of March 11, 2011, crafting a tender and intelligent narrative on 
the internal effects of an unspeakable national tragedy.,
  ;; cast:
  ;; [
  ;; {
  ;; _id:513a82d1c07f5d471378,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Jo Keita,
  ;;  Aya Saito,
  ;; title:Associate Producer
  ;; },
  ;; {
  ;; _id:513a82d1c07f5d471379,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Kiki Sugino,
  ;;  Yukiko Shinohara,
  ;;  Takeshi Yamamoto,
  ;;  Ami Watanabe,
  ;;  Yu Koyanagi,
  ;;  Makiko Watanabe,
  ;; title:Cast
  ;; },
  ;; {
  ;; _id:513a82d1c07f5d47137a,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Shinichi Tsunoda,
  ;; title:Cinematographer
  ;; },
  ;; {
  ;;  _id:513a82d1c07f5d47137b,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Jo Keita,
  ;; title:Composer
  ;; },
  ;; {
  ;;  _id:513a82d1c07f5d47137c,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Nobuteru Uchida,
  ;; title:Director
  ;; },
  ;; {
  ;; _id:513a82d1c07f5d47137d,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Nobuteru Uchida,
  ;; title:Editor
  ;; },
  ;; {
  ;; _id:513a82d1c07f5d47137e,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Kousuke Ono,
  ;; title:Executive Producer
  ;; },
  ;; {
  ;;  _id:513a82d1c07f5d47137f,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Kiki Sugino,
  ;;  Eric Nyari,
  ;; title:Producer
  ;; },
  ;; {
  ;; _id:513a82d1c07f5d471380,
  ;; film_id:513a82d1c07f5d471377,
  ;; name:Nobuteru Uchida,
  ;; title:Screenwriter
  ;; }
  ;; ]
  ;; },


I flattened this by inventing keys for the nested cast members. But now my 
different rows have different keys. I guess I should pad this so they all 
have the same rows? Or maybe I've missed something obvious? Seems like I 
shouldn't have to engage in ugly hacks for something this simple. 




On Friday, March 22, 2013 11:37:31 AM UTC-4, Gary Verhaegen wrote:

 I would guess the NPE comes from the form (xml/emit-str 
 (xml/map-Element next-movie-as-map)), given that (conj nil nil) does 
 not throw. 

 Perhaps try to isolate the problem in a smaller chunk of code, and 
 then file a bug with the data.xml library? 

 On 21 March 2013 19:16, larry google groups 
 lawrenc...@gmail.comjavascript: 
 wrote: 
  
  I am getting a null pointer exception in the line where I conj into the 
  vector. I added the pprint so I could see what was going on. I am 
 confused 
  by the outcome: 
  
  (defn convert-json-to-xml [json-as-flat-maps] 
(reduce 
 (fn [vector-of-strings next-movie-as-map] 
   (println next move as map: ) 
   (println (pp/pprint next-movie-as-map)) 
   (if (seq next-movie-as-map) 
 (conj vector-of-strings (xml/emit-str (xml/map-Element 
  next-movie-as-map))) 
 vector-of-strings)) 
 [] 
 json-as-flat-maps)) 
  
  The pprint is showing me this: 
  
  {:film_64209.9096316473 513e67e3c07f5dd74551, 
   :cast_member_64209.9096316473 5148c50dc07f5db4233a, 
   :title_64209.9096316473 Sound design

Re: If there is no nil values, why do I get null pointer exception?

2013-03-22 Thread larry google groups
Hmm, maybe I simply nested the XML elements incorrectly (though 
NullPointerException doesn't give much information about the real problem). 
I eventually imported this URL: 

http://tribecafilm.com/api/xomo/films.json

With this code: 


(defn transform-cast-members-into-xml [cast-members-listed-in-a-vector]
  (timbre/spy :debug  return value of transform-cast-members-into-xml 
  (reduce
   (fn [vector-of-xml-elements next-cast-member-as-map]
   (conj vector-of-xml-elements (xml/element :cast-member {}
 (xml/element 
:film-id {} (get next-cast-member-as-map film_id))
 (xml/element 
:cast-member-name {} (get next-cast-member-as-map name))
 (xml/element 
:cast-member-title {} (get next-cast-member-as-map title)
 []
 cast-members-listed-in-a-vector)))

(defn transform-movie-json-to-vector-of-xml-elements [json-to-convert]
  (timbre/spy :debug return value of 
transform-movie-json-to-vector-of-xml-elements
  (reduce
   (fn [vector-of-xml-elements next-json-map]
 (if (seq next-json-map)
   (conj vector-of-xml-elements (xml/element :movie {}
 (xml/element 
:thumb_img_url {} (get next-json-map Thumb_img_url))
 (xml/element 
:website_url {} (get next-json-map website_url))
 (xml/element 
:director {} (get next-json-map director))
 (xml/element 
:youtube_url {} (get next-json-map youtube_url))
 (xml/element 
:title {} (get next-json-map title))
 (xml/element 
:runtime {} (get next-json-map runtime))
 (xml/element 
:_id {} (get next-json-map _id))
 (xml/element 
:categories {} (st/join , (get next-json-map categories)))
 (xml/element 
:description {} (get next-json-map description))
 (xml/element 
:cast {} (transform-cast-members-into-xml (get next-json-map cast)
   vector-of-xml-elements))
   []
   json-to-convert)))

(defn json-to-xml [request]
  (let [string-to-convert (slurp 
http://tribecafilm.com/api/xomo/films.json;)
json-to-convert (json/read-str string-to-convert)
vector-of-xml-elements 
(transform-movie-json-to-vector-of-xml-elements json-to-convert)
final-xml-element (xml/element :movies {} vector-of-xml-elements)
page-string (xml/emit-str final-xml-element)
response-headers {:status 200
  :headers {Content-Type text/plain}
  :body page-string }]
response-headers))







On Friday, March 22, 2013 12:02:25 PM UTC-4, larry google groups wrote:

 Thank you. 

 I need to import this json and convert it to XML or CSV:

 http://tribecafilm.com/api/xomo/films.json

 I'm guessing that the problem is the nested vector of cast members, which 
 my project manager has asked me to flatten (I think she is planning work 
 with this in Microsoft Excel, eventually). 

 I start with rows like this: 

   ;;
   ;; {
   ;; Thumb_img_url:https:\/\/s3.amazonaws.com
 \/tribeca_cms_production\/uploads\/uploads\/film\/photo_1\/513a82d1c07f5d471377\/small_odayaka__1_PUBS.jpg,
   ;; website_url:,
   ;; director:,
   ;; large_img_url:null,
   ;; youtube_url:,
   ;; title:Odayaka,
   ;; runtime:100,
   ;; id:513a82d1c07f5d471377,
   ;; categories:[Drama],
   ;; description:The Great East Japan Earthquake has just 
 struck, the waters of the ensuing tsunami finally rolling back into the 
 sea. In the comparative safety of Tokyo, two wives and a child living in 
 the same apartment building have nothing to do but wait for their 
 husbands\u2019 return. Nobuteru Uchida finds a striking emotional core to 
 the shock of March 11, 2011, crafting a tender and intelligent narrative on 
 the internal effects of an unspeakable national tragedy.,
   ;; cast:
   ;; [
   ;; {
   ;; _id:513a82d1c07f5d471378,
   ;; film_id:513a82d1c07f5d471377,
   ;; name:Jo Keita,
   ;;  Aya Saito,
   ;; title:Associate Producer
   ;; },
   ;; {
   ;; _id:513a82d1c07f5d471379

If there is no nil values, why do I get null pointer exception?

2013-03-21 Thread larry google groups

I am getting a null pointer exception in the line where I conj into the 
vector. I added the pprint so I could see what was going on. I am confused 
by the outcome:

(defn convert-json-to-xml [json-as-flat-maps]
  (reduce
   (fn [vector-of-strings next-movie-as-map]
 (println next move as map: )
 (println (pp/pprint next-movie-as-map))
 (if (seq next-movie-as-map)
   (conj vector-of-strings (xml/emit-str (xml/map-Element 
next-movie-as-map)))
   vector-of-strings))
   []
   json-as-flat-maps))

The pprint is showing me this: 

{:film_64209.9096316473 513e67e3c07f5dd74551,
 :cast_member_64209.9096316473 5148c50dc07f5db4233a,
 :title_64209.9096316473 Sound design,
 :director ,
 :runtime 5,
 :movie-id 513e67e3c07f5dd74551,
 :title Two Islands,
 :thumb
 
https://s3.amazonaws.com/tribeca_cms_production/uploads/uploads/film/photo_1/513e67e3c07f5dd74551/small_TWO_ISLANDS_2_pubs.jpg;,
 :categories [Documentary],
 :youtube_url ,
 :website_url ,
 :name_64209.9096316473 Svante Colérus,
 :description
 Two Islands is film about two enormous waste dumps in New York City. The 
first was once the largest dump in the world. The other, a cemetery of 
unknowns, is still in use. Two Islands bluntly asks, what does the 
existence of these two huge mountains of economic and social waste and 
rejected surplus tell us about our civilization and the so-called richest 
nation in the world? What kind of legacy will future archaeologists see?}


Any thoughts about what triggers a null pointer exception? I am using this 
XML library: 

http://clojure.github.com/data.xml/






-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups
 Might be a silly suggestion but are the first 3 connections leading to 
 redirects (30x's) ???

Interesting idea. I will check. You are thinking that I should:

{http.protocol.allow-circular-redirects false

yes?


On Mar 5, 2:39 am, Marc Boschma marc.bosc...@gmail.com wrote:
 Might be a silly suggestion but are the first 3 connections leading to 
 redirects (30x's) ???

 On 05/03/2013, at 10:18 AM, larry google groups lawrencecloj...@gmail.com 
 wrote:









  So, thanks to Michael Klishin, Aaron Cohen, Frank Siebenlist and Craig
  Brozefsky I am now able to correctly ping the Omniture API. But I am
  getting a strange behavior from the clj-http library. It makes 4 calls
  to the API server, even though the first call is successful.

  When I look here:

 https://github.com/dakrone/clj-http

  I see it says:

  ;; Apache's http client automatically retries on IOExceptions, if you
  ;; would like to handle these retries yourself, you can specify a
  ;; :retry-handler.

  So, since it re-tries, I should assume that it is encountering an
  IOException. But I get a successful response on the first try, so what
  would the IOException be?

  Because clj-http uses Slingshot, I have wrapped it in a try+ / catch
  Object o block. And I print the o to the terminal, and yet I am not
  seeing anything in the terminal. So where is the IOException? How do I
  find it?

  This is the actual function I use to ping the Omniture API:

  (defn omniture-call-api [url-with-queue-method api-payload headers]
   (timbre/spy :debug  return value of omniture-call-api 
               (try+
                 (http-client/post url-with-queue-method
                                   {:body api-payload
                                    :debug true
                                    :debug-body true
                                    :insecure true
                                    :headers {X-Api-Version 2
                                              X-WSSE headers}
                                    :content-type :json
                                    :socket-timeout 4000
                                    :conn-timeout 4000
                                    :accept :json
                                    :client-params
  {http.protocol.allow-circular-redirects true
                                                    http.useragent
  clj-http}})
                 (catch Object o (println (pp/pprint o))

  If there is an IOException, why doesn't this line catch it?

                 (catch Object o (println (pp/pprint o))

  I read here that catch Object o is the correct way to catch
  everything, using Slingshot:

 https://github.com/scgilardi/slingshot/issues/24

  So why would I not see this error?

  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with 
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups 
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an 
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups
As near as I can see, the 1st request is successful, and then the next
3 return with 401 errors, plus the message The nonce has already been
used. Clearly, the 2nd, 3rd and 4th attempts should fail, because
they are re-using the nonce that was already used in the first
request, and a nonce can only be used once. So it makes sense that
they would get a 401 error, but it makes no sense that they would ever
get called at all, because why would the code re-try if there was no
IOException.

One of the requests returns with a 200 status:

 {:trace-redirects [https://api2.omniture.com/admin/1.3/rest/?
method=Report.QueueOvertime], :request-time 1658, :status
200, :headers {date Mon, 04 Mar 2013 21:23:44 GMT, server
Omniture AWS/2.0.0, vary Accept-Encoding, content-encoding
gzip, xserver www322, content-length 83, content-type
application/json, connection close}, :body {\status\:\queued
\,\statusMsg\:\Your report has been queued\,\reportID\:xxx}}

I assume this is the first request, because if it wasn't then it would
get the error This nonce has already been used. And why would the
later requests get the 401 error This nonce has already been used
unless the first request had succeeded?

My understanding is the code will retry up to 4 times if it encounters
an IOException. But in my case it seems to be retrying even though
here was no IOException.

Maybe this is some kind of timing issue?






On Mar 5, 10:50 am, larry google groups lawrencecloj...@gmail.com
wrote:
  Might be a silly suggestion but are the first 3 connections leading to 
  redirects (30x's) ???

 Interesting idea. I will check. You are thinking that I should:

 {http.protocol.allow-circular-redirects false

 yes?

 On Mar 5, 2:39 am, Marc Boschma marc.bosc...@gmail.com wrote:







  Might be a silly suggestion but are the first 3 connections leading to 
  redirects (30x's) ???

  On 05/03/2013, at 10:18 AM, larry google groups lawrencecloj...@gmail.com 
  wrote:

   So, thanks to Michael Klishin, Aaron Cohen, Frank Siebenlist and Craig
   Brozefsky I am now able to correctly ping the Omniture API. But I am
   getting a strange behavior from the clj-http library. It makes 4 calls
   to the API server, even though the first call is successful.

   When I look here:

  https://github.com/dakrone/clj-http

   I see it says:

   ;; Apache's http client automatically retries on IOExceptions, if you
   ;; would like to handle these retries yourself, you can specify a
   ;; :retry-handler.

   So, since it re-tries, I should assume that it is encountering an
   IOException. But I get a successful response on the first try, so what
   would the IOException be?

   Because clj-http uses Slingshot, I have wrapped it in a try+ / catch
   Object o block. And I print the o to the terminal, and yet I am not
   seeing anything in the terminal. So where is the IOException? How do I
   find it?

   This is the actual function I use to ping the Omniture API:

   (defn omniture-call-api [url-with-queue-method api-payload headers]
    (timbre/spy :debug  return value of omniture-call-api 
                (try+
                  (http-client/post url-with-queue-method
                                    {:body api-payload
                                     :debug true
                                     :debug-body true
                                     :insecure true
                                     :headers {X-Api-Version 2
                                               X-WSSE headers}
                                     :content-type :json
                                     :socket-timeout 4000
                                     :conn-timeout 4000
                                     :accept :json
                                     :client-params
   {http.protocol.allow-circular-redirects true
                                                     http.useragent
   clj-http}})
                  (catch Object o (println (pp/pprint o))

   If there is an IOException, why doesn't this line catch it?

                  (catch Object o (println (pp/pprint o))

   I read here that catch Object o is the correct way to catch
   everything, using Slingshot:

  https://github.com/scgilardi/slingshot/issues/24

   So why would I not see this error?

   --
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clojure@googlegroups.com
   Note that posts from new members are moderated - please be patient with 
   your first post.
   To unsubscribe from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
   ---
   You received this message because you are subscribed to the Google Groups 
   Clojure group.
   To unsubscribe from this group and stop receiving emails from it, send an 
   email to clojure+unsubscr...@googlegroups.com.
   For more options, visithttps

Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread Meikel Brandmeyer (kotarak)
Hi,

silly question are you using the call in a sequence pipeline with pmap or 
mapcat or the like? Or does clj-http that under the covers?

Kind regards
Meikel

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups

 silly question are you using the call in a sequence pipeline with pmap or
 mapcat or the like? Or does clj-http that under the covers?

Those are good questions. Until I get this working I have been doing
the simplest thing possible, which is simply starting the app, and
then having the app make the call to Omniture as one of the first
things it does on startup.

I will dig into clj-http to see what it is doing under the covers.

I am curious, do you have a suspicion about something? A theory?




On Mar 5, 11:17 am, Meikel Brandmeyer (kotarak) m...@kotka.de
wrote:
 Hi,

 silly question are you using the call in a sequence pipeline with pmap or
 mapcat or the like? Or does clj-http that under the covers?

 Kind regards
 Meikel

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups
This is strange. An IOException is thrown, but it seems to do with
with the retry, which should never exist in the first place, unless an
IOException has been thrown:


 clj-http has thrown this exception:
{:trace-redirects
 [https://api2.omniture.com/admin/1.3/rest/?
method=Report.QueueOvertime],
 :request-time 885,
 :status 401,
 :headers
 {date Tue, 05 Mar 2013 19:14:46 GMT,
  server Omniture AWS/2.0.0,
  www-authenticate
  WSSE realm=\Omniture REST Api\, profile=\UsernameToken\,
  xserver www811,
  content-length 90,
  content-type application/json,
  connection close},
 :body
 {\error\:\The nonce
(NGQ1ODc4NmU3M2QyY2I5MmIyOTIzOWFiN2Q4ODc1NjQ=) has already been used
\}}




On Mar 5, 12:45 pm, larry google groups lawrencecloj...@gmail.com
wrote:
  silly question are you using the call in a sequence pipeline with pmap or
  mapcat or the like? Or does clj-http that under the covers?

 Those are good questions. Until I get this working I have been doing
 the simplest thing possible, which is simply starting the app, and
 then having the app make the call to Omniture as one of the first
 things it does on startup.

 I will dig into clj-http to see what it is doing under the covers.

 I am curious, do you have a suspicion about something? A theory?

 On Mar 5, 11:17 am, Meikel Brandmeyer (kotarak) m...@kotka.de
 wrote:







  Hi,

  silly question are you using the call in a sequence pipeline with pmap or
  mapcat or the like? Or does clj-http that under the covers?

  Kind regards
  Meikel

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups
Out of frustration, I have decided to surpress the re-tries. This
worries me -- I hate to bury a problem without understanding it. But
the retries are burying the actual queries. This page:

https://github.com/dakrone/clj-http

says:

;; Apache's http client automatically retries on IOExceptions, if you
;; would like to handle these retries yourself, you can specify a
;; :retry-handler. Return true to retry, false to stop trying:
(client/post http://example.org; {:multipart [[title Foo]
   [Content/type text/
plain]
 
[file (clojure.java.io/file /tmp/missing-file)]]
   :retry-handler (fn [ex try-count
http-context]
(println Got:
ex)
(if ( try-count
4) false true))})

So I have re-written my function so that the re-tries are always
suppressed:


(defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug  return value of omniture-call-api 
  (try+
(http-client/post url-with-queue-method
  {:body api-payload
   :debug true
   :debug-body true
   :insecure true
   :headers {X-Api-Version 2
 X-WSSE headers}
   :content-type :json
   :socket-timeout 4000
   :conn-timeout 4000
   :accept :json
   :client-params
{http.protocol.allow-circular-redirects false
   http.useragent
clj-http}
   :retry-handler (fn [ex try-count
http-context]
false)
   })
(catch Object o (catch-clj-http-exceptions o)


I will have to come back to this later, when I have more time, and try
to figure out what is going wrong.



On Mar 5, 2:19 pm, larry google groups lawrencecloj...@gmail.com
wrote:
 This is strange. An IOException is thrown, but it seems to do with
 with the retry, which should never exist in the first place, unless an
 IOException has been thrown:

  clj-http has thrown this exception:
 {:trace-redirects
  [https://api2.omniture.com/admin/1.3/rest/?
 method=Report.QueueOvertime],
  :request-time 885,
  :status 401,
  :headers
  {date Tue, 05 Mar 2013 19:14:46 GMT,
   server Omniture AWS/2.0.0,
   www-authenticate
   WSSE realm=\Omniture REST Api\, profile=\UsernameToken\,
   xserver www811,
   content-length 90,
   content-type application/json,
   connection close},
  :body
  {\error\:\The nonce
 (NGQ1ODc4NmU3M2QyY2I5MmIyOTIzOWFiN2Q4ODc1NjQ=) has already been used
 \}}

 On Mar 5, 12:45 pm, larry google groups lawrencecloj...@gmail.com
 wrote:







   silly question are you using the call in a sequence pipeline with pmap or
   mapcat or the like? Or does clj-http that under the covers?

  Those are good questions. Until I get this working I have been doing
  the simplest thing possible, which is simply starting the app, and
  then having the app make the call to Omniture as one of the first
  things it does on startup.

  I will dig into clj-http to see what it is doing under the covers.

  I am curious, do you have a suspicion about something? A theory?

  On Mar 5, 11:17 am, Meikel Brandmeyer (kotarak) m...@kotka.de
  wrote:

   Hi,

   silly question are you using the call in a sequence pipeline with pmap or
   mapcat or the like? Or does clj-http that under the covers?

   Kind regards
   Meikel

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-05 Thread larry google groups
I look here:

https://github.com/dakrone/clj-http/issues/45

and I see the original reasoning for :trace-redirects

add a key like :trace-redirects in the response containing the
ordered list of traversed uris. This would allow clients to know what
was the final uri fetched more easily than now (I think the only way
is to set :save-request? and check the url inside the req). It could
also be very useful for caching purpose (knowing all the uris which
are equivalent to the terminal one). 

The README says: :trace-redirects will contain the chain of the
redirections followed.

But in my case, I don't think I'm getting redirected. My :trace-
redirects only has 1 URL, and it is the URL that I POSTed to.

[:trace-redirects [https://api2.omniture.com/admin/1.3/rest/?
method=Report.QueueOvertime]] [:request-time 1601][:status 200]
[:headers {date Tue, 05 Mar 2013 19:57:24 GMT, server Omniture
AWS/2.0.0, vary Accept-Encoding, content-encoding gzip,
xserver www503, content-length 83, content-type application/
json, connection close}][:body {\status\:\queued\,\statusMsg
\:\Your report has been queued\,\reportID\:83928267}]


Maybe the POST gets redirected to something with the same URL? The
status I see is 200, not 301 or 302.







On Mar 5, 2:33 pm, larry google groups lawrencecloj...@gmail.com
wrote:
 Out of frustration, I have decided to surpress the re-tries. This
 worries me -- I hate to bury a problem without understanding it. But
 the retries are burying the actual queries. This page:

 https://github.com/dakrone/clj-http

 says:

 ;; Apache's http client automatically retries on IOExceptions, if you
 ;; would like to handle these retries yourself, you can specify a
 ;; :retry-handler. Return true to retry, false to stop trying:
 (client/post http://example.org; {:multipart [[title Foo]
                                                [Content/type text/
 plain]

 [file (clojure.java.io/file /tmp/missing-file)]]
                                    :retry-handler (fn [ex try-count
 http-context]
                                                     (println Got:
 ex)
                                                     (if ( try-count
 4) false true))})

 So I have re-written my function so that the re-tries are always
 suppressed:

 (defn omniture-call-api [url-with-queue-method api-payload headers]
   (timbre/spy :debug  return value of omniture-call-api 
               (try+
                 (http-client/post url-with-queue-method
                                   {:body api-payload
                                    :debug true
                                    :debug-body true
                                    :insecure true
                                    :headers {X-Api-Version 2
                                              X-WSSE headers}
                                    :content-type :json
                                    :socket-timeout 4000
                                    :conn-timeout 4000
                                    :accept :json
                                    :client-params
 {http.protocol.allow-circular-redirects false
                                                    http.useragent
 clj-http}
                                    :retry-handler (fn [ex try-count
 http-context]
                                                     false)
                                    })
                 (catch Object o (catch-clj-http-exceptions o)

 I will have to come back to this later, when I have more time, and try
 to figure out what is going wrong.

 On Mar 5, 2:19 pm, larry google groups lawrencecloj...@gmail.com
 wrote:







  This is strange. An IOException is thrown, but it seems to do with
  with the retry, which should never exist in the first place, unless an
  IOException has been thrown:

   clj-http has thrown this exception:
  {:trace-redirects
   [https://api2.omniture.com/admin/1.3/rest/?
  method=Report.QueueOvertime],
   :request-time 885,
   :status 401,
   :headers
   {date Tue, 05 Mar 2013 19:14:46 GMT,
    server Omniture AWS/2.0.0,
    www-authenticate
    WSSE realm=\Omniture REST Api\, profile=\UsernameToken\,
    xserver www811,
    content-length 90,
    content-type application/json,
    connection close},
   :body
   {\error\:\The nonce
  (NGQ1ODc4NmU3M2QyY2I5MmIyOTIzOWFiN2Q4ODc1NjQ=) has already been used
  \}}

  On Mar 5, 12:45 pm, larry google groups lawrencecloj...@gmail.com
  wrote:

silly question are you using the call in a sequence pipeline with pmap 
or
mapcat or the like? Or does clj-http that under the covers?

   Those are good questions. Until I get this working I have been doing
   the simplest thing possible, which is simply starting the app, and
   then having the app make the call to Omniture as one of the first
   things it does on startup.

   I will dig into clj-http to see what it is doing under the covers.

   I am curious, do you have a suspicion about something? A theory?

   On Mar 5, 11:17 am

why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread larry google groups
I need to get a GMT date. I found this page on StackOverflow:

http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java

It gives this example:

SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
HH:mm:ss);
dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

I thought I was following it closely with (this is inside of a (let)
statement):

 date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
 gmt-timezone (TimeZone/getTimeZone GMT)
 date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
timezone)
 created (.format date-formatter-set-to-gmt-time (new Date))

but this line:

  created (.format date-formatter-set-to-gmt-time (new Date))

gives me:

java.lang.NullPointerException: null
 Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
   omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
for-api-call

Can anyone tell me why?







-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread Ray Miller
You've assigned to date-formatter-set-to-gmt-time the return value
from the setTimeZone method call. This method returns null, hence the
null pointer exception when you try to call the format method. 'doto'
might help here, like:

(let [gmt-date-formatter (doto (SimpleDateFormat. -MMM-dd HH:mm:ss)
   (.setTimeZone
(TimeZone/getTimeZone GMT)))]
(.format gmt-date-formatter (Date.)))

On 4 March 2013 16:50, larry google groups lawrencecloj...@gmail.com wrote:
 I need to get a GMT date. I found this page on StackOverflow:

 http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java

 It gives this example:

 SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
 HH:mm:ss);
 dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

 I thought I was following it closely with (this is inside of a (let)
 statement):

  date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
  gmt-timezone (TimeZone/getTimeZone GMT)
  date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
 timezone)
  created (.format date-formatter-set-to-gmt-time (new Date))

 but this line:

   created (.format date-formatter-set-to-gmt-time (new Date))

 gives me:

 java.lang.NullPointerException: null
  Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
 for-api-call

 Can anyone tell me why?







 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread larry google groups
Thank you. That is very helpful.

On Mar 4, 3:17 pm, Ray Miller r...@1729.org.uk wrote:
 You've assigned to date-formatter-set-to-gmt-time the return value
 from the setTimeZone method call. This method returns null, hence the
 null pointer exception when you try to call the format method. 'doto'
 might help here, like:

 (let [gmt-date-formatter (doto (SimpleDateFormat. -MMM-dd HH:mm:ss)
                                                    (.setTimeZone
 (TimeZone/getTimeZone GMT)))]
         (.format gmt-date-formatter (Date.)))

 On 4 March 2013 16:50, larry google groups lawrencecloj...@gmail.com wrote:







  I need to get a GMT date. I found this page on StackOverflow:

 http://stackoverflow.com/questions/308683/how-can-i-get-the-current-d...

  It gives this example:

  SimpleDateFormat dateFormatGmt = new SimpleDateFormat(-MMM-dd
  HH:mm:ss);
  dateFormatGmt.setTimeZone(TimeZone.getTimeZone(GMT));

  I thought I was following it closely with (this is inside of a (let)
  statement):

   date-formatter (new SimpleDateFormat -MM-dd'T'HH:mm:ss)
   gmt-timezone (TimeZone/getTimeZone GMT)
   date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
  timezone)
   created (.format date-formatter-set-to-gmt-time (new Date))

  but this line:

    created (.format date-formatter-set-to-gmt-time (new Date))

  gives me:

  java.lang.NullPointerException: null
           Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
             omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
  for-api-call

  Can anyone tell me why?

  --
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with 
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups 
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an 
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




how do I find an IO exception triggering retries in clj-http?

2013-03-04 Thread larry google groups

So, thanks to Michael Klishin, Aaron Cohen, Frank Siebenlist and Craig
Brozefsky I am now able to correctly ping the Omniture API. But I am
getting a strange behavior from the clj-http library. It makes 4 calls
to the API server, even though the first call is successful.

When I look here:

https://github.com/dakrone/clj-http

I see it says:

;; Apache's http client automatically retries on IOExceptions, if you
;; would like to handle these retries yourself, you can specify a
;; :retry-handler.

So, since it re-tries, I should assume that it is encountering an
IOException. But I get a successful response on the first try, so what
would the IOException be?

Because clj-http uses Slingshot, I have wrapped it in a try+ / catch
Object o block. And I print the o to the terminal, and yet I am not
seeing anything in the terminal. So where is the IOException? How do I
find it?

This is the actual function I use to ping the Omniture API:

(defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug  return value of omniture-call-api 
  (try+
(http-client/post url-with-queue-method
  {:body api-payload
   :debug true
   :debug-body true
   :insecure true
   :headers {X-Api-Version 2
 X-WSSE headers}
   :content-type :json
   :socket-timeout 4000
   :conn-timeout 4000
   :accept :json
   :client-params
{http.protocol.allow-circular-redirects true
   http.useragent
clj-http}})
(catch Object o (println (pp/pprint o))

If there is an IOException, why doesn't this line catch it?

(catch Object o (println (pp/pprint o))

I read here that catch Object o is the correct way to catch
everything, using Slingshot:

https://github.com/scgilardi/slingshot/issues/24

So why would I not see this error?






-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I find an IO exception triggering retries in clj-http?

2013-03-04 Thread Marc Boschma
Might be a silly suggestion but are the first 3 connections leading to 
redirects (30x's) ???

On 05/03/2013, at 10:18 AM, larry google groups lawrencecloj...@gmail.com 
wrote:

 
 So, thanks to Michael Klishin, Aaron Cohen, Frank Siebenlist and Craig
 Brozefsky I am now able to correctly ping the Omniture API. But I am
 getting a strange behavior from the clj-http library. It makes 4 calls
 to the API server, even though the first call is successful.
 
 When I look here:
 
 https://github.com/dakrone/clj-http
 
 I see it says:
 
 ;; Apache's http client automatically retries on IOExceptions, if you
 ;; would like to handle these retries yourself, you can specify a
 ;; :retry-handler.
 
 So, since it re-tries, I should assume that it is encountering an
 IOException. But I get a successful response on the first try, so what
 would the IOException be?
 
 Because clj-http uses Slingshot, I have wrapped it in a try+ / catch
 Object o block. And I print the o to the terminal, and yet I am not
 seeing anything in the terminal. So where is the IOException? How do I
 find it?
 
 This is the actual function I use to ping the Omniture API:
 
 (defn omniture-call-api [url-with-queue-method api-payload headers]
  (timbre/spy :debug  return value of omniture-call-api 
  (try+
(http-client/post url-with-queue-method
  {:body api-payload
   :debug true
   :debug-body true
   :insecure true
   :headers {X-Api-Version 2
 X-WSSE headers}
   :content-type :json
   :socket-timeout 4000
   :conn-timeout 4000
   :accept :json
   :client-params
 {http.protocol.allow-circular-redirects true
   http.useragent
 clj-http}})
(catch Object o (println (pp/pprint o))
 
 If there is an IOException, why doesn't this line catch it?
 
(catch Object o (println (pp/pprint o))
 
 I read here that catch Object o is the correct way to catch
 everything, using Slingshot:
 
 https://github.com/scgilardi/slingshot/issues/24
 
 So why would I not see this error?
 
 
 
 
 
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
 
 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Why is java.io/do-copy defined private

2013-02-22 Thread Jürgen Hötzel
Hi,

I implemented 

(defmethod (var-get #'io/do-copy) [Path Path] [#^Path input #^Path output 
opts] ...) 

for fast NIO2 io, but had to do the var-get workaround because do-copy is 
defined private.

Jürgen

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I am ignorant of the JVM, and of Java, so I am sure this is a dumb question.

I need to post to the Omniture API. They offer some sample code here: 

https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

That code depends on a Base64Coder class which they offer in a zip file. I 
downloaded it and did: 

javac Base64Coder.java

and this gave me Base64Coder.class. 

I created my project with Leinengen2. 

I thought maybe I could just copy Base64Coder.class to the target/classes 
folder, but then how would I reference it in my code? 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
When I just do something obvious, like in mpdv.core:

(ns mpdv.core
  (:gen-class)
  (:import
   (Base64Coder))

and then call its static methods I get: 

Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
(wrong name: com/omniture/security/Base64Coder), 
compiling:(mpdv/core.clj:130)




On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip file. I 
 downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the target/classes 
 folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Why is java.io/do-copy defined private

2013-02-22 Thread Stuart Sierra
Hi Jürgen,

Things are declared :private usually because the author of the library 
didn't want to commit to a public API function in future releases. The 
var-get trick works fine (you can also write @#'io/do-copy) but there's no 
promise that `do-copy` will stay the same between releases. As long as 
you're aware that your code might be broken by a future release, there's no 
reason not to extend it as you did.

Since Clojure is designed to be compatible with JDK 1.5, it doesn't use 
NIO2 anywhere. Perhaps conditional compilation (a possible feature for 
Clojure 1.6) will make it possible to support newer JDK features like NIO2.

-S




On Friday, February 22, 2013 12:23:27 PM UTC-5, Jürgen Hötzel wrote:

 Hi,

 I implemented 

 (defmethod (var-get #'io/do-copy) [Path Path] [#^Path input #^Path output 
 opts] ...) 

 for fast NIO2 io, but had to do the var-get workaround because do-copy is 
 defined private.

 Jürgen



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Ah, I see. This is a polygot project, which Leiningen describes here:

https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

That worked for me. Leiningen  saves the day again. 


On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip file. 
 I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the target/classes 
 folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Maybe I spoke too soon. I have now stepped into the Twilight Zone. Changes 
I make to files do not get built when a try to run lein. 

Just to get some kind of reaction from Leinengen I just put random garbage 
in the ns clause of my core.clj:

(ns lkjlkljlkjlkj  mpdv.core
  (:gen-class)
  (:import
   (java.net URL URLConnection)
   (java.io ByteArrayInputStream BufferedReader IOException InputStream 
InputStreamReader OutputStreamWriter UnsupportedEncodingException)
   (java.text SimpleDateFormat)
   (java.util Date)
   (java.security MessageDigest)
   (org.apache.commons.mail SimpleEmail HtmlEmail)
   (org.joda.time.format DateTimeFormat ISODateTimeFormat)
   (Base64Coder)
   (lkjlkjlkjoiuoiu))

This should have caused an error, but instead, when I did lein uberjar 
everything compiled -- but compiled without any of the changes I've made 
during the last 30 minutes. 

In the terminal, from the same terminal that I run lein uberjar I can 
run: 

cat src/mpdv/core.clj

and I see my changes, including the random garbage that I just wrote, but 
somehow, if I then type lein uberjar lein does not see it. 

I do not know if this issue is related, but following the advice about 
polygots, given here: 

https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

I added this to my project.clj file: 

  :source-paths  [src/mpdv]
  :java-source-paths [src/java]

Did I do something wrong here? 

Why is Leinengen still compiling, even though the source code is full of 
garbage? 




On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:

 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip file. 
 I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I see this sentence:

Having one source root contain another (e.g. src and src/java) can cause 
obscure problems.

but I have: 

src/
java/
mpdv/

Which I assume is what Leinengen is asking for. 


On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. Changes 
 I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random garbage 
 in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException InputStream 
 InputStreamReader OutputStreamWriter UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein uberjar 
 everything compiled -- but compiled without any of the changes I've made 
 during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I can 
 run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, but 
 somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice about 
 polygots, given here: 

 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full of 
 garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:

 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
At least if I put random junk in the project.clj, Leinengen dies with an 
error:

(defproject mpdv 0.1.0
  :dependencies [[org.clojure/clojure 1.4.0]
 [ring 1.1.5] 
 [ring/ring-jetty-adapter 1.1.5] 
 [org.clojure/data.json 0.2.0]
 [org.clojure/java.jdbc 0.2.3]
 [mysql/mysql-connector-java 5.1.6]

jlkjlkjlkjlkj
 [clj-yaml 0.4.0]
 [clj-time 0.4.4]


lein uberjar
nth not supported on this type: Symbol

But otherwise, it is not seeing the changes I make to the code. 




On Friday, February 22, 2013 5:28:17 PM UTC-5, larry google groups wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can cause 
 obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException InputStream 
 InputStreamReader OutputStreamWriter UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein uberjar 
 everything compiled -- but compiled without any of the changes I've made 
 during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I can 
 run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, but 
 somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice about 
 polygots, given here: 

 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full of 
 garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:


 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
No, src is root for all Clojure. That means that your java root is under 
the Clojure root. Move java to top-level.

On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can cause 
 obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException InputStream 
 InputStreamReader OutputStreamWriter UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein uberjar 
 everything compiled -- but compiled without any of the changes I've made 
 during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I can 
 run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, but 
 somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice about 
 polygots, given here: 

 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full of 
 garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:


 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Hmm, okay. Seems to be working with:

  :source-paths  [src]
  :java-source-paths [src_java]

The example on the Leiningen site might be clear to those who know the JVM, 
but it was not clear to me. 

But now I have the earlier problem: 

Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

Not sure how to import this. I tried a simple:

(ns mpdv.core
  (:gen-class)
  (:import
   (Base64Coder))

But that does not work. 


On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is under 
 the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can 
 cause obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException InputStream 
 InputStreamReader OutputStreamWriter UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein uberjar 
 everything compiled -- but compiled without any of the changes I've made 
 during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I can 
 run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, 
 but somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice about 
 polygots, given here: 


 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full of 
 garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:


 https://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups 
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.NoClassDefFoundError: Base64Coder 
 (wrong name: com/omniture/security/Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code here: 

 https://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I include a single class file from someone else's library?

2013-02-22 Thread AtKaaZ
use fully qualified name for that class, I think?


On Fri, Feb 22, 2013 at 11:50 PM, larry google groups 
lawrencecloj...@gmail.com wrote:

 Hmm, okay. Seems to be working with:

   :source-paths  [src]
   :java-source-paths [src_java]

 The example on the Leiningen site might be clear to those who know the
 JVM, but it was not clear to me.

 But now I have the earlier problem:

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 Not sure how to import this. I tried a simple:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 But that does not work.


 On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is under
 the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can
 cause obscure problems.

 but I have:

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for.


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone.
 Changes I make to files do not get built when a try to run lein.

 Just to get some kind of reaction from Leinengen I just put random
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException
 InputStream InputStreamReader OutputStreamWriter
 UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein
 uberjar everything compiled -- but compiled without any of the changes
 I've made during the last 30 minutes.

 In the terminal, from the same terminal that I run lein uberjar I can
 run:

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote,
 but somehow, if I then type lein uberjar lein does not see it.

 I do not know if this issue is related, but following the advice about
 polygots, given here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file:

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here?

 Why is Leinengen still compiling, even though the source code is full
 of garbage?




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups
 wrote:

 Ah, I see. This is a polygot project, which Leiningen describes here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again.


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get:

 Exception in thread main java.lang.**NoClassDefFoundError:
 Base64Coder (wrong name: com/omniture/security/**Base64Coder),
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb
 question.

 I need to post to the Omniture API. They offer some sample code
 here:

 https://developer.omniture.**com/en_US/blog/calling-rest-**
 api-in-javahttps://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip
 file. I downloaded it and did:

 javac Base64Coder.java

 and this gave me Base64Coder.class.

 I created my project with Leinengen2.

 I thought maybe I could just copy Base64Coder.class to the
 target/classes folder, but then how would I reference it in my code?


  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
Please correct me if I'm wrong or incomplete

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
I don't get it. Whats the fully qualified name of a standalone file that i 
have locally?

On Friday, February 22, 2013 6:03:13 PM UTC-5, AtKaaZ wrote:

 use fully qualified name for that class, I think?


 On Fri, Feb 22, 2013 at 11:50 PM, larry google groups 
 lawrenc...@gmail.com javascript: wrote:

 Hmm, okay. Seems to be working with:

   :source-paths  [src]
   :java-source-paths [src_java]

 The example on the Leiningen site might be clear to those who know the 
 JVM, but it was not clear to me. 

 But now I have the earlier problem: 

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 Not sure how to import this. I tried a simple:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 But that does not work. 


 On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is under 
 the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups 
 wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can 
 cause obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups 
 wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException 
 InputStream InputStreamReader OutputStreamWriter 
 UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein 
 uberjar everything compiled -- but compiled without any of the changes 
 I've made during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I 
 can run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, 
 but somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice about 
 polygots, given here: 

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full 
 of garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups 
 wrote:

 Ah, I see. This is a polygot project, which Leiningen describes 
 here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups 
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.**NoClassDefFoundError: 
 Base64Coder (wrong name: com/omniture/security/**Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code 
 here: 

 https://developer.omniture.**com/en_US/blog/calling-rest-**
 api-in-javahttps://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 


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

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
this:

  (:import
   (Base64Coder))

gets me:

Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

this:

  (:import
   (src_java Base64Coder))

gets me:

Exception in thread main java.lang.ClassNotFoundException: 
src_java.Base64Coder, compiling:(core.clj:1)








On Friday, February 22, 2013 6:14:42 PM UTC-5, larry google groups wrote:

 I don't get it. Whats the fully qualified name of a standalone file that i 
 have locally?

 On Friday, February 22, 2013 6:03:13 PM UTC-5, AtKaaZ wrote:

 use fully qualified name for that class, I think?


 On Fri, Feb 22, 2013 at 11:50 PM, larry google groups 
 lawrenc...@gmail.com wrote:

 Hmm, okay. Seems to be working with:

   :source-paths  [src]
   :java-source-paths [src_java]

 The example on the Leiningen site might be clear to those who know the 
 JVM, but it was not clear to me. 

 But now I have the earlier problem: 

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 Not sure how to import this. I tried a simple:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 But that does not work. 


 On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is 
 under the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups 
 wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can 
 cause obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups 
 wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException 
 InputStream InputStreamReader OutputStreamWriter 
 UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein 
 uberjar everything compiled -- but compiled without any of the changes 
 I've made during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I 
 can run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just wrote, 
 but somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice 
 about polygots, given here: 

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is full 
 of garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups 
 wrote:

 Ah, I see. This is a polygot project, which Leiningen describes 
 here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups 
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.**NoClassDefFoundError: 
 Base64Coder (wrong name: com/omniture/security/**Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a dumb 
 question.

 I need to post to the Omniture API. They offer some sample code 
 here: 

 https://developer.omniture.**com/en_US/blog/calling-rest-**
 api-in-javahttps://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a zip 
 file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder, but then how would I reference it in my code? 


  -- 
 -- 
 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
 Note that posts from new members

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread Marko Topolnik
You must know the package name of your class. Is it really in the default 
package? That would be almost impossible since you can't even refer to such 
a class from another class in a normal package.

On Saturday, February 23, 2013 12:20:15 AM UTC+1, larry google groups wrote:

 this:

   (:import
(Base64Coder))

 gets me:

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 this:

   (:import
(src_java Base64Coder))

 gets me:

 Exception in thread main java.lang.ClassNotFoundException: 
 src_java.Base64Coder, compiling:(core.clj:1)








 On Friday, February 22, 2013 6:14:42 PM UTC-5, larry google groups wrote:

 I don't get it. Whats the fully qualified name of a standalone file that 
 i have locally?

 On Friday, February 22, 2013 6:03:13 PM UTC-5, AtKaaZ wrote:

 use fully qualified name for that class, I think?


 On Fri, Feb 22, 2013 at 11:50 PM, larry google groups 
 lawrenc...@gmail.com wrote:

 Hmm, okay. Seems to be working with:

   :source-paths  [src]
   :java-source-paths [src_java]

 The example on the Leiningen site might be clear to those who know the 
 JVM, but it was not clear to me. 

 But now I have the earlier problem: 

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 Not sure how to import this. I tried a simple:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 But that does not work. 


 On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is 
 under the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups 
 wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can 
 cause obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups 
 wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException 
 InputStream InputStreamReader OutputStreamWriter 
 UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein 
 uberjar everything compiled -- but compiled without any of the changes 
 I've made during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I 
 can run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just 
 wrote, but somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice 
 about polygots, given here: 

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is 
 full of garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups 
 wrote:

 Ah, I see. This is a polygot project, which Leiningen describes 
 here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups 
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.**NoClassDefFoundError: 
 Base64Coder (wrong name: com/omniture/security/**Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a 
 dumb question.

 I need to post to the Omniture API. They offer some sample code 
 here: 

 https://developer.omniture.**com/en_US/blog/calling-rest-**
 api-in-javahttps://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a 
 zip file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy

Re: how do I include a single class file from someone else's library?

2013-02-22 Thread larry google groups
Oh, I see, the file declared a package. This worked:

   (com.omniture.security Base64Coder))

The Java stuff still confuses me. 

Thanks for all the help.


On Friday, February 22, 2013 6:20:15 PM UTC-5, larry google groups wrote:

 this:

   (:import
(Base64Coder))

 gets me:

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 this:

   (:import
(src_java Base64Coder))

 gets me:

 Exception in thread main java.lang.ClassNotFoundException: 
 src_java.Base64Coder, compiling:(core.clj:1)








 On Friday, February 22, 2013 6:14:42 PM UTC-5, larry google groups wrote:

 I don't get it. Whats the fully qualified name of a standalone file that 
 i have locally?

 On Friday, February 22, 2013 6:03:13 PM UTC-5, AtKaaZ wrote:

 use fully qualified name for that class, I think?


 On Fri, Feb 22, 2013 at 11:50 PM, larry google groups 
 lawrenc...@gmail.com wrote:

 Hmm, okay. Seems to be working with:

   :source-paths  [src]
   :java-source-paths [src_java]

 The example on the Leiningen site might be clear to those who know the 
 JVM, but it was not clear to me. 

 But now I have the earlier problem: 

 Caused by: java.lang.RuntimeException: No such namespace: Base64Coder

 Not sure how to import this. I tried a simple:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 But that does not work. 


 On Friday, February 22, 2013 5:31:49 PM UTC-5, Marko Topolnik wrote:

 No, src is root for all Clojure. That means that your java root is 
 under the Clojure root. Move java to top-level.

 On Friday, February 22, 2013 11:28:17 PM UTC+1, larry google groups 
 wrote:

 I see this sentence:

 Having one source root contain another (e.g. src and src/java) can 
 cause obscure problems.

 but I have: 

 src/
 java/
 mpdv/

 Which I assume is what Leinengen is asking for. 


 On Friday, February 22, 2013 5:23:28 PM UTC-5, larry google groups 
 wrote:

 Maybe I spoke too soon. I have now stepped into the Twilight Zone. 
 Changes I make to files do not get built when a try to run lein. 

 Just to get some kind of reaction from Leinengen I just put random 
 garbage in the ns clause of my core.clj:

 (ns lkjlkljlkjlkj  mpdv.core
   (:gen-class)
   (:import
(java.net URL URLConnection)
(java.io ByteArrayInputStream BufferedReader IOException 
 InputStream InputStreamReader OutputStreamWriter 
 UnsupportedEncodingException)
(java.text SimpleDateFormat)
(java.util Date)
(java.security MessageDigest)
(org.apache.commons.mail SimpleEmail HtmlEmail)
(org.joda.time.format DateTimeFormat ISODateTimeFormat)
(Base64Coder)
(lkjlkjlkjoiuoiu))

 This should have caused an error, but instead, when I did lein 
 uberjar everything compiled -- but compiled without any of the changes 
 I've made during the last 30 minutes. 

 In the terminal, from the same terminal that I run lein uberjar I 
 can run: 

 cat src/mpdv/core.clj

 and I see my changes, including the random garbage that I just 
 wrote, but somehow, if I then type lein uberjar lein does not see it. 

 I do not know if this issue is related, but following the advice 
 about polygots, given here: 

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 I added this to my project.clj file: 

   :source-paths  [src/mpdv]
   :java-source-paths [src/java]

 Did I do something wrong here? 

 Why is Leinengen still compiling, even though the source code is 
 full of garbage? 




 On Friday, February 22, 2013 5:01:15 PM UTC-5, larry google groups 
 wrote:

 Ah, I see. This is a polygot project, which Leiningen describes 
 here:

 https://github.com/**technomancy/leiningen/blob/**
 stable/doc/MIXED_PROJECTS.mdhttps://github.com/technomancy/leiningen/blob/stable/doc/MIXED_PROJECTS.md

 That worked for me. Leiningen  saves the day again. 


 On Friday, February 22, 2013 4:25:04 PM UTC-5, larry google groups 
 wrote:

 When I just do something obvious, like in mpdv.core:

 (ns mpdv.core
   (:gen-class)
   (:import
(Base64Coder))

 and then call its static methods I get: 

 Exception in thread main java.lang.**NoClassDefFoundError: 
 Base64Coder (wrong name: com/omniture/security/**Base64Coder), 
 compiling:(mpdv/core.clj:130)




 On Friday, February 22, 2013 4:18:00 PM UTC-5, larry google groups 
 wrote:

 I am ignorant of the JVM, and of Java, so I am sure this is a 
 dumb question.

 I need to post to the Omniture API. They offer some sample code 
 here: 

 https://developer.omniture.**com/en_US/blog/calling-rest-**
 api-in-javahttps://developer.omniture.com/en_US/blog/calling-rest-api-in-java

 That code depends on a Base64Coder class which they offer in a 
 zip file. I downloaded it and did: 

 javac Base64Coder.java

 and this gave me Base64Coder.class. 

 I created my project with Leinengen2. 

 I thought maybe I could just copy Base64Coder.class to the 
 target/classes folder

how do I reference a var that is in my core namespace?

2013-02-21 Thread larry google groups
I wanted to have some functions run when an app starts, and I wanted this 
to be configurable, because I plan to use the same architecture for several 
apps. So I thought I could have the function names as strings inside of 
maps inside of a set (that I sort), in a config file. And I thought I could 
use ns-resolve *ns* symbol to turn the strings into references to the vars 
where the function definitions are stored. But somehow this is not working. 
I have this right now, in mpdv.core, which is the core namespace is an app 
I created with lein:


(defn process-startup-hooks []
  2013-02-21- remember, each row in hooks is a map: {:order-of-events 1, 
:event-name 'connect-to-database'}
  (connect-to-database)
  (let [hooks (sort-by :order-of-events 
(:events-called-when-the-app-starts-hooks @um/interactions))]
(doseq [x hooks]
  (let [event-as-symbol (symbol (:event-name x))
event (ns-resolve *ns* event-as-symbol)]
(println  what kind of var is this? )
(println *ns*)
(println (type event-as-symbol))
(println event-as-symbol)
(if-not (nil? event)
  (event))


event is always nil. One of the events listed in um/interactions is 
connect-to-database so, as a test, I hardcoded it here, to be sure it 
could run here, and it runs fine (first line after the comment). So the var 
for the function is known. But this:

(ns-resolve *ns* event-as-symbol)

returns nil, even when event-as-symbol is connect-to-database. 

When I println *ns* to the terminal output, I see the namespace is: 

#Namespace clojure.core

Which surprises me somewhat. 

How do I get ns-resolve to look in mpdv.core for the var that I want it to 
find? 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I reference a var that is in my core namespace?

2013-02-21 Thread Sean Corfield
I tend to have this at the top of most of my namespaces:

(def ^:private my-ns *ns*)

This evaluates *ns* at load/init time when it is bound to the
namespace being loaded and then initializes my-ns with that value.
Then I use my-ns throughout that namespace.

*ns* is dynamically bound to whatever namespace is currently executing
which is why it changes unexpectedly when you're trying to do
something obvious with it.

On Thu, Feb 21, 2013 at 10:30 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 I wanted to have some functions run when an app starts, and I wanted this to
 be configurable, because I plan to use the same architecture for several
 apps. So I thought I could have the function names as strings inside of maps
 inside of a set (that I sort), in a config file. And I thought I could use
 ns-resolve *ns* symbol to turn the strings into references to the vars where
 the function definitions are stored. But somehow this is not working. I have
 this right now, in mpdv.core, which is the core namespace is an app I
 created with lein:


 (defn process-startup-hooks []
   2013-02-21- remember, each row in hooks is a map: {:order-of-events 1,
 :event-name 'connect-to-database'}
   (connect-to-database)
   (let [hooks (sort-by :order-of-events
 (:events-called-when-the-app-starts-hooks @um/interactions))]
 (doseq [x hooks]
   (let [event-as-symbol (symbol (:event-name x))
 event (ns-resolve *ns* event-as-symbol)]
 (println  what kind of var is this? )
 (println *ns*)
 (println (type event-as-symbol))
 (println event-as-symbol)
 (if-not (nil? event)
   (event))


 event is always nil. One of the events listed in um/interactions is
 connect-to-database so, as a test, I hardcoded it here, to be sure it
 could run here, and it runs fine (first line after the comment). So the var
 for the function is known. But this:

 (ns-resolve *ns* event-as-symbol)

 returns nil, even when event-as-symbol is connect-to-database.

 When I println *ns* to the terminal output, I see the namespace is:

 #Namespace clojure.core

 Which surprises me somewhat.

 How do I get ns-resolve to look in mpdv.core for the var that I want it to
 find?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.





--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: how do I reference a var that is in my core namespace?

2013-02-21 Thread larry google groups

That worked. I find it a little surprising that this is the correct way to 
do this, but it worked, so I am happy. Thank you. 


On Thursday, February 21, 2013 1:43:18 PM UTC-5, Sean Corfield wrote:

 I tend to have this at the top of most of my namespaces: 

 (def ^:private my-ns *ns*) 

 This evaluates *ns* at load/init time when it is bound to the 
 namespace being loaded and then initializes my-ns with that value. 
 Then I use my-ns throughout that namespace. 

 *ns* is dynamically bound to whatever namespace is currently executing 
 which is why it changes unexpectedly when you're trying to do 
 something obvious with it. 

 On Thu, Feb 21, 2013 at 10:30 AM, larry google groups 
 lawrenc...@gmail.com javascript: wrote: 
  I wanted to have some functions run when an app starts, and I wanted 
 this to 
  be configurable, because I plan to use the same architecture for several 
  apps. So I thought I could have the function names as strings inside of 
 maps 
  inside of a set (that I sort), in a config file. And I thought I could 
 use 
  ns-resolve *ns* symbol to turn the strings into references to the vars 
 where 
  the function definitions are stored. But somehow this is not working. I 
 have 
  this right now, in mpdv.core, which is the core namespace is an app I 
  created with lein: 
  
  
  (defn process-startup-hooks [] 
2013-02-21- remember, each row in hooks is a map: {:order-of-events 
 1, 
  :event-name 'connect-to-database'} 
(connect-to-database) 
(let [hooks (sort-by :order-of-events 
  (:events-called-when-the-app-starts-hooks @um/interactions))] 
  (doseq [x hooks] 
(let [event-as-symbol (symbol (:event-name x)) 
  event (ns-resolve *ns* event-as-symbol)] 
  (println  what kind of var is this? ) 
  (println *ns*) 
  (println (type event-as-symbol)) 
  (println event-as-symbol) 
  (if-not (nil? event) 
(event)) 
  
  
  event is always nil. One of the events listed in um/interactions is 
  connect-to-database so, as a test, I hardcoded it here, to be sure it 
  could run here, and it runs fine (first line after the comment). So the 
 var 
  for the function is known. But this: 
  
  (ns-resolve *ns* event-as-symbol) 
  
  returns nil, even when event-as-symbol is connect-to-database. 
  
  When I println *ns* to the terminal output, I see the namespace is: 
  
  #Namespace clojure.core 
  
  Which surprises me somewhat. 
  
  How do I get ns-resolve to look in mpdv.core for the var that I want it 
 to 
  find? 
  
  -- 
  -- 
  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 unsubscribe from this group and stop receiving emails from it, send 
 an 
  email to clojure+u...@googlegroups.com javascript:. 
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  



 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




How do you typecast and insert a Postgres enum value using Clojure JDBC?

2013-02-06 Thread James Thornton


For example, here is a product table in PostgreSQL with status as an enum:

create type product_status as enum ('InStock', 'OutOfStock');

create table product (
pidint primary key default nextval('product_pid_seq'),
skutext not null unique,
name   text not null,
descriptiontext not null,
quantity   int not null,
cost   numeric(10,2) not null,
price  numeric(10,2) not null,
weight numeric(10,2),
status product_status not null);

Typical Clojure code to insert a product would be:

(def prod-12345 {:sku 12345
 :name My Product
 :description yada yada yada
 :quantity 100
 :cost 42.00
 :price 59.00
 :weight 0.3
 :status InStock})
(sql/with-connection db-spec
   (sql/insert-record :product product-12345))

However, status is an enum so you can't insert it as a normal string 
without casting it to an enum:

'InStock'::product_status

I know you can do it with a prepared statement, such as:

INSERT INTO product (name, status) VALUES (?, ?::product_status)

But is there a way to do it without using a prepared statement?

From StackOverflow: 
http://stackoverflow.com/questions/14719207/how-do-you-insert-a-postgres-enum-value-using-clojure-jdbc

- James

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




do background threads sometimes swallow exceptions?

2013-01-29 Thread larry google groups
I think someone on this mailist recently said that an exception that occurs 
in a thread is sometimes lost? That is, even if I put in a lot of pprint 
statements or println statements* or (stack/print-stack-trace e) 
expressions, and I just want it to show up in terminal, so I can debug it, 
but if the exception happens in a background thread, it gets lost? If this 
is true, what is the best way to find these errors? 

I have been unable to save a document to MongoDb using Monger. I assume the 
problem is that my connection credentials are wrong, but no error ever 
appears in the output. I posted the question to 
Stackoverflow: 
http://stackoverflow.com/questions/14564589/how-do-i-add-a-document-to-mongodb-with-monger-and-clojure

But so far I have no answers. 

*I do realize that in Clojure there are no statements, but I assume my 
meaning was clear enough. 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: do background threads sometimes swallow exceptions?

2013-01-29 Thread larry google groups
I don't see any threads in your Stack Overflow post. 

I thought it would be over-complicated to include all of the code. But 
inside my -main function I start a new thread and call the function that 
calls the function that causes this error. 

They are not lost. Unhandled exceptions cause 
 threads to terminate immediately.

That is good to know. I have the top level function call wrapped in a 
try/catch block, but I suppose I'll get better results if I do more of the 
try/catch at a lower level, closer to the problem.


W dniu wtorek, 29 stycznia 2013 16:03:51 UTC-5 użytkownik Michael Klishin 
napisał:


 2013/1/30 larry google groups lawrenc...@gmail.com javascript:

 but if the exception happens in a background thread, it gets lost? If 
 this is true, what is the best way to find these errors? 


 They are not lost. Unhandled exceptions cause threads to terminate 
 immediately. You need to handle
 exceptions where you expect them.

 I don't see any threads in your Stack Overflow post. Monger itself does 
 not create any threads internally. You are
 saying your credentials may be wrong but no code, it is true that with 
 MongoDB Java driver's current behavior
 exceptions will be thrown next time you attempt to do something rather 
 than immediately upon connection.
 -- 
 MK

 http://github.com/michaelklishin
 http://twitter.com/michaelklishin
  

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: do background threads sometimes swallow exceptions?

2013-01-29 Thread Chas Emerick
On Jan 29, 2013, at 4:56 PM, Michael Klishin wrote:

 
 2013/1/30 larry google groups lawrencecloj...@gmail.com
 That is good to know. I have the top level function call wrapped in a 
 try/catch block, but I suppose I'll get better results if I do more of the 
 try/catch at a lower level, closer to the problem.
 
 Wrap the entire new thread body in a try/catch, it should reveal any 
 exceptions there may be.

Also, if you're actually revving up new Threads, this sometimes comes in handy:


http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html#setDefaultUncaughtExceptionHandler%28java.lang.Thread.UncaughtExceptionHandler%29

- 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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




How do I install guice?

2013-01-14 Thread larry google groups
I am building a web app. I just included Compojure and Friend as
dependencies, and one of these, in turn, relies on Google Guice. I
type:

lein uberjar

and I get a whole lot of output which includes:

Could not find artifact com.google.code.guice:guice:pom:2.0 in central
(http://repo1.maven.org/maven2)
Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
(https://clojars.org/repo/)
Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
to guice (http://guice-maven.googlecode.com/svn/trunk): Not
authorized, ReasonPhrase:Authorization Required.
Could not find artifact com.google.code.guice:guice:pom:2.0 in
alchim.snapshots (http://alchim.sf.net/download/snapshots)
Check :dependencies and :repositories for typos.
It's possible the specified jar is not in any repository.
If so, see Free-floating Jars under http://j.mp/repeatability
Uberjar aborting because jar/compilation failed: Could not resolve
dependencies


I find instructions for installing guice here:

http://code.google.com/p/roboguice/issues/detail?id=38

I download guice from here:

http://code.google.com/p/google-guice/downloads/list

On my Mac, at the command line, I then run:

mvn install:install-file -DgroupId=com.google.android.maps -
DartifactId=maps -Dversion=3_r3 -Dpackaging=jar -Dfile=/Users/lkrubner/
Downloads/guice-2.0/guice-2.0.jar

and I get:

[INFO] Scanning for projects...
[INFO]
[INFO]

[INFO] Building Maven Stub Project (No POM) 1
[INFO]

[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @
standalone-pom ---
[INFO] Installing /Users/lkrubner/Downloads/guice-2.0/guice-2.0.jar
to /Users/lkrubner/.m2/repository/com/google/android/maps/maps/3_r3/
maps-3_r3.jar
[INFO]

[INFO] BUILD SUCCESS
[INFO]

[INFO] Total time: 0.718s
[INFO] Finished at: Mon Jan 14 10:18:44 EST 2013
[INFO] Final Memory: 4M/92M
[INFO]



I then again run:

lein uberjar

and again I get:

lein uberjar
Could not find artifact com.google.code.guice:guice:pom:2.0 in central
(http://repo1.maven.org/maven2)
Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
(https://clojars.org/repo/)
Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
to guice (http://guice-maven.googlecode.com/svn/trunk): Not
authorized, ReasonPhrase:Authorization Required.
Could not find artifact com.google.code.guice:guice:pom:2.0 in
alchim.snapshots (http://alchim.sf.net/download/snapshots)
Check :dependencies and :repositories for typos.
It's possible the specified jar is not in any repository.
If so, see Free-floating Jars under http://j.mp/repeatability
Uberjar aborting because jar/compilation failed: Could not resolve
dependencies

What am I doing wrong?

-- 
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 do I install guice?

2013-01-14 Thread Chas Emerick
Please change your Friend dependency to [com.cemerick/friend 0.1.3].

Prior versions transitively depended upon a Guice artifact that was hosted on a 
now-404 Maven repository via Google Code's svn.  Friend = 0.1.3 depends only 
on artifacts available in Clojars and Maven Central, and will remain that way.

Sorry for the inconvenience,

- Chas

On Jan 14, 2013, at 10:23 AM, larry google groups wrote:

 I am building a web app. I just included Compojure and Friend as
 dependencies, and one of these, in turn, relies on Google Guice. I
 type:
 
 lein uberjar
 
 and I get a whole lot of output which includes:
 
 Could not find artifact com.google.code.guice:guice:pom:2.0 in central
 (http://repo1.maven.org/maven2)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
 (https://clojars.org/repo/)
 Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
 to guice (http://guice-maven.googlecode.com/svn/trunk): Not
 authorized, ReasonPhrase:Authorization Required.
 Could not find artifact com.google.code.guice:guice:pom:2.0 in
 alchim.snapshots (http://alchim.sf.net/download/snapshots)
 Check :dependencies and :repositories for typos.
 It's possible the specified jar is not in any repository.
 If so, see Free-floating Jars under http://j.mp/repeatability
 Uberjar aborting because jar/compilation failed: Could not resolve
 dependencies
 
 
 I find instructions for installing guice here:
 
 http://code.google.com/p/roboguice/issues/detail?id=38
 
 I download guice from here:
 
 http://code.google.com/p/google-guice/downloads/list
 
 On my Mac, at the command line, I then run:
 
 mvn install:install-file -DgroupId=com.google.android.maps -
 DartifactId=maps -Dversion=3_r3 -Dpackaging=jar -Dfile=/Users/lkrubner/
 Downloads/guice-2.0/guice-2.0.jar
 
 and I get:
 
 [INFO] Scanning for projects...
 [INFO]
 [INFO]
 
 [INFO] Building Maven Stub Project (No POM) 1
 [INFO]
 
 [INFO]
 [INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @
 standalone-pom ---
 [INFO] Installing /Users/lkrubner/Downloads/guice-2.0/guice-2.0.jar
 to /Users/lkrubner/.m2/repository/com/google/android/maps/maps/3_r3/
 maps-3_r3.jar
 [INFO]
 
 [INFO] BUILD SUCCESS
 [INFO]
 
 [INFO] Total time: 0.718s
 [INFO] Finished at: Mon Jan 14 10:18:44 EST 2013
 [INFO] Final Memory: 4M/92M
 [INFO]
 
 
 
 I then again run:
 
 lein uberjar
 
 and again I get:
 
 lein uberjar
 Could not find artifact com.google.code.guice:guice:pom:2.0 in central
 (http://repo1.maven.org/maven2)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
 (https://clojars.org/repo/)
 Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
 to guice (http://guice-maven.googlecode.com/svn/trunk): Not
 authorized, ReasonPhrase:Authorization Required.
 Could not find artifact com.google.code.guice:guice:pom:2.0 in
 alchim.snapshots (http://alchim.sf.net/download/snapshots)
 Check :dependencies and :repositories for typos.
 It's possible the specified jar is not in any repository.
 If so, see Free-floating Jars under http://j.mp/repeatability
 Uberjar aborting because jar/compilation failed: Could not resolve
 dependencies
 
 What am I doing wrong?
 
 -- 
 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: How do I install guice?

2013-01-14 Thread larry google groups
Thank you for the fast reply. That helped. But do you (or anyone else
here) know of a workaround for friend-oauth2? I get:

lein uberjar
Could not find artifact friend-oauth2:friend-oauth2:pom:0.0.2 in
central (http://repo1.maven.org/maven2)
Retrieving friend-oauth2/friend-oauth2/0.0.2/friend-oauth2-0.0.2.pom
(4k)
from https://clojars.org/repo/
Could not find artifact com.google.code.guice:guice:pom:2.0 in central
(http://repo1.maven.org/maven2)
Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
(https://clojars.org/repo/)
Could not find artifact com.google.code.guice:guice:pom:2.0 in stuart
(http://stuartsierra.com/maven2)
Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
to guice (http://guice-maven.googlecode.com/svn/trunk): Not
authorized, ReasonPhrase:Authorization Required.
Could not find artifact com.google.code.guice:guice:pom:2.0 in
alchim.snapshots (http://alchim.sf.net/download/snapshots)




On 14 Sty, 11:12, Chas Emerick c...@cemerick.com wrote:
 Please change your Friend dependency to [com.cemerick/friend 0.1.3].

 Prior versions transitively depended upon a Guice artifact that was hosted on 
 a now-404 Maven repository via Google Code's svn.  Friend = 0.1.3 depends 
 only on artifacts available in Clojars and Maven Central, and will remain 
 that way.

 Sorry for the inconvenience,

 - Chas

 On Jan 14, 2013, at 10:23 AM, larry google groups wrote:







  I am building a web app. I just included Compojure and Friend as
  dependencies, and one of these, in turn, relies on Google Guice. I
  type:

  lein uberjar

  and I get a whole lot of output which includes:

  Could not find artifact com.google.code.guice:guice:pom:2.0 in central
  (http://repo1.maven.org/maven2)
  Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
  (https://clojars.org/repo/)
  Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
  to guice (http://guice-maven.googlecode.com/svn/trunk):Not
  authorized, ReasonPhrase:Authorization Required.
  Could not find artifact com.google.code.guice:guice:pom:2.0 in
  alchim.snapshots (http://alchim.sf.net/download/snapshots)
  Check :dependencies and :repositories for typos.
  It's possible the specified jar is not in any repository.
  If so, see Free-floating Jars underhttp://j.mp/repeatability
  Uberjar aborting because jar/compilation failed: Could not resolve
  dependencies

  I find instructions for installing guice here:

 http://code.google.com/p/roboguice/issues/detail?id=38

  I download guice from here:

 http://code.google.com/p/google-guice/downloads/list

  On my Mac, at the command line, I then run:

  mvn install:install-file -DgroupId=com.google.android.maps -
  DartifactId=maps -Dversion=3_r3 -Dpackaging=jar -Dfile=/Users/lkrubner/
  Downloads/guice-2.0/guice-2.0.jar

  and I get:

  [INFO] Scanning for projects...
  [INFO]
  [INFO]
  
  [INFO] Building Maven Stub Project (No POM) 1
  [INFO]
  
  [INFO]
  [INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @
  standalone-pom ---
  [INFO] Installing /Users/lkrubner/Downloads/guice-2.0/guice-2.0.jar
  to /Users/lkrubner/.m2/repository/com/google/android/maps/maps/3_r3/
  maps-3_r3.jar
  [INFO]
  
  [INFO] BUILD SUCCESS
  [INFO]
  
  [INFO] Total time: 0.718s
  [INFO] Finished at: Mon Jan 14 10:18:44 EST 2013
  [INFO] Final Memory: 4M/92M
  [INFO]
  

  I then again run:

  lein uberjar

  and again I get:

  lein uberjar
  Could not find artifact com.google.code.guice:guice:pom:2.0 in central
  (http://repo1.maven.org/maven2)
  Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
  (https://clojars.org/repo/)
  Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
  to guice (http://guice-maven.googlecode.com/svn/trunk):Not
  authorized, ReasonPhrase:Authorization Required.
  Could not find artifact com.google.code.guice:guice:pom:2.0 in
  alchim.snapshots (http://alchim.sf.net/download/snapshots)
  Check :dependencies and :repositories for typos.
  It's possible the specified jar is not in any repository.
  If so, see Free-floating Jars underhttp://j.mp/repeatability
  Uberjar aborting because jar/compilation failed: Could not resolve
  dependencies

  What am I doing wrong?

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

Re: How do I install guice?

2013-01-14 Thread Chas Emerick
Instead of this:

[friend-oauth2 0.0.2]

Use this:

[friend-oauth2 0.0.2 :exclusions [com.cemerick/friend]]
[com.cemerick/friend 0.1.3]

That will keep lein from attempting to resolve the now-gone Guice artifact 
transitively referred to by the older revs of friend.

- Chas

On Jan 14, 2013, at 11:48 AM, larry google groups wrote:

 Thank you for the fast reply. That helped. But do you (or anyone else
 here) know of a workaround for friend-oauth2? I get:
 
 lein uberjar
 Could not find artifact friend-oauth2:friend-oauth2:pom:0.0.2 in
 central (http://repo1.maven.org/maven2)
 Retrieving friend-oauth2/friend-oauth2/0.0.2/friend-oauth2-0.0.2.pom
 (4k)
from https://clojars.org/repo/
 Could not find artifact com.google.code.guice:guice:pom:2.0 in central
 (http://repo1.maven.org/maven2)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
 (https://clojars.org/repo/)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in stuart
 (http://stuartsierra.com/maven2)
 Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
 to guice (http://guice-maven.googlecode.com/svn/trunk): Not
 authorized, ReasonPhrase:Authorization Required.
 Could not find artifact com.google.code.guice:guice:pom:2.0 in
 alchim.snapshots (http://alchim.sf.net/download/snapshots)
 
 
 
 
 On 14 Sty, 11:12, Chas Emerick c...@cemerick.com wrote:
 Please change your Friend dependency to [com.cemerick/friend 0.1.3].
 
 Prior versions transitively depended upon a Guice artifact that was hosted 
 on a now-404 Maven repository via Google Code's svn.  Friend = 0.1.3 
 depends only on artifacts available in Clojars and Maven Central, and will 
 remain that way.
 
 Sorry for the inconvenience,
 
 - Chas
 
 On Jan 14, 2013, at 10:23 AM, larry google groups wrote:
 
 
 
 
 
 
 
 I am building a web app. I just included Compojure and Friend as
 dependencies, and one of these, in turn, relies on Google Guice. I
 type:
 
 lein uberjar
 
 and I get a whole lot of output which includes:
 
 Could not find artifact com.google.code.guice:guice:pom:2.0 in central
 (http://repo1.maven.org/maven2)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
 (https://clojars.org/repo/)
 Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
 to guice (http://guice-maven.googlecode.com/svn/trunk):Not
 authorized, ReasonPhrase:Authorization Required.
 Could not find artifact com.google.code.guice:guice:pom:2.0 in
 alchim.snapshots (http://alchim.sf.net/download/snapshots)
 Check :dependencies and :repositories for typos.
 It's possible the specified jar is not in any repository.
 If so, see Free-floating Jars underhttp://j.mp/repeatability
 Uberjar aborting because jar/compilation failed: Could not resolve
 dependencies
 
 I find instructions for installing guice here:
 
 http://code.google.com/p/roboguice/issues/detail?id=38
 
 I download guice from here:
 
 http://code.google.com/p/google-guice/downloads/list
 
 On my Mac, at the command line, I then run:
 
 mvn install:install-file -DgroupId=com.google.android.maps -
 DartifactId=maps -Dversion=3_r3 -Dpackaging=jar -Dfile=/Users/lkrubner/
 Downloads/guice-2.0/guice-2.0.jar
 
 and I get:
 
 [INFO] Scanning for projects...
 [INFO]
 [INFO]
 
 [INFO] Building Maven Stub Project (No POM) 1
 [INFO]
 
 [INFO]
 [INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @
 standalone-pom ---
 [INFO] Installing /Users/lkrubner/Downloads/guice-2.0/guice-2.0.jar
 to /Users/lkrubner/.m2/repository/com/google/android/maps/maps/3_r3/
 maps-3_r3.jar
 [INFO]
 
 [INFO] BUILD SUCCESS
 [INFO]
 
 [INFO] Total time: 0.718s
 [INFO] Finished at: Mon Jan 14 10:18:44 EST 2013
 [INFO] Final Memory: 4M/92M
 [INFO]
 
 
 I then again run:
 
 lein uberjar
 
 and again I get:
 
 lein uberjar
 Could not find artifact com.google.code.guice:guice:pom:2.0 in central
 (http://repo1.maven.org/maven2)
 Could not find artifact com.google.code.guice:guice:pom:2.0 in clojars
 (https://clojars.org/repo/)
 Could not transfer artifact com.google.code.guice:guice:pom:2.0 from/
 to guice (http://guice-maven.googlecode.com/svn/trunk):Not
 authorized, ReasonPhrase:Authorization Required.
 Could not find artifact com.google.code.guice:guice:pom:2.0 in
 alchim.snapshots (http://alchim.sf.net/download/snapshots)
 Check :dependencies and :repositories for typos.
 It's possible the specified jar is not in any repository.
 If so, see Free-floating Jars underhttp://j.mp/repeatability
 Uberjar aborting because jar/compilation failed: Could not resolve
 dependencies
 
 What am I doing wrong?
 
 --
 You received this message

Re: what Jetty jars do I need for WebSockets?

2012-12-10 Thread larry google groups

Thank you. I will do that.

I find that trying to learn both Clojure and the JVM (which automatically 
entails parts of the Java eco-system), is a little overwhelming at first. 
But I suppose that is true of learning anything new.


On Sunday, December 9, 2012 9:04:44 PM UTC-5, Jay Fields wrote:

 I don't have the answer, but I would strongly recommend webbit: 
 https://github.com/webbit/webbit 

 I've been using it for quite awhile and I've been very happy with it. 

 On Sun, Dec 9, 2012 at 8:55 PM, larry google groups 
 lawrenc...@gmail.com javascript: wrote: 
  
  I am still fairly new to Clojure, the JVM and Java, so I get lost trying 
 to 
  read some of the stuff that assumes knowledge of any of those 3. I want 
 to 
  build a Clojure app using Jetty and offering WebSocket connections. 
  
  I have already built an app with Clojure and Jetty, so that part is 
 easy. 
  But I look here: 
  
  
 http://wiki.eclipse.org/index.php?title=Jetty/Feature/WebSocketsoldid=297254 
  
  and it says I should download 3 jars: 
  
  wget -O jetty-all.jar --user-agent=demo \ 
  
  
 http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/7.6.2.v20120308/jetty-all-7.6.2.v20120308.jar
  
  wget -O jetty-websocket-tests.jar --user-agent=demo \ 
  
  
 http://repo2.maven.org/maven2/org/eclipse/jetty/jetty-websocket/7.6.2.v20120308/jetty-websocket-7.6.2.v20120308-tests.jar
  
  wget --user-agent=demo \ 
  
  
 http://repo2.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
  
  
  
  
  I assume I put these in project.clj? I already have stuff in there like: 
  
:dependencies [[org.clojure/clojure 1.3.0] 
   [net.cgrand/moustache 1.1.0] 
   [ring 1.1.5] 
   [ring/ring-jetty-adapter 1.1.5] 
  
  etc 
  
  Searching on this topic brought me to this: 
  
  
 https://groups.google.com/forum/?fromgroups=#!topic/ring-clojure/JD9FLJFTVsg 
  
  But that is 2 years old. I have not found anything specific to 
  ring/jetty/websockets that is recent. 
  
  Can anyone point me to documentation that might lead me out of my 
 confusion? 
  
  
  
  
  
  
  -- 
  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: what Jetty jars do I need for WebSockets?

2012-12-10 Thread Jay Fields
The upside of using Java is that it's very widely documented. Also, I
find people on this mailing list to be very helpful. Nonetheless, I'm
sure it's frustrating to have to learn about Java when you just want
to do some Clojure.

I've previously written about using Webbit with Clojure:
http://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html

afaik, the post should be up to date and still working. Feel free to
email me if you run into any issues.

On Mon, Dec 10, 2012 at 8:25 AM, larry google groups
lawrencecloj...@gmail.com wrote:

 Thank you. I will do that.

 I find that trying to learn both Clojure and the JVM (which automatically
 entails parts of the Java eco-system), is a little overwhelming at first.
 But I suppose that is true of learning anything new.


 On Sunday, December 9, 2012 9:04:44 PM UTC-5, Jay Fields wrote:

 I don't have the answer, but I would strongly recommend webbit:
 https://github.com/webbit/webbit

 I've been using it for quite awhile and I've been very happy with it.

 On Sun, Dec 9, 2012 at 8:55 PM, larry google groups
 lawrenc...@gmail.com wrote:
 
  I am still fairly new to Clojure, the JVM and Java, so I get lost trying
  to
  read some of the stuff that assumes knowledge of any of those 3. I want
  to
  build a Clojure app using Jetty and offering WebSocket connections.
 
  I have already built an app with Clojure and Jetty, so that part is
  easy.
  But I look here:
 
 
  http://wiki.eclipse.org/index.php?title=Jetty/Feature/WebSocketsoldid=297254
 
  and it says I should download 3 jars:
 
  wget -O jetty-all.jar --user-agent=demo \
 
 
  http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/7.6.2.v20120308/jetty-all-7.6.2.v20120308.jar
  wget -O jetty-websocket-tests.jar --user-agent=demo \
 
 
  http://repo2.maven.org/maven2/org/eclipse/jetty/jetty-websocket/7.6.2.v20120308/jetty-websocket-7.6.2.v20120308-tests.jar
  wget --user-agent=demo \
 
 
  http://repo2.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar
 
 
 
  I assume I put these in project.clj? I already have stuff in there like:
 
:dependencies [[org.clojure/clojure 1.3.0]
   [net.cgrand/moustache 1.1.0]
   [ring 1.1.5]
   [ring/ring-jetty-adapter 1.1.5]
 
  etc
 
  Searching on this topic brought me to this:
 
 
  https://groups.google.com/forum/?fromgroups=#!topic/ring-clojure/JD9FLJFTVsg
 
  But that is 2 years old. I have not found anything specific to
  ring/jetty/websockets that is recent.
 
  Can anyone point me to documentation that might lead me out of my
  confusion?
 
 
 
 
 
 
  --
  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
  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
  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


what Jetty jars do I need for WebSockets?

2012-12-09 Thread larry google groups

I am still fairly new to Clojure, the JVM and Java, so I get lost trying to 
read some of the stuff that assumes knowledge of any of those 3. I want to 
build a Clojure app using Jetty and offering WebSocket connections. 

I have already built an app with Clojure and Jetty, so that part is easy. 
But I look here:

http://wiki.eclipse.org/index.php?title=Jetty/Feature/WebSocketsoldid=297254

and it says I should download 3 jars:

wget -O jetty-all.jar --user-agent=demo \
  
http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/7.6.2.v20120308/jetty-all-7.6.2.v20120308.jarwget
 -O jetty-websocket-tests.jar --user-agent=demo \
  
http://repo2.maven.org/maven2/org/eclipse/jetty/jetty-websocket/7.6.2.v20120308/jetty-websocket-7.6.2.v20120308-tests.jarwget
 --user-agent=demo \

http://repo2.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar



I assume I put these in project.clj? I already have stuff in there like:

  :dependencies [[org.clojure/clojure 1.3.0]
 [net.cgrand/moustache 1.1.0] 
 [ring 1.1.5] 
 [ring/ring-jetty-adapter 1.1.5] 

etc

Searching on this topic brought me to this:

https://groups.google.com/forum/?fromgroups=#!topic/ring-clojure/JD9FLJFTVsg

But that is 2 years old. I have not found anything specific to 
ring/jetty/websockets that is recent. 

Can anyone point me to documentation that might lead me out of my confusion?






-- 
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: what Jetty jars do I need for WebSockets?

2012-12-09 Thread Jay Fields
I don't have the answer, but I would strongly recommend webbit:
https://github.com/webbit/webbit

I've been using it for quite awhile and I've been very happy with it.

On Sun, Dec 9, 2012 at 8:55 PM, larry google groups
lawrencecloj...@gmail.com wrote:

 I am still fairly new to Clojure, the JVM and Java, so I get lost trying to
 read some of the stuff that assumes knowledge of any of those 3. I want to
 build a Clojure app using Jetty and offering WebSocket connections.

 I have already built an app with Clojure and Jetty, so that part is easy.
 But I look here:

 http://wiki.eclipse.org/index.php?title=Jetty/Feature/WebSocketsoldid=297254

 and it says I should download 3 jars:

 wget -O jetty-all.jar --user-agent=demo \

 http://repo2.maven.org/maven2/org/eclipse/jetty/aggregate/jetty-all/7.6.2.v20120308/jetty-all-7.6.2.v20120308.jar
 wget -O jetty-websocket-tests.jar --user-agent=demo \

 http://repo2.maven.org/maven2/org/eclipse/jetty/jetty-websocket/7.6.2.v20120308/jetty-websocket-7.6.2.v20120308-tests.jar
 wget --user-agent=demo \

 http://repo2.maven.org/maven2/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar



 I assume I put these in project.clj? I already have stuff in there like:

   :dependencies [[org.clojure/clojure 1.3.0]
  [net.cgrand/moustache 1.1.0]
  [ring 1.1.5]
  [ring/ring-jetty-adapter 1.1.5]

 etc

 Searching on this topic brought me to this:

 https://groups.google.com/forum/?fromgroups=#!topic/ring-clojure/JD9FLJFTVsg

 But that is 2 years old. I have not found anything specific to
 ring/jetty/websockets that is recent.

 Can anyone point me to documentation that might lead me out of my confusion?






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


How do ClojureScript protocol functions work?

2012-10-07 Thread Timothy Baldridge
While digging through the CLJS sources I've seen that protocols use some
sort of odd bitmask optimization. Is this documented anywhere?

Or as a more general question, is the way protocols are implemented in CLJS
documented at all?

Thanks,

Timothy

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how do I evaluate this lazy sequence?

2012-09-29 Thread larry google groups
 I'm just  a
 bit amazed that you would go away and write clojure code to consume JSON
 and all that, without realising that data-structures in Clojure are
 immutable!

That part is obvious enough, but I thought the new data structures
returned from assoc were being handed to map which then, in turn,
returned a new data structure where all values had been updated with
the values from assoc. But clearly, I got the syntax badly wrong.




On Sep 27, 2:21 pm, Jim - FooBar(); jimpil1...@gmail.com wrote:
 the 2 previous responses answered your question perfectly ...I'm just  a
 bit amazed that you would go away and write clojure code to consume JSON
 and all that, without realising that data-structures in Clojure are
 immutable! I think we can all agree they are *the* cornerstone of
 Clojure. It is a bit alien at first but it does pay off in the long
 run... If you absolutely need to stick with your code style (mutability
 not-recommended in general) use a java HashMap instead...

 Jim

 ps: i recently used a cheshire without any problems :-)

 On 27/09/12 18:53, gaz jones wrote:







  Couple of initial things, Clojure has immutable data structures so
  when you call for example 'assoc' it will return you a new map with
  the new values assoc'd. It will not mutate the original, so:

  (let [foo {}]
     (assoc foo :a 1)
     (assoc foo :b 2)
     foo)

  Will return {}. You need to do something like:

  (- {}
        (assoc :a 1)
        (assoc :b 2))

  = {:a 1 :b 2}

  FYI, assoc takes multiple kvps:

  (assoc {} :a 1 :b 2)

  Also, to return valid JSON, you cannot simply call 'str' on the map.
  You need to use a library likehttps://github.com/dakrone/cheshireor
 https://github.com/clojure/data.jsonand encode the map as JSON.

  Perhaps you could illustrate the data structure you are holding inside
  of @registry, and the structure of the JSON you would like to emit.
  Laziness is not an issue here.

  On Thu, Sep 27, 2012 at 12:02 PM, larry google groups
  lawrencecloj...@gmail.com wrote:
  I would like 2 types of advice:

  1.) an answer to this specific question

  2.) advice on how one is suppose to debug mysteries likes this

  I have a simple web app that serves some data (hopefully in JSON
  format, but at the moment I will accept anything at all). The app uses
  Ring and Moustache and outputs the data.

  We start with a simple atom:

  (def registry (atom {}))

  We put some data in this atom. And then we output it. But I have had
  great difficulty getting anything to appear on the screen. Assuming
  the problem was with the fact the main sequence was lazy, I added in
  doall everywhere it made sense. But I still can not get anything to
  work:

  (defn current-users [request]
     The default action of this app. Add new users to the registry, and
  delete the ones that are more than 15 seconds old
     (let [this-users-params (:params request)
           final-map-for-output {}]
     (add-to-logged-in-registry this-users-params)
     (remove-old-registrants)
     (response (apply str (into {}
                                (doall
                                 (map (fn [each-user-map]
                                        (doall
                                         (let [inner-details (second each-
  user-map)]
                                           (assoc final-map-for-output
  username (get inner-details username nothing found for user))
                                           (assoc final-map-for-output
  updated (get inner-details updated nothing found for updated))
                                           final-map-for-output)))
                                      @registry)))

  The various variations I have tried on this have either given me a
  blank white page or:

  {}

  Nothing else.

  I used to do simply:

     (response (apply str (doall @registry)

  This worked fine. But it did not output valid JSON, so I wanted to
  change the format. But I have not been able to get anything to appear
  on screen.

  Suggestions?

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


Questions regarding do form

2012-09-27 Thread arekanderu
Hello all,

I am new to clojure and I have two questions about do and the way it should 
be used.

*Question 1: Which of the following two functions is more idiomatic and 
why? Both functions produce the same result.*

code
(defn my-fn [java-object]
  (. java-object firstFunc)
  (. java-object secondFunc)
  (. java-object thirdFunc)
  java-object)
/code

code
(defn my-fn [java-object]
  (do (. java-object firstFunc)
(. java-object secondFunc )
(. java-object thirdFunc )
java-object))
/code

*Question 2: Again, which one is more idiomatic and why? Both functions 
produce the same result.*
*
*
code
(defn my-fn [java-object bar]
  (let [bar-bar (. java-object getSomething)
_   (if (not (is-bar? bar))
  (. java-object (setSomething bar-bar)))]
java-object))
/code

code
(defn my-fn [java-object bar]
  (let [bar-bar (. java-object getSomething)]
(do 
  (if (not (is-bar? bar))
(. java-object (setSomething bar-bar)))
 java-object)))
/code


-- 
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: Questions regarding do form

2012-09-27 Thread Meikel Brandmeyer (kotarak)
Hi,

Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:

I am new to clojure and I have two questions about do and the way it should 
 be used.

 *Question 1: Which of the following two functions is more idiomatic and 
 why? Both functions produce the same result.*

 code
 (defn my-fn [java-object]
   (. java-object firstFunc)
   (. java-object secondFunc)
   (. java-object thirdFunc)
   java-object)
 /code


The first because defn includes an implicit do. So the second example is 
actually (do (do ...)).

In this case you could also use doto:

(defn my-fn
  [pojo]
  (doto pojo
.firstFunc
.secondFunc
.thirdFunc))

 

 *Question 2: Again, which one is more idiomatic and why? Both functions 
 produce the same result.*
 *
 *
 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)
 _   (if (not (is-bar? bar))
   (. java-object (setSomething bar-bar)))]
 java-object))
 /code

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)]
 (do 
   (if (not (is-bar? bar))
 (. java-object (setSomething bar-bar)))
  java-object)))
 /code


The third:

(defn my-fn
  [pojo bar]
  (let [bar-bar (.getSomething pojo)]
(when-not (is-bar? bar)
  (.setSomething pojo bar-bar))
pojo)))

let also (just like defn) includes an implicit do for the body.

Hope this helps.

Kind regards
Meikel
 

-- 
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: Questions regarding do form

2012-09-27 Thread arekanderu
Thank you Meikel for your so helpful replies.

On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer 
(kotarak) wrote:

 Hi,

 Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:

 I am new to clojure and I have two questions about do and the way it 
 should be used.

 *Question 1: Which of the following two functions is more idiomatic and 
 why? Both functions produce the same result.*

 code
 (defn my-fn [java-object]
   (. java-object firstFunc)
   (. java-object secondFunc)
   (. java-object thirdFunc)
   java-object)
 /code


 The first because defn includes an implicit do. So the second example is 
 actually (do (do ...)).

 In this case you could also use doto:

 (defn my-fn
   [pojo]
   (doto pojo
 .firstFunc
 .secondFunc
 .thirdFunc))

  

 *Question 2: Again, which one is more idiomatic and why? Both functions 
 produce the same result.*
 *
 *
 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)
 _   (if (not (is-bar? bar))
   (. java-object (setSomething bar-bar)))]
 java-object))
 /code

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)]
 (do 
   (if (not (is-bar? bar))
 (. java-object (setSomething bar-bar)))
  java-object)))
 /code


 The third:

 (defn my-fn
   [pojo bar]
   (let [bar-bar (.getSomething pojo)]
 (when-not (is-bar? bar)
   (.setSomething pojo bar-bar))
 pojo)))

 let also (just like defn) includes an implicit do for the body.

 Hope this helps.

 Kind regards
 Meikel
  


-- 
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: Questions regarding do form

2012-09-27 Thread Russell Whitaker
On Thu, Sep 27, 2012 at 8:26 AM, arekanderu arekand...@gmail.com wrote:
 Thank you Meikel for your so helpful replies.


Thanks also from a lurker, to whom these facts were a useful surprise:
I'd wondered
the same myself.

Cheers, R


 On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
 (kotarak) wrote:

 Hi,

 Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:

 I am new to clojure and I have two questions about do and the way it
 should be used.

 Question 1: Which of the following two functions is more idiomatic and
 why? Both functions produce the same result.

 code
 (defn my-fn [java-object]
   (. java-object firstFunc)
   (. java-object secondFunc)
   (. java-object thirdFunc)
   java-object)
 /code


 The first because defn includes an implicit do. So the second example is
 actually (do (do ...)).

 In this case you could also use doto:

 (defn my-fn
   [pojo]
   (doto pojo
 .firstFunc
 .secondFunc
 .thirdFunc))



 Question 2: Again, which one is more idiomatic and why? Both functions
 produce the same result.

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)
 _   (if (not (is-bar? bar))
   (. java-object (setSomething bar-bar)))]
 java-object))
 /code

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)]
 (do
   (if (not (is-bar? bar))
 (. java-object (setSomething bar-bar)))
  java-object)))
 /code


 The third:

 (defn my-fn
   [pojo bar]
   (let [bar-bar (.getSomething pojo)]
 (when-not (is-bar? bar)
   (.setSomething pojo bar-bar))
 pojo)))

 let also (just like defn) includes an implicit do for the body.

 Hope this helps.

 Kind regards
 Meikel


-- 
Russell Whitaker
http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
http://www.linkedin.com/pub/russell-whitaker/0/b86/329

-- 
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: Questions regarding do form

2012-09-27 Thread Grant Rettke
I'm reading _The Joy of Clojure_ right now, and they touch on it,
which is nice coming from Scheme/Racket.

On Thu, Sep 27, 2012 at 10:40 AM, Russell Whitaker
russell.whita...@gmail.com wrote:
 On Thu, Sep 27, 2012 at 8:26 AM, arekanderu arekand...@gmail.com wrote:
 Thank you Meikel for your so helpful replies.


 Thanks also from a lurker, to whom these facts were a useful surprise:
 I'd wondered
 the same myself.

 Cheers, R


 On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
 (kotarak) wrote:

 Hi,

 Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:

 I am new to clojure and I have two questions about do and the way it
 should be used.

 Question 1: Which of the following two functions is more idiomatic and
 why? Both functions produce the same result.

 code
 (defn my-fn [java-object]
   (. java-object firstFunc)
   (. java-object secondFunc)
   (. java-object thirdFunc)
   java-object)
 /code


 The first because defn includes an implicit do. So the second example is
 actually (do (do ...)).

 In this case you could also use doto:

 (defn my-fn
   [pojo]
   (doto pojo
 .firstFunc
 .secondFunc
 .thirdFunc))



 Question 2: Again, which one is more idiomatic and why? Both functions
 produce the same result.

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)
 _   (if (not (is-bar? bar))
   (. java-object (setSomething bar-bar)))]
 java-object))
 /code

 code
 (defn my-fn [java-object bar]
   (let [bar-bar (. java-object getSomething)]
 (do
   (if (not (is-bar? bar))
 (. java-object (setSomething bar-bar)))
  java-object)))
 /code


 The third:

 (defn my-fn
   [pojo bar]
   (let [bar-bar (.getSomething pojo)]
 (when-not (is-bar? bar)
   (.setSomething pojo bar-bar))
 pojo)))

 let also (just like defn) includes an implicit do for the body.

 Hope this helps.

 Kind regards
 Meikel


 --
 Russell Whitaker
 http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
 http://www.linkedin.com/pub/russell-whitaker/0/b86/329

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



-- 
((λ (x) (x x)) (λ (x) (x x)))
http://www.wisdomandwonder.com/
ACM, AMA, COG, IEEE

-- 
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: Questions regarding do form

2012-09-27 Thread Wes Freeman
Thanks for mentioning doto--hadn't seen that before. Particularly, I think
some of my unit tests can be made significantly more readable with that.

Wes

On Thu, Sep 27, 2012 at 11:40 AM, Russell Whitaker 
russell.whita...@gmail.com wrote:

 On Thu, Sep 27, 2012 at 8:26 AM, arekanderu arekand...@gmail.com wrote:
  Thank you Meikel for your so helpful replies.
 

 Thanks also from a lurker, to whom these facts were a useful surprise:
 I'd wondered
 the same myself.

 Cheers, R

 
  On Thursday, September 27, 2012 4:19:44 PM UTC+3, Meikel Brandmeyer
  (kotarak) wrote:
 
  Hi,
 
  Am Donnerstag, 27. September 2012 12:16:41 UTC+2 schrieb arekanderu:
 
  I am new to clojure and I have two questions about do and the way it
  should be used.
 
  Question 1: Which of the following two functions is more idiomatic and
  why? Both functions produce the same result.
 
  code
  (defn my-fn [java-object]
(. java-object firstFunc)
(. java-object secondFunc)
(. java-object thirdFunc)
java-object)
  /code
 
 
  The first because defn includes an implicit do. So the second example is
  actually (do (do ...)).
 
  In this case you could also use doto:
 
  (defn my-fn
[pojo]
(doto pojo
  .firstFunc
  .secondFunc
  .thirdFunc))
 
 
 
  Question 2: Again, which one is more idiomatic and why? Both functions
  produce the same result.
 
  code
  (defn my-fn [java-object bar]
(let [bar-bar (. java-object getSomething)
  _   (if (not (is-bar? bar))
(. java-object (setSomething bar-bar)))]
  java-object))
  /code
 
  code
  (defn my-fn [java-object bar]
(let [bar-bar (. java-object getSomething)]
  (do
(if (not (is-bar? bar))
  (. java-object (setSomething bar-bar)))
   java-object)))
  /code
 
 
  The third:
 
  (defn my-fn
[pojo bar]
(let [bar-bar (.getSomething pojo)]
  (when-not (is-bar? bar)
(.setSomething pojo bar-bar))
  pojo)))
 
  let also (just like defn) includes an implicit do for the body.
 
  Hope this helps.
 
  Kind regards
  Meikel
 

 --
 Russell Whitaker
 http://twitter.com/OrthoNormalRuss / http://orthonormalruss.blogspot.com/
 http://www.linkedin.com/pub/russell-whitaker/0/b86/329

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

how do I evaluate this lazy sequence?

2012-09-27 Thread larry google groups
I would like 2 types of advice:

1.) an answer to this specific question

2.) advice on how one is suppose to debug mysteries likes this

I have a simple web app that serves some data (hopefully in JSON
format, but at the moment I will accept anything at all). The app uses
Ring and Moustache and outputs the data.

We start with a simple atom:

(def registry (atom {}))

We put some data in this atom. And then we output it. But I have had
great difficulty getting anything to appear on the screen. Assuming
the problem was with the fact the main sequence was lazy, I added in
doall everywhere it made sense. But I still can not get anything to
work:

(defn current-users [request]
  The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old
  (let [this-users-params (:params request)
final-map-for-output {}]
  (add-to-logged-in-registry this-users-params)
  (remove-old-registrants)
  (response (apply str (into {}
 (doall
  (map (fn [each-user-map]
 (doall
  (let [inner-details (second each-
user-map)]
(assoc final-map-for-output
username (get inner-details username nothing found for user))
(assoc final-map-for-output
updated (get inner-details updated nothing found for updated))
final-map-for-output)))
   @registry)))

The various variations I have tried on this have either given me a
blank white page or:

{}

Nothing else.

I used to do simply:

  (response (apply str (doall @registry)

This worked fine. But it did not output valid JSON, so I wanted to
change the format. But I have not been able to get anything to appear
on screen.

Suggestions?

-- 
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 do I evaluate this lazy sequence?

2012-09-27 Thread Tassilo Horn
larry google groups lawrencecloj...@gmail.com writes:

 We put some data in this atom. And then we output it. But I have had
 great difficulty getting anything to appear on the screen. Assuming
 the problem was with the fact the main sequence was lazy, I added in
 doall everywhere it made sense. But I still can not get anything to
 work:

Your problem's here and has nothing to do with lazyness:

   (let [inner-details (second each-user-map)]
  (assoc final-map-for-output username (get inner-details 
 username nothing found for user))
  (assoc final-map-for-output updated (get inner-details 
 updated nothing found for updated))
  final-map-for-output)))

assoc (and all clojure collection functions) doesn't modify the given
map but it returns a new version of the given map with the new
association.  You simply don't use it.

Maybe you want something like this in case you want to output pairs of
username/inner-details, and updated/inner-details pairs.

--8---cut here---start-8---
(defn current-users [request]
  The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old
  (let [this-users-params (:params request)]
(add-to-logged-in-registry this-users-params)
(remove-old-registrants)
(response (apply str
 (mapcat
  (fn [each-user-map]
(let [inner-details (second each-user-map)]
  [[username (get inner-details username
nothing found for user)]
   [updated (get inner-details updated
   nothing found for updated)]]))
  @registry)
--8---cut here---end---8---

Bye,
Tassilo

-- 
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 do I evaluate this lazy sequence?

2012-09-27 Thread gaz jones
Couple of initial things, Clojure has immutable data structures so
when you call for example 'assoc' it will return you a new map with
the new values assoc'd. It will not mutate the original, so:

(let [foo {}]
  (assoc foo :a 1)
  (assoc foo :b 2)
  foo)

Will return {}. You need to do something like:

(- {}
 (assoc :a 1)
 (assoc :b 2))

= {:a 1 :b 2}

FYI, assoc takes multiple kvps:

(assoc {} :a 1 :b 2)

Also, to return valid JSON, you cannot simply call 'str' on the map.
You need to use a library like https://github.com/dakrone/cheshire or
https://github.com/clojure/data.json and encode the map as JSON.

Perhaps you could illustrate the data structure you are holding inside
of @registry, and the structure of the JSON you would like to emit.
Laziness is not an issue here.


On Thu, Sep 27, 2012 at 12:02 PM, larry google groups
lawrencecloj...@gmail.com wrote:
 I would like 2 types of advice:

 1.) an answer to this specific question

 2.) advice on how one is suppose to debug mysteries likes this

 I have a simple web app that serves some data (hopefully in JSON
 format, but at the moment I will accept anything at all). The app uses
 Ring and Moustache and outputs the data.

 We start with a simple atom:

 (def registry (atom {}))

 We put some data in this atom. And then we output it. But I have had
 great difficulty getting anything to appear on the screen. Assuming
 the problem was with the fact the main sequence was lazy, I added in
 doall everywhere it made sense. But I still can not get anything to
 work:

 (defn current-users [request]
   The default action of this app. Add new users to the registry, and
 delete the ones that are more than 15 seconds old
   (let [this-users-params (:params request)
 final-map-for-output {}]
   (add-to-logged-in-registry this-users-params)
   (remove-old-registrants)
   (response (apply str (into {}
  (doall
   (map (fn [each-user-map]
  (doall
   (let [inner-details (second each-
 user-map)]
 (assoc final-map-for-output
 username (get inner-details username nothing found for user))
 (assoc final-map-for-output
 updated (get inner-details updated nothing found for updated))
 final-map-for-output)))
@registry)))

 The various variations I have tried on this have either given me a
 blank white page or:

 {}

 Nothing else.

 I used to do simply:

   (response (apply str (doall @registry)

 This worked fine. But it did not output valid JSON, so I wanted to
 change the format. But I have not been able to get anything to appear
 on screen.

 Suggestions?

 --
 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: how do I evaluate this lazy sequence?

2012-09-27 Thread Jim - FooBar();
the 2 previous responses answered your question perfectly ...I'm just  a 
bit amazed that you would go away and write clojure code to consume JSON 
and all that, without realising that data-structures in Clojure are 
immutable! I think we can all agree they are *the* cornerstone of 
Clojure. It is a bit alien at first but it does pay off in the long 
run... If you absolutely need to stick with your code style (mutability 
not-recommended in general) use a java HashMap instead...


Jim

ps: i recently used a cheshire without any problems :-)

On 27/09/12 18:53, gaz jones wrote:

Couple of initial things, Clojure has immutable data structures so
when you call for example 'assoc' it will return you a new map with
the new values assoc'd. It will not mutate the original, so:

(let [foo {}]
   (assoc foo :a 1)
   (assoc foo :b 2)
   foo)

Will return {}. You need to do something like:

(- {}
  (assoc :a 1)
  (assoc :b 2))

= {:a 1 :b 2}

FYI, assoc takes multiple kvps:

(assoc {} :a 1 :b 2)

Also, to return valid JSON, you cannot simply call 'str' on the map.
You need to use a library like https://github.com/dakrone/cheshire or
https://github.com/clojure/data.json and encode the map as JSON.

Perhaps you could illustrate the data structure you are holding inside
of @registry, and the structure of the JSON you would like to emit.
Laziness is not an issue here.


On Thu, Sep 27, 2012 at 12:02 PM, larry google groups
lawrencecloj...@gmail.com wrote:

I would like 2 types of advice:

1.) an answer to this specific question

2.) advice on how one is suppose to debug mysteries likes this

I have a simple web app that serves some data (hopefully in JSON
format, but at the moment I will accept anything at all). The app uses
Ring and Moustache and outputs the data.

We start with a simple atom:

(def registry (atom {}))

We put some data in this atom. And then we output it. But I have had
great difficulty getting anything to appear on the screen. Assuming
the problem was with the fact the main sequence was lazy, I added in
doall everywhere it made sense. But I still can not get anything to
work:

(defn current-users [request]
   The default action of this app. Add new users to the registry, and
delete the ones that are more than 15 seconds old
   (let [this-users-params (:params request)
 final-map-for-output {}]
   (add-to-logged-in-registry this-users-params)
   (remove-old-registrants)
   (response (apply str (into {}
  (doall
   (map (fn [each-user-map]
  (doall
   (let [inner-details (second each-
user-map)]
 (assoc final-map-for-output
username (get inner-details username nothing found for user))
 (assoc final-map-for-output
updated (get inner-details updated nothing found for updated))
 final-map-for-output)))
@registry)))

The various variations I have tried on this have either given me a
blank white page or:

{}

Nothing else.

I used to do simply:

   (response (apply str (doall @registry)

This worked fine. But it did not output valid JSON, so I wanted to
change the format. But I have not been able to get anything to appear
on screen.

Suggestions?

--
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: how do we go about promoting new clojure libraries?

2012-09-26 Thread Stuart Sierra
http://dev.clojure.org/display/community/Libraries is unorganized and out 
of date - volunteers welcome.

James Reeves created http://www.clojure-toolbox.com/

-S

-- 
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 do we go about promoting new clojure libraries?

2012-09-26 Thread Mayank Jain
On Thu, Sep 27, 2012 at 12:31 AM, Stuart Sierra the.stuart.sie...@gmail.com
 wrote:

 http://dev.clojure.org/display/community/Libraries is unorganized and out
 of date - volunteers welcome.


I am interested in keeping the clojure libraries up to date. Can you give
me some ideas what are the tasks that needs to be done? So that I have some
idea about it.

Thanks.


 James Reeves created http://www.clojure-toolbox.com/

 -S


  --
 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: how do we go about promoting new clojure libraries?

2012-09-26 Thread Stuart Sierra
On Wednesday, September 26, 2012 3:05:08 PM UTC-4, Mayank Jain wrote:

 I am interested in keeping the clojure libraries up to date. Can you give 
 me some ideas what are the tasks that needs to be done? So that I have some 
 idea about it.


1. Send in a signed Clojure Contributor Agreement: 
http://clojure.org/contributing

2. You will receive an editor account on http://dev.clojure.org/

3. Start editing!

Thanks!
-S

-- 
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 do we go about promoting new clojure libraries?

2012-09-26 Thread Mayank Jain
@Stuart
Thanks. But it says Send your signed agreement via postal mail to:
Do I need to send it via postal mail? (I stay in India)

On Thu, Sep 27, 2012 at 12:38 AM, Stuart Sierra the.stuart.sie...@gmail.com
 wrote:

 On Wednesday, September 26, 2012 3:05:08 PM UTC-4, Mayank Jain wrote:

 I am interested in keeping the clojure libraries up to date. Can you give
 me some ideas what are the tasks that needs to be done? So that I have some
 idea about it.


 1. Send in a signed Clojure Contributor Agreement:
 http://clojure.org/contributing

 2. You will receive an editor account on http://dev.clojure.org/

 3. Start editing!

 Thanks!
 -S

  --
 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: how do we go about promoting new clojure libraries?

2012-09-26 Thread Michael Klishin
2012/9/26 Mayank Jain firesof...@gmail.com

 Thanks. But it says Send your signed agreement via postal mail to:
 Do I need to send it via postal mail? (I stay in India)


Unfortunately, yes. Clojure uses a fine crafted 16th century contributor
agreement process that does not
take into account that there may be potential contributors outside of North
America and western Europe.

Please cast your vote in
https://groups.google.com/forum/?fromgroups=#!searchin/clojure/evolving$20the$20clojure/clojure/GnfAK6beMN8/DiMIbvYWhVkJ

so it can be replaced with something that makes sense in the year 2012.
-- 
MK

-- 
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 do we go about promoting new clojure libraries?

2012-09-26 Thread Michael Klishin
2012/9/26 Stuart Sierra the.stuart.sie...@gmail.com

 http://dev.clojure.org/display/community/Libraries is unorganized and out
 of date - volunteers welcome.


Stuart,

No, that's not how it works. You *first* make contribution process easy,
*then* ask people to volunteer.

Not the other way around, no.
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: how do we go about promoting new clojure libraries?

2012-09-26 Thread Baishampayan Ghose
On Wed, Sep 26, 2012 at 12:35 PM, Michael Klishin
michael.s.klis...@gmail.com wrote:
 Unfortunately, yes. Clojure uses a fine crafted 16th century contributor
 agreement process that does not
 take into account that there may be potential contributors outside of North
 America and western Europe.

 Please cast your vote in
 https://groups.google.com/forum/?fromgroups=#!searchin/clojure/evolving$20the$20clojure/clojure/GnfAK6beMN8/DiMIbvYWhVkJ

 so it can be replaced with something that makes sense in the year 2012.

Michael,

IMHO it's not that archaic. There are _many_ FOSS projects which
mandate a CLA of some sort (even the hippest projects like Node.js
have this http://nodejs.org/cla.html). The only contention is the
snail-mailing part, which I understand is cumbersome.

Chef guys have opted to use Echosign for the signing purpose
(http://wiki.opscode.com/display/chef/How+to+Contribute) and I think
it's a decent compromise.

Regards,
BG

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


<    4   5   6   7   8   9   10   11   12   13   >