Re: sql utilities

2010-10-18 Thread Emeka
Beautiful .

Emeka

On Fri, Oct 15, 2010 at 1:08 AM, Stuart Campbell  wrote:

> Thanks Kyle. Looks useful!
>
>
> On 15 October 2010 09:25, Saul Hazledine  wrote:
>
>> On Oct 14, 9:16 pm, "Kyle R. Burton"  wrote:
>> > I've written some sql helper functions that will do things like list
>> > the objects in the database and describe a table.  I've found these
>> > handy when doing interactive development as I don't have to jump over
>> > to another app to see what the make up of tables are.  I've also used
>> > it in some scenarios when generating code from the database schema.
>> >
>>
>> Very cool. If you have no joy getting it into contrib you can have
>> write access to clj-sql if you want it:
>>
>> http://github.com/alienscience/clj-sql
>>
>> Otherwise, as Shanatu says, a github project of your own would be
>> welcome and is sure to be used by others.
>>
>> Saul
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from 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
>



-- 
*Satajanus  Nig. Ltd


*

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Traffic junctions as a metaphor for understanding the STM?

2010-10-18 Thread michele
There is a difference between having limitations and not being
applicable.

The movement of cars through a road intersection is a metaphor for
processes that simultaneously want to change a resource. The traffic
signal is there to hinder these cars to crash, i.e. to make changes in
an uncontrolled way. In an STM there is also a control mechanism, but
the responsibility is on the process instead of on a mechanism that
locks the resource.

In the case of a junction without traffic lights, it would be like
going at full speed through the intersection without checking to see
if and how you can drive through - like in the movie. If you crash,
i.e. another process has made changes to the resource, you roll back
and try again. There is no intelligence on the part of the processes.
If the movie would show drivers crash and then pulled out by tow
trucks, be given a new car, go full speed through the junction again,
then we'd have a nice analogy, and a movie from the 70's.

Also, in the case of STM in Clojure, the resources don't change,
instead identities will point to different values at different moments
in time. Maybe a piece of film strip would somehow help for a better
metaphor.



On 17 Okt, 15:07, Sam Aaron  wrote:
> On 17 Oct 2010, at 8.54 am, michele wrote:
>
>
>
> > Well, there are intelligent beings with the ability to make decisions
> > entering the traffic junction, not exactly the same as with the STM.
>
> Of course, all analogies have their limitations; I wasn't proposing this as a 
> perfect model, just something that gave me some insight. Out of interest, 
> what analogies do you use to conceptualise the STM?
>
> Sam
>
> ---http://sam.aaron.name

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


Pros and cons of macro versus functions

2010-10-18 Thread jbk
I'm new to Clojure and just getting my head around macros. As an
exercise I was trying different ways to wrap making a proxy for
java.util.Comparator and came up with two alternatives. I'm really not
sure how to judge what would favour one solution over the other, and
I'm curious if one style is preferred over the other around the
Clojure community.

First some data:

(def things #{:q :w :e :r :t :y :a :s :d})
(defn inverse-compare [a b] (* -1 (compare a b)))

Using a macro to generate a proxy to change sort order:

(defmacro cmprtr [f] `(proxy [java.util.Comparator] [] (compare
[a# b#] (~f a# b#
(sort (cmprtr inverse-compare) things)

Using a simple function to generate the proxy:

(defn cmpprx [f] (proxy [java.util.Comparator] [] (compare [a b]
(f a b
(sort (cmpprx inverse-compare) things)


Thanks,
Julian.

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


Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
Hi All,

I stuck with performance problem using Clojure.
It seems that when all the optimisation hints are used,
Clojure data processing is still much slower than Java.

In my simple test I sum up 16M of random integers 0 < n < 10.
The code is as follows (see below Java and C code, and the test
script and output):

(def *N* (* 1024 1024 16))
(def *a* (make-array Integer/TYPE *N*))

(dotimes [i *N*] (aset ^ints *a* i (int (* 10 (rand 1.0)

(set! *warn-on-reflection* true)

(defn sum [arr]
  (loop [i (int 0) s (int 0)]
(if (= i *N*) s
  (recur (inc i) (+ s (aget ^ints arr i))

(println "Clojure:" *clojure-version*)
(dotimes [_ 5] (time (println "sum =" (sum *a*

(set! *warn-on-reflection* false)

In this test Clojure is ~15 times slower than the same test in plain
Java.
(The best result is for Clojure 1.2, it's slower for the 1.3-alpha
version,
see the output log below.)

I didn't use there unchecked-inc, unchecked-add, but it doesn't help
much
either. Actually, this is even not about access to the Java array,
because
the sum of constants (1+1+1... ) is evaluated at nearly the same time
(30% more quick, ~10 time slower than the original test in Java).

It's rather surprising, having in mind that Clojure code is compiled
to the bytecode, pretty much the same as Java code is.

I do realize that Java demonstrates an extremely powerful JIT technic
there, since the loop is executed in just ~1 nanosecond which is
~3 CPU cycles on my PC. (Clojure's best result shows ~16ns = ~50 CPU
cycles.)
Although, the same slowdown I observed with more sophisticated tests,
therefore it seems to be a general trend.

Thanks in advance, I would appreciate very much any suggestions or
comments.

Best wishes,
  Dmitriy

P.S. The code for Java/Clojure/C languages, test script, and its
output:

### Sum.java  ###

package Test;
import java.util.Random;

public class Sum {
  public static void main(String args[]) {
int N = 1024*1024*16;
int a[] = new int[N];
int i, cs = 0;

Random r = new Random();

for(i = 0; i < N; i++) {
int r_int = r.nextInt();
a[i] = (r_int > 0 ? r_int : -r_int) % 10;
}

for(int l = 0; l < 5; l++) {
long start = System.currentTimeMillis();
cs = 0;
for(i = 0; i < N; i++) {
cs += a[i];
}
System.out.printf("Elapsed time (Java): %1$d msecs\n",
System.currentTimeMillis() - start);
}

System.out.printf("sum = %1$d\n", cs);
  }
}

### sum.clj  ###

(def *N* (* 1024 1024 16))
(def *a* (make-array Integer/TYPE *N*))

(dotimes [i *N*] (aset ^ints *a* i (int (* 10 (rand 1.0)

(set! *warn-on-reflection* true)

(defn sum [arr]
  (loop [i (int 0) s (int 0)]
(if (= i *N*) s
  (recur (inc i) (+ s (aget ^ints arr i))

(println "Clojure:" *clojure-version*)
(dotimes [_ 5] (time (println "sum =" (sum *a*

(set! *warn-on-reflection* false)

### sum.c  ###

#include 
#include 
#include 
#include 

#define N (1024*1024*16)
int a[N];

int main()
{
int i, cs = 0;
struct timeval t1, t2;

srand(23);
for(i = 0; i < N; i++) {
int rn = rand();
a[i] = rn % 10;
}

gettimeofday(&t1, NULL);
for(i = 0; i < N; i++) {
cs += a[i];
}
gettimeofday(&t2, NULL);
printf("Elapsed time (C): %d msecs\n",
   (t2.tv_sec - t1.tv_sec) * 1000
+ (t2.tv_usec - t1.tv_usec) / 1000);

printf("sum = %d\n", cs);
}

### test-sum.sh  ###

#! /bin/bash

echo System info:
cat /proc/cpuinfo | grep 'model name' | tail -1
uname -rs

# C
echo
gcc --version
gcc -O2 -o sum sum.c
./sum

# Java
echo
javac -6 Test/Sum.java
java -version
java -server -cp . Test.Sum

# Clojure 1.2 alpha
echo
java -server -cp .:clojure.jar clojure.main sum.clj

# Clojure 1.3 alpha
echo
java -server -cp .:clojure-1.3a.jar clojure.main sum.clj

# clean
rm sum Test/Sum.class

### The output:  ###

System info:
model name  : Intel(R) Core(TM)2 Duo CPU E8600  @ 3.33GHz
Linux 2.6.27.19-170.2.35.fc10.i686

gcc (GCC) 4.3.2 20081105 (Red Hat 4.3.2-7)
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There
is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

Elapsed time (C): 14 msecs
sum = 75480349

java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6) (fedora-23.b16.fc10-i386)
OpenJDK Server VM (build 14.0-b16, mixed mode)
Elapsed time (Java): 17 msecs
Elapsed time (Java): 19 msecs
Elapsed time (Java): 14 msecs
Elapsed time (Java): 17 msecs
Elapsed time (Java): 18 msecs
sum = 75490326

Clojure: {:major 1, :minor 2, :incremental 0, :qualifier }
sum = 75488840
"Elapsed time: 568.937934 msecs"
sum = 75488840
"Elapsed time: 285.198714 msecs"
sum = 754

Re: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Jürgen Hötzel
Hi,


(defn sum [^ints arr]
  (areduce arr i ret (int 0)
   (unchecked-add-int ret (aget arr i


2010/10/18 Dmitriy S. :
>
> (defn sum [arr]
>  (loop [i (int 0) s (int 0)]
>    (if (= i *N*) s
^^^

You still doing non-primitive ops here. Also Check for areduce:

(defn sum [^ints arr]
  (areduce arr i ret (int 0)
   (unchecked-add-int ret (aget arr i

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


Network class loader

2010-10-18 Thread Ingmar
Hi community,

I'm using clojure for having a dynamic programming environment in
terms of a client-server process. This is needed for a highly flexible
communication system. The clojure system defines the server, a
programming environment like emacs provides the client. The
communication in between will be accomplished by the swank server.

I have defined a network class loader especially to use with clojure.
The class loader supports dynamically loading classes and clojure
resources (like clj files) from the client. For this, a class loader
server is running on the client site to provide classes and resources
to the class loader. Moreover, not only "require" is supported, but
also the compilation process (AOT). A clojure file can be compiled on
the clojure system, the files will be written back to the client. By
using a global variable, *compile-remote*, one can define whether such
a remote write back should be used or rather a standard write of a
class file.

A question to the community: does anybody need such a feature? I have
made some minor adds to clojure.core. It would be very appreciate to
make the changes public. Who does decide which features will be added?
The classloader is provided as an opensource project part of a more
complex system at sourceforge, http://sourceforge.net/projects/opencommunicate/.

Best regards, Ingmar

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
On Oct 18, 3:07 pm, Jürgen Hötzel  wrote:
> > (defn sum [arr]
> >  (loop [i (int 0) s (int 0)]
> >(if (= i *N*) s
>
> ^^^
>
> You still doing non-primitive ops here.

Indeed, I overlooked that.
But this was not the main cause of the trouble.

> Also Check for areduce:
>
> (defn sum [^ints arr]
>   (areduce arr i ret (int 0)
>            (unchecked-add-int ret (aget arr i

This code works at the top speed.
(the time with Clojure-1.2 now is ~17 msec, same as for Java, and
with Clojure-1.3-alpha it's 67 msec)

By comparing my code with areduce macro I've found
what was the problem -- it's a '=' operator, which I used
instead of '>='.

Therefore this version of areduce is ~10 times slower
(in spite of being equivalent logically with the original one):

(defmacro areduce-slow
  "Reduces an expression across an array a, using an index named idx,
  and return value named ret, initialized to init, setting ret to the
  evaluation of expr at each step, returning ret."
  {:added "1.0"}
  [a idx ret init expr]
  `(let [a# ~a]
 (loop  [~idx (int 0) ~ret ~init]
   (if (= ~idx  (alength a#)) ;; '=' instead of '>=' (but original
areduce uses '<' and ~ret in the 'else' branch)
 ~ret
 (recur (unchecked-inc ~idx) ~expr)

Is it a bug? Should I report it to the development team?

Thanks a lot for the prompt and informative answer.

Regards,
  Dmitriy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread nicolas.o...@gmail.com
I happened to stumble on something like that in 1.2, with
= slower than >=, which is in turn slower than zero?.
(Even when everything is a primitive)

I never really understood why and would be happy to understand it better.
Dimitry, have you tryed to replace (= x y) by (zero? (- x u)), or with
an unchecked substraction?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Pros and cons of macro versus functions

2010-10-18 Thread lprefontaine
Choose functions over macros when you can write an equivalent function.

I use macros when:

a) I have a repetitive pattern in the code that cannot be easily turned
   into a function (too much context to pass as args to a function).
   You can then hide a binding form in the macro to refer to the context
   or directly refer to it (global vars, ...) using form expansion.
   You can wrap huge chunks of your code in the macro referring to the context
   ( & body) easily.

b) I need to evaluate the args (aka the symbols) to alter the form(s)
   generated by the macro and do not want immediate evaluation.

c) I need a lighter syntax. You can marshall the symbols themselves as you 
   wish to refer to other context bindings by sufixing/prefixing the synbol
   names.

   I wrote an interactive report utility used by non-lispers and that helped
   remove some Clojure syntax requirements that would look obscur
   to non-Lispers. The report utility can refer to global bindings while
   the user uses nicknames and other syntatic sugars to simplify the calls.
   This hides references to the context that would clutter the report code
   and make the tool unusable for the average user.

d) I see some potential in tuning the forms later (maybe to create functions)
   but do not want to embark on that journey now. Using macros you can defer
   retooling of your code or hide partial retooling until you are ready
   to change the top form to its definitive look.


Luc P.

jbk  wrote ..
> I'm new to Clojure and just getting my head around macros. As an
> exercise I was trying different ways to wrap making a proxy for
> java.util.Comparator and came up with two alternatives. I'm really not
> sure how to judge what would favour one solution over the other, and
> I'm curious if one style is preferred over the other around the
> Clojure community.
> 
> First some data:
> 
> (def things #{:q :w :e :r :t :y :a :s :d})
> (defn inverse-compare [a b] (* -1 (compare a b)))
> 
> Using a macro to generate a proxy to change sort order:
> 
> (defmacro cmprtr [f] `(proxy [java.util.Comparator] [] (compare
> [a# b#] (~f a# b#
> (sort (cmprtr inverse-compare) things)
> 
> Using a simple function to generate the proxy:
> 
> (defn cmpprx [f] (proxy [java.util.Comparator] [] (compare [a b]
> (f a b
> (sort (cmpprx inverse-compare) things)
> 
> 
> Thanks,
> Julian.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first
> post.
> To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
On Oct 18, 4:44 pm, "nicolas.o...@gmail.com" 
wrote:
> I happened to stumble on something like that in 1.2, with
> = slower than >=, which is in turn slower than zero?.
> (Even when everything is a primitive)
>
> I never really understood why and would be happy to understand it better.
> Dimitry, have you tryed to replace (= x y) by (zero? (- x u)), or with
> an unchecked substraction?

16 msec (>= ~idx  (alength a#)) -- speed of the original areduce
17 msec (zero? (unchecked-subtract (alength a#) ~idx))
33 msec (zero? (- (alength a#) ~idx))
293 msec (= ~idx  (alength a#))

(defmacro areduce-2
  [a idx ret init expr]
  `(let [a# ~a]
 (loop  [~idx (int 0) ~ret ~init]
   (if (>= ~idx (alength a#))
 ~ret
 (recur (unchecked-inc ~idx) ~expr)

So, the problem is really about '=' operator.
I wonder, could it be some kind of special op
(like eq / eqn / equal in Common Lisp)?

Regards,
  Dmitriy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread nicolas.o...@gmail.com
You can try == for numbers

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
On Oct 18, 5:15 pm, "nicolas.o...@gmail.com" 
wrote:
> You can try == for numbers

17 msec (== ~idx  (alength a#))
293 msec (= ~idx  (alength a#))

Yes, it's the case.
I should have checked the API doc for the =/== difference.
Thank you very much.

Best regards,
  Dmitriy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Pros and cons of macro versus functions

2010-10-18 Thread Mike Meyer
On Mon, 18 Oct 2010 08:58:48 -0400 (EDT)
lprefonta...@softaddicts.ca wrote:
> Choose functions over macros when you can write an equivalent function.

>From the LISP community, I'd put it slightly stronger: Only use macros
when you have to. But you get the same set of reasons (with
explanations).

> I use macros when:
> 
> a) I have a repetitive pattern in the code that cannot be easily turned
>into a function (too much context to pass as args to a function).
>You can then hide a binding form in the macro to refer to the context
>or directly refer to it (global vars, ...) using form expansion.
>You can wrap huge chunks of your code in the macro referring to the context
>( & body) easily.

If I understand you correctly, these would be non-hygienic
macros. Yeah, those are pretty much "have to".

> b) I need to evaluate the args (aka the symbols) to alter the form(s)
>generated by the macro and do not want immediate evaluation.

And much of the time, this is because you're not sure you want to
evaluate the form at all, or may want to evaluate it more than
once. Again, a "have to" situation.

> c) I need a lighter syntax. You can marshall the symbols themselves as you 
>wish to refer to other context bindings by sufixing/prefixing the synbol
>names.
> 
>I wrote an interactive report utility used by non-lispers and that helped
>remove some Clojure syntax requirements that would look obscur
>to non-Lispers. The report utility can refer to global bindings while
>the user uses nicknames and other syntatic sugars to simplify the calls.
>This hides references to the context that would clutter the report code
>and make the tool unusable for the average user.

In other words, building DSL's. This is a qualified "have to": "have
to to meet user requirements."

> d) I see some potential in tuning the forms later (maybe to create functions)
>but do not want to embark on that journey now. Using macros you can defer
>retooling of your code or hide partial retooling until you are ready
>to change the top form to its definitive look.

General performance reasons? Yeah. In particular, if you can replace
run-time decisions with compile time-decisions (loop unrolling, etc.)
you can win quite a bit here. Another qualifed "have to": "have to to
meet performance requirements".

  http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Jürgen Hötzel
2010/10/18 Dmitriy S. :
> On Oct 18, 3:07 pm, Jürgen Hötzel  wrote:
>> > (defn sum [arr]
>> >  (loop [i (int 0) s (int 0)]
>> >    (if (= i *N*) s
>>
>> ^^^
>>
>> You still doing non-primitive ops here.
>
> Indeed, I overlooked that.
> But this was not the main cause of the trouble.
>
>> Also Check for areduce:
>>
>> (defn sum [^ints arr]
>>   (areduce arr i ret (int 0)
>>            (unchecked-add-int ret (aget arr i
>
> This code works at the top speed.
> (the time with Clojure-1.2 now is ~17 msec, same as for Java, and
> with Clojure-1.3-alpha it's 67 msec)
>
> By comparing my code with areduce macro I've found
> what was the problem -- it's a '=' operator, which I used
> instead of '>='.
>
> Therefore this version of areduce is ~10 times slower
> (in spite of being equivalent logically with the original one):
>
> (defmacro areduce-slow
>  "Reduces an expression across an array a, using an index named idx,
>  and return value named ret, initialized to init, setting ret to the
>  evaluation of expr at each step, returning ret."
>  {:added "1.0"}
>  [a idx ret init expr]
>  `(let [a# ~a]
>     (loop  [~idx (int 0) ~ret ~init]
>       (if (= ~idx  (alength a#)) ;; '=' instead of '>=' (but original

Note the difference between "=" and "==", "=" will result in a cast to
the wrapped types for it's arguments.

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


Re: Newbie : Java Interop question

2010-10-18 Thread oak
P = Property. Guess it could have been lower case p.

On Oct 15, 11:19 pm, Michael Ossareh  wrote:
> On Fri, Oct 15, 2010 at 09:32, oak  wrote:
> > Hi All,
>
> > This is how i see the package in package explorer.
> > IEssbase.class
> >  (I) IEssbase
> >      (C, s f) Home
> >             (M, s) create(String) IEssbase
> >             (M, c) Home()
> >       (P, s f) JAPI_VERSION
>
> Out of interest what is this format? Are my guesses at the letters accurate?
>
> I == Interface
> C == Class
> M == Method
> P == ?
> s == static
> f == final
> c = class

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
On Oct 18, 5:46 pm, Jürgen Hötzel  wrote:
> Note the difference between "=" and "==", "=" will result in a cast to
> the wrapped types for it's arguments.

It seems that '=' is always slower than '==',
even if types are primitive, look:

Clojure 1.2.0
user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (= a
b
"Elapsed time: 38.438735 msecs"
nil
user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (== a
b
"Elapsed time: 4.79083 msecs"
nil
user=>

Regards,
  Dmitriy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Dmitriy S.
On Oct 18, 5:46 pm, Jürgen Hötzel  wrote:
> Note the difference between "=" and "==", "=" will result in a cast to
> the wrapped types for it's arguments.

It seems that '=' is always slower than '==',
even if types are primitive, look:

Clojure 1.2.0
user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (= a
b
"Elapsed time: 38.438735 msecs"
nil
user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (== a
b
"Elapsed time: 4.79083 msecs"
nil
user=>

Regards,
  Dmitriy

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


SQLAlchemy in Clojure?

2010-10-18 Thread Sean Devlin
Okay, I just finished a Python app for work.  Using SQLAlchemy was a
joy.  Has anyone ported this yet?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Newbie : Java Interop question

2010-10-18 Thread oak
Thanks just what needed to know

On Oct 15, 11:13 pm, Randy Hudson  wrote:
> Nested classes require the syntax AClass$NestedClass -- this being the
> "real name" of the class in the JVM.
> Static members of classes are referenced as AClass/member --
> essentially treating the class as a namespace of its static members.
> So this should do it:
>
> (IEssbase$Home/create IEssbase/JAPI_VERSION)
>
> On Oct 15, 12:32 pm, oak  wrote:
>
>
>
> > Hi All,
>
> > This is how i see the package in package explorer.
> > IEssbase.class
> >   (I) IEssbase
> >       (C, s f) Home
> >              (M, s) create(String) IEssbase
> >              (M, c) Home()
> >        (P, s f) JAPI_VERSION
>
> > I can import like this in Clojure
> > =>(import `(com.essbase.api.session IEssbase))`
>
> > I can also call the property like this with success.
> > =>(IEssbase/JAPI_VERSION)
> > "11.1.1"
> > =>
>
> > In java the code to get this API instance looks like this.
>
> > IEssbase ess = null;
> > ess = IEssbase.Home.create(IEssbase.JAPI_VERSION);
>
> > when in Clojure i try the following
> > => (.. IEssbase Home create IEssbase.JAPI_VERSION)
>
> > I get the message no such Field exists.
>
> > Do i have to use a proxy since IEssbase is an Interface if so how do i
> > make call to create to get instance of API back.

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


Conj arrivals and Thursday night...

2010-10-18 Thread Andrew Gwozdziewycz
Hey Conj goers,

I'm scheduled to arrive around 6:30, and after I check in am planning
to spend the rest of the night writing code. Anyone want to help
commandeer a random lobby to join in on the fun?

Andrew
-- 
http://www.apgwoz.com

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


Re: SQLAlchemy in Clojure?

2010-10-18 Thread Andrew Gwozdziewycz
I think it's very unlikely that someone will port SQLAlchemy to java.
However, there are lots of ORMs which maybe suitable for you to use
from clojure--maybe with some macros to make it a bit nicer. WikiPedia
has a great list of these:

http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software#Java

Having never used any of them, I can't recommend one. I too really
like SQLAlchemy myself.

On Mon, Oct 18, 2010 at 11:18 AM, Sean Devlin  wrote:
> Okay, I just finished a Python app for work.  Using SQLAlchemy was a
> joy.  Has anyone ported this yet?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
http://www.apgwoz.com

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Ryan Waters
I probably wouldn't be able to show up until 8:00pm but I'd be
interested in getting on the 'list' for said group.

Thanks,
Ryan


On Mon, Oct 18, 2010 at 11:32 AM, Andrew Gwozdziewycz  wrote:
> Hey Conj goers,
>
> I'm scheduled to arrive around 6:30, and after I check in am planning
> to spend the rest of the night writing code. Anyone want to help
> commandeer a random lobby to join in on the fun?
>
> Andrew
> --
> http://www.apgwoz.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

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


Need some help with static files and ring...

2010-10-18 Thread lprefontaine
Hi everyone,

I have been banging my head on the walls for a few hours now and really cannot
figure out the proper way to serve static files in a Compojure application
deployed on Tomcat or Glassfish...

Feeling pretty dumb in fact...

I tried to configure the default servlet to catch up requests but I feel
that I cannot escape the Ring routes so this never worked.

The static files reside in the folder stylesheets at the very top of the
application folder. The application path is IDEMDossierPatient.

The HTML link references stylesheets/... 

I get the following stack trace:

SEVERE: Allocate exception for servlet IDEMDossierPatient
java.lang.Exception: Directory does not exist: stylesheets
at ring.middleware.file$ensure_dir.invoke(file.clj:13)
at ring.middleware.file$wrap_file.doInvoke(file.clj:23)
at clojure.lang.RestFn.invoke(RestFn.java:426)
at ring.middleware.static$wrap_static.invoke(static.clj:13)
at 
idem.mr.clinic.webaccess.medicalrecord$eval1206.invoke(medicalrecord.clj:52)
...

The routes are the following (after several attempts with the file wrapper):

(defroutes app-routes
   (GET "/patient" [patient-id]
 (render-page "Dossier médical") (render-page (load-patient-mr patient-id)))
  (GET "/req" req (str req))
  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
  (GET "/" [] (render-page "Saisie du # de patient" patient-form)) 
  (route/not-found "Page inconnue")
)

(wrap! app-routes :stacktrace)
(wrap! app-routes (:static "stylesheets" ["stylesheets"]))

Any ideas where I am going with this aside from a dead end ?
Is there another way to specify the folder for static file ?
Should I specify an absolute path (ugly but given where I am right
now I would not care...) ?
Should I move the folder elsewhere ?

Blblblblblblbl...

Thank you,

Luc 

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

2010-10-18 Thread lprefontaine
Count me out, pretty sure I'll need a drink by the time I arrive (21:00).
I like so much airplane travels, livestock receives more attention from their
carriers than airline passengers these days. Meuh !
 
Luc P.

Ryan Waters  wrote ..
> I probably wouldn't be able to show up until 8:00pm but I'd be
> interested in getting on the 'list' for said group.
> 
> Thanks,
> Ryan
> 
> 
> On Mon, Oct 18, 2010 at 11:32 AM, Andrew Gwozdziewycz  
> wrote:
> > Hey Conj goers,
> >
> > I'm scheduled to arrive around 6:30, and after I check in am planning
> > to spend the rest of the night writing code. Anyone want to help
> > commandeer a random lobby to join in on the fun?
> >
> > Andrew
> > --
> > http://www.apgwoz.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
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first
> post.
> To unsubscribe from 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: Conj arrivals and Thursday night...

2010-10-18 Thread Peter Buckley
I'll be arriving between 9:30 and 10pm, and I expect to be up for some
coding or a drink, or perhaps a little of both.

-Peter

On Mon, Oct 18, 2010 at 2:12 PM,   wrote:
> Count me out, pretty sure I'll need a drink by the time I arrive (21:00).
> I like so much airplane travels, livestock receives more attention from their
> carriers than airline passengers these days. Meuh !
>
> Luc P.
>
> Ryan Waters  wrote ..
>> I probably wouldn't be able to show up until 8:00pm but I'd be
>> interested in getting on the 'list' for said group.
>>
>> Thanks,
>> Ryan
>>
>>
>> On Mon, Oct 18, 2010 at 11:32 AM, Andrew Gwozdziewycz  
>> wrote:
>> > Hey Conj goers,
>> >
>> > I'm scheduled to arrive around 6:30, and after I check in am planning
>> > to spend the rest of the night writing code. Anyone want to help
>> > commandeer a random lobby to join in on the fun?
>> >
>> > Andrew
>> > --
>> > http://www.apgwoz.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
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your 
>> first
>> post.
>> To unsubscribe from 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



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

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


Array types in multimethod?

2010-10-18 Thread stefanmuenchow
Hey :)

I have a little problem defining a multimethod with an array type as
parameter. I have something like this:

(defmulti amethod (fn [& args] (vec (map class args

(defmethod amethod [[C]
  ([par1] (String. par1)))

I want to pass a char-array as parameter. The internal java name i
"[C", but this doesn't work. I also tried "char[]", but the "[]" seem
to be problematic. If I define it this way it works:

(def *char-array-type* (class (make-array Character/TYPE 0)))

(defmulti amethod (fn [& args] (vec (map class args

(defmethod amethod [*char-array-type*]
  ([par1] (String. par1)))

Is there a way to define it without the global constant *char-array-
type*?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Array types in multimethod?

2010-10-18 Thread Meikel Brandmeyer
Hi,

user=> (defmulti foo type)
#'user/foo
user=> (defmethod foo (Class/forName "[C") [_] (println "It's an array!"))
#
user=> (foo (make-array Character/TYPE 1))
It's an array!
nil

Could be easier... Hope this helps.

Sincerely
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


Dot special form problem.

2010-10-18 Thread Sergio Arbeo
Hello, everyone,

I'm having problems with the dot special form. First things first, I
have src-out defined this way:

http://gist.github.com/632852

Then, I have problems using that function as an argument for a macro:

http://gist.github.com/632849

Evaluation aborted throws an exception, shown in one of the three
files. The original macro is there too. Why does that fail if it is
called with (src-out) but it doesn't if called with (src-out) already
evalled?

Thanks,

Serabe

-- 
http://sergio.arbeo.net
http://www.serabe.com

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


Re: Need some help with static files and ring...

2010-10-18 Thread Linus Ericsson
This tutorial covers the subject pretty well, I assume you've already read
it.

http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

according to it you should use

"Next, include the necessary Ring middleware:

(:use ring.middleware.file)
(:use ring.middleware.file-info)


and update the middleware stack to look like:


(def app
  (-> #'handler
(wrap-file "public")
(wrap-file-info)
(wrap-request-logging)
(wrap-reload '[adder.middleware adder.core])
(wrap-bounce-favicon)
(wrap-stacktrace)))

"

I really hope that can be of help, I remeber I struggled about this myself,
I don't remeber if I finally got it working.

/Linus

2010/10/18 

> Hi everyone,
>
> I have been banging my head on the walls for a few hours now and really
> cannot
> figure out the proper way to serve static files in a Compojure application
> deployed on Tomcat or Glassfish...
>
> Feeling pretty dumb in fact...
>
> I tried to configure the default servlet to catch up requests but I feel
> that I cannot escape the Ring routes so this never worked.
>
> The static files reside in the folder stylesheets at the very top of the
> application folder. The application path is IDEMDossierPatient.
>
> The HTML link references stylesheets/...
>
> I get the following stack trace:
>
> SEVERE: Allocate exception for servlet IDEMDossierPatient
> java.lang.Exception: Directory does not exist: stylesheets
>at ring.middleware.file$ensure_dir.invoke(file.clj:13)
>at ring.middleware.file$wrap_file.doInvoke(file.clj:23)
>at clojure.lang.RestFn.invoke(RestFn.java:426)
>at ring.middleware.static$wrap_static.invoke(static.clj:13)
>at
> idem.mr.clinic.webaccess.medicalrecord$eval1206.invoke(medicalrecord.clj:52)
> ...
>
> The routes are the following (after several attempts with the file
> wrapper):
>
> (defroutes app-routes
>   (GET "/patient" [patient-id]
> (render-page "Dossier médical") (render-page (load-patient-mr
> patient-id)))
>  (GET "/req" req (str req))
>  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
>  (GET "/" [] (render-page "Saisie du # de patient" patient-form))
>  (route/not-found "Page inconnue")
> )
>
> (wrap! app-routes :stacktrace)
> (wrap! app-routes (:static "stylesheets" ["stylesheets"]))
>
> Any ideas where I am going with this aside from a dead end ?
> Is there another way to specify the folder for static file ?
> Should I specify an absolute path (ugly but given where I am right
> now I would not care...) ?
> Should I move the folder elsewhere ?
>
> Blblblblblblbl...
>
> Thank you,
>
> Luc
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from 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: Dot special form problem.

2010-10-18 Thread Kevin Downey
clojure works something like reader -> macro expansion -> compiler (eval) -> run

the exception you are seeing means that your macro expansion contains
a form that the compiler doesn't know how to generate code for. for
example if your macro expansion contained a Graphics2d object the
compiler would barf because it doesn't know how to generate code that
will reconstruct that Graphics2d object at runtime.

this happens a lot if you write macros and don't understand the
difference between the stages given above. macros should generally not
be running code, they should be emitting code that then gets compiled
and later run.

On Mon, Oct 18, 2010 at 12:42 PM, Sergio Arbeo  wrote:
> Hello, everyone,
>
> I'm having problems with the dot special form. First things first, I
> have src-out defined this way:
>
> http://gist.github.com/632852
>
> Then, I have problems using that function as an argument for a macro:
>
> http://gist.github.com/632849
>
> Evaluation aborted throws an exception, shown in one of the three
> files. The original macro is there too. Why does that fail if it is
> called with (src-out) but it doesn't if called with (src-out) already
> evalled?
>
> Thanks,
>
> Serabe
>
> --
> http://sergio.arbeo.net
> http://www.serabe.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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Need some help with static files and ring...

2010-10-18 Thread lprefontaine
This is a more recent tutorial than what I had in my hands up to now
so I'll work on it tonight and look at the example app closely.

Thank you

Luc P.

Linus Ericsson  wrote ..
> This tutorial covers the subject pretty well, I assume you've already read
> it.
> 
> http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html
> 
> according to it you should use
> 
> "Next, include the necessary Ring middleware:
> 
> (:use ring.middleware.file)
> (:use ring.middleware.file-info)
> 
> 
> and update the middleware stack to look like:
> 
> 
> (def app
>   (-> #'handler
> (wrap-file "public")
> (wrap-file-info)
> (wrap-request-logging)
> (wrap-reload '[adder.middleware adder.core])
> (wrap-bounce-favicon)
> (wrap-stacktrace)))
> 
> "
> 
> I really hope that can be of help, I remeber I struggled about this myself,
> I don't remeber if I finally got it working.
> 
> /Linus
> 
> 2010/10/18 
> 
> > Hi everyone,
> >
> > I have been banging my head on the walls for a few hours now and really
> > cannot
> > figure out the proper way to serve static files in a Compojure application
> > deployed on Tomcat or Glassfish...
> >
> > Feeling pretty dumb in fact...
> >
> > I tried to configure the default servlet to catch up requests but I feel
> > that I cannot escape the Ring routes so this never worked.
> >
> > The static files reside in the folder stylesheets at the very top of the
> > application folder. The application path is IDEMDossierPatient.
> >
> > The HTML link references stylesheets/...
> >
> > I get the following stack trace:
> >
> > SEVERE: Allocate exception for servlet IDEMDossierPatient
> > java.lang.Exception: Directory does not exist: stylesheets
> >at ring.middleware.file$ensure_dir.invoke(file.clj:13)
> >at ring.middleware.file$wrap_file.doInvoke(file.clj:23)
> >at clojure.lang.RestFn.invoke(RestFn.java:426)
> >at ring.middleware.static$wrap_static.invoke(static.clj:13)
> >at
> > idem.mr.clinic.webaccess.medicalrecord$eval1206.invoke(medicalrecord.clj:52)
> > ...
> >
> > The routes are the following (after several attempts with the file
> > wrapper):
> >
> > (defroutes app-routes
> >   (GET "/patient" [patient-id]
> > (render-page "Dossier médical") (render-page (load-patient-mr
> > patient-id)))
> >  (GET "/req" req (str req))
> >  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
> >  (GET "/" [] (render-page "Saisie du # de patient" patient-form))
> >  (route/not-found "Page inconnue")
> > )
> >
> > (wrap! app-routes :stacktrace)
> > (wrap! app-routes (:static "stylesheets" ["stylesheets"]))
> >
> > Any ideas where I am going with this aside from a dead end ?
> > Is there another way to specify the folder for static file ?
> > Should I specify an absolute path (ugly but given where I am right
> > now I would not care...) ?
> > Should I move the folder elsewhere ?
> >
> > Blblblblblblbl...
> >
> > Thank you,
> >
> > Luc
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first
> post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Kyle R. Burton
Andrew,

Several of us are car pooling down from Philly and should be arriving
some time between 6 and 8pm.  I will be hoping to drop off our bags
and get dinner somewhere and otherwise be social with other
conferencegoers.  Are there any recommendations for dinner the night
before?  Any social events or get-togethers on Thursday evening?

Regards,

Kyle

On Mon, Oct 18, 2010 at 12:32 PM, Andrew Gwozdziewycz  wrote:
> Hey Conj goers,
>
> I'm scheduled to arrive around 6:30, and after I check in am planning
> to spend the rest of the night writing code. Anyone want to help
> commandeer a random lobby to join in on the fun?
>
> Andrew
> --
> http://www.apgwoz.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



-- 
Twitter: @kyleburton
Blog: http://asymmetrical-view.com/
Fun: http://snapclean.me/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Need some help with static files and ring...

2010-10-18 Thread David Jagoe
Hey Luc,

Are you deploying to Tomcat using a war file? Are you perhaps missing
the :web-content key in your project.clj file (I presume you're using
Leiningen + leiningen-war)

(defproject myproject "0.0.1"
  :description ""
  :dependencies [[org.clojure/clojure "1.2.0"]
  ... ]
  :dev-dependencies [...
 [uk.org.alienscience/leiningen-war "0.0.8"]]
  ;; Used by leiningen-war to deploy static resources
  :web-content "public"
  :aot [myproject.servlet])

In your case "public" would be "stylesheets".

Is this the approach you're taking? Ultimately it is probably a best
to let nginx or apache serve up static files (rather than tomcat/ring)
but at the moment I am actually just serving up static content
directly from Tomcat which works fine. I have one servlet handling the
application and a default servlet on the same Tomcat instance serving
up the static files. So I only use the file middleware in development:

   (wrap-if development? wrap-file "public")
   (wrap-if development? wrap-file-info)

Not sure if that addresses your problem?


Cheers,
David


On 18 October 2010 20:06,   wrote:
> Hi everyone,
>
> I have been banging my head on the walls for a few hours now and really cannot
> figure out the proper way to serve static files in a Compojure application
> deployed on Tomcat or Glassfish...
>
> Feeling pretty dumb in fact...
>
> I tried to configure the default servlet to catch up requests but I feel
> that I cannot escape the Ring routes so this never worked.
>
> The static files reside in the folder stylesheets at the very top of the
> application folder. The application path is IDEMDossierPatient.
>
> The HTML link references stylesheets/...
>
> I get the following stack trace:
>
> SEVERE: Allocate exception for servlet IDEMDossierPatient
> java.lang.Exception: Directory does not exist: stylesheets
>    at ring.middleware.file$ensure_dir.invoke(file.clj:13)
>    at ring.middleware.file$wrap_file.doInvoke(file.clj:23)
>    at clojure.lang.RestFn.invoke(RestFn.java:426)
>    at ring.middleware.static$wrap_static.invoke(static.clj:13)
>    at 
> idem.mr.clinic.webaccess.medicalrecord$eval1206.invoke(medicalrecord.clj:52)
> ...
>
> The routes are the following (after several attempts with the file wrapper):
>
> (defroutes app-routes
>   (GET "/patient" [patient-id]
>     (render-page "Dossier médical") (render-page (load-patient-mr 
> patient-id)))
>  (GET "/req" req (str req))
>  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
>  (GET "/" [] (render-page "Saisie du # de patient" patient-form))
>  (route/not-found "Page inconnue")
> )
>
> (wrap! app-routes :stacktrace)
> (wrap! app-routes (:static "stylesheets" ["stylesheets"]))
>
> Any ideas where I am going with this aside from a dead end ?
> Is there another way to specify the folder for static file ?
> Should I specify an absolute path (ugly but given where I am right
> now I would not care...) ?
> Should I move the folder elsewhere ?
>
> Blblblblblblbl...
>
> Thank you,
>
> Luc
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from 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: SQLAlchemy in Clojure?

2010-10-18 Thread Michael Ossareh
>
> On Mon, Oct 18, 2010 at 11:18 AM, Sean Devlin 
> wrote:
> > Okay, I just finished a Python app for work.  Using SQLAlchemy was a
> > joy.  Has anyone ported this yet?
>
>
Having never used SQLAlchemy, and rarely python, what are the benefits of
SQLAlchemy? My only experience with ORM was hibernate and it was a pretty
bad experience, the whole time left thinking "Why use this over SQL?" - the
only answer I came up with was not having to write the table/column to
object/property mapping stuff, which alone was not worth the concision lost
to not writing my own queries. Also ... that whole lazy loading situation is
a real PITA in my experience.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Need some help with static files and ring...

2010-10-18 Thread James Reeves
On 18 October 2010 19:06,   wrote:
> The routes are the following (after several attempts with the file wrapper):
>
> (defroutes app-routes
>   (GET "/patient" [patient-id]
>     (render-page "Dossier médical") (render-page (load-patient-mr 
> patient-id)))
>  (GET "/req" req (str req))
>  (GET "/file" [] (doto (java.io.File. ".") (.getAbsolutePath)))
>  (GET "/" [] (render-page "Saisie du # de patient" patient-form))
>  (route/not-found "Page inconnue")
> )

There's a function called compojure.route/files that is designed to
serve static files from a directory:

  (defroutes app-routes
    (GET "/patient" [patient-id]
  (do-something))
(route/files "/")
(route/not-found "Page inconnue"))

The route/files function serves files from "./public" by default, but
you can change this by specifying the :root option:

  (route/files "/" {:root "./static"})

You can also serve files from resources, using compojure.route/resources:

  (route/resources "/")

Like route/files, you can change the root prefix with :root. By
default, it looks in "/public", so if you're using Leiningen, you can
put your files in "./resources/public".

Note that route/resources doesn't support index files (e.g. "/foo/"
becomes "/foo/index.html").

I'll write all this up on the Compojure wiki. My attention has been on
the Ring documentation lately, so I haven't done much on Compojure.

- 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


Re: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Jürgen Hötzel
2010/10/18 Dmitriy S. :
> On Oct 18, 5:46 pm, Jürgen Hötzel  wrote:
>> Note the difference between "=" and "==", "=" will result in a cast to
>> the wrapped types for it's arguments.
>
> It seems that '=' is always slower than '==',
> even if types are primitive, look:
>
> Clojure 1.2.0
> user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (= a
> b
> "Elapsed time: 38.438735 msecs"
> nil
> user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (== a
> b
> "Elapsed time: 4.79083 msecs"
> nil
> user=>

Rich just added primitve = support:

http://github.com/clojure/clojure/commit/df8c65a286e90e93972bb69392bc106128427dde

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Toni Batchelli
I'll be in by 7pm or so. I am down for coding and coffee, or drinks and no
coding, or what the hell, drinks and coding, but then no git commits...

Toni.

On Mon, Oct 18, 2010 at 9:32 AM, Andrew Gwozdziewycz wrote:

> Hey Conj goers,
>
> I'm scheduled to arrive around 6:30, and after I check in am planning
> to spend the rest of the night writing code. Anyone want to help
> commandeer a random lobby to join in on the fun?
>
> Andrew
> --
> http://www.apgwoz.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




-- 
Antoni Batchelli
- twitter: @tbatchelli , @disclojure
--- email: tbatche...@gmail.com
- web: tbatchelli.org , disclojure.org

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

2010-10-18 Thread Eric Lavigne
> Hey Conj goers,
>
> I'm scheduled to arrive around 6:30, and after I check in am planning
> to spend the rest of the night writing code. Anyone want to help
> commandeer a random lobby to join in on the fun?
>
> Andrew

Count me in. Sounds like a great way to kick off the conference. My
plane gets in at 1:39, so I can also meet earlier if anyone is up for
it.

Also looking for a Saturday evening activity, since the after-party
ran out of tickets so quickly. Am I the only Clojurian who didn't
check for new mail between 1:22pm and ~4pm, or are there just a lot
more Clojurians than I imagined? :-)

Looking forward to meeting everyone in a few days!

Eric Lavigne
352-871-7829
http://twitter.com/ericlavigne
lavigne.e...@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


Keyword names and namespaces

2010-10-18 Thread Rob Lachlan
There seems to be a discrepancy between what keyword names are
supposed to be allowed, according to the reader documentation, and
which the reader actually allows.  For instance, periods are supposed
to be disallowed in keyword names, and only one forward slash allowed,
but no errors are thrown at something like this:

{:f/o/o.o :bar}

The key :f/o/o.o is interpreted as a keyword with namespace f/o and
name o.o

Using the keyword function, we seem to be able to make keywords out of
any pair arbitrary strings, even including spaces.  This might seem
pathological, but since keywords just evaluate to themselves there
doesn't seem to be great harm in allowing this kind of liberal
behavior.  (Note also that keywords don't create a namespace, so we
don't have to worry about inadmissible namespaces for keywords.)

On the other hand, if this isn't to be allowed, then shouldn't the
keyword function throw an error when inadmissible strings are provided
for namespaces or names?  I should point out that the symbol function
is also similarly permissive, and that seems like it might be more
worrisome.  I would be in favor of keeping the behavior of the keyword
function as is, but possibly making the symbol function a bit
stricter.

Note, I'm using version 1.2.  This all is motivated by a stackoverflow
discussion: 
http://stackoverflow.com/questions/3951761/what-are-the-allowed-characters-in-a-clojure-keyword/

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

2010-10-18 Thread Seth
What's this about an after party?

On Oct 18, 5:59 pm, Eric Lavigne  wrote:
> > Hey Conj goers,
>
> > I'm scheduled to arrive around 6:30, and after I check in am planning
> > to spend the rest of the night writing code. Anyone want to help
> > commandeer a random lobby to join in on the fun?
>
> > Andrew
>
> Count me in. Sounds like a great way to kick off the conference. My
> plane gets in at 1:39, so I can also meet earlier if anyone is up for
> it.
>
> Also looking for a Saturday evening activity, since the after-party
> ran out of tickets so quickly. Am I the only Clojurian who didn't
> check for new mail between 1:22pm and ~4pm, or are there just a lot
> more Clojurians than I imagined? :-)
>
> Looking forward to meeting everyone in a few days!
>
> Eric Lavigne
> 352-871-7829http://twitter.com/ericlavigne
> lavigne.e...@gmail.com

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


Re: Keyword names and namespaces

2010-10-18 Thread Abhishek Reddy
Hi,

The reader (LispReader) and the interning functions (symbol and keyword) are
separate.  The reader tries to enforce some constraints, but overlooks some
edge cases, before eventually interning.  The interning functions do not
validate input.

Besides the problems you raised, there are some confusing edge cases
involving colons.  For example, there is no implicit way to produce a symbol
of the name ":b", but you can get away with the qualified form (read-string
"user/:b").  Similarly, (read-string ":user/:b") produces a keyword symbol
of the name ":b".

Also, repeating colons are disallowed, and checked in the reader.
Presumably, this is to prevent reading something like "a/::b".  But then the
rule could probably be relaxed to only check for colons at the start of the
name.  (Incidentally, this would be useful for applying the reader to data
-- as swank-clojure tries to -- from other lisps such as CL, where foo::bar
is meaningful.)

Meanwhile, the interning functions do not check for any of this.  You can
get away with (symbol "a::b") and so on.  I suspect it would take some more
serious refactoring to get them to run the same checks as the reader, but I
don't know if they are intentionally or accidentally more liberal in the
first place.  Anyway, I would like to see at least the reader adopt a more
complete and consistent validation routine too.

Cheers


On Tue, Oct 19, 2010 at 11:02 AM, Rob Lachlan wrote:

> There seems to be a discrepancy between what keyword names are
> supposed to be allowed, according to the reader documentation, and
> which the reader actually allows.  For instance, periods are supposed
> to be disallowed in keyword names, and only one forward slash allowed,
> but no errors are thrown at something like this:
>
> {:f/o/o.o :bar}
>
> The key :f/o/o.o is interpreted as a keyword with namespace f/o and
> name o.o
>
> Using the keyword function, we seem to be able to make keywords out of
> any pair arbitrary strings, even including spaces.  This might seem
> pathological, but since keywords just evaluate to themselves there
> doesn't seem to be great harm in allowing this kind of liberal
> behavior.  (Note also that keywords don't create a namespace, so we
> don't have to worry about inadmissible namespaces for keywords.)
>
> On the other hand, if this isn't to be allowed, then shouldn't the
> keyword function throw an error when inadmissible strings are provided
> for namespaces or names?  I should point out that the symbol function
> is also similarly permissive, and that seems like it might be more
> worrisome.  I would be in favor of keeping the behavior of the keyword
> function as is, but possibly making the symbol function a bit
> stricter.
>
> Note, I'm using version 1.2.  This all is motivated by a stackoverflow
> discussion:
> http://stackoverflow.com/questions/3951761/what-are-the-allowed-characters-in-a-clojure-keyword/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en




-- 
Abhishek Reddy
http://abhishek.geek.nz

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

2010-10-18 Thread Eric Lavigne
> What's this about an after party?

I received an email today at 1:22pm with the following link, but when
I tried to register at ~4pm it said sold out. More recently, tickets
became available again and I have one printed out on my desk.
Hopefully there's one left for you, too. :-)

http://conjafterparty.eventbrite.com/

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread lprefontaine
Hu ? What party ? Where ? When ?

Luc

Seth  wrote ..
> What's this about an after party?
> 
> On Oct 18, 5:59 pm, Eric Lavigne  wrote:
> > > Hey Conj goers,
> >
> > > I'm scheduled to arrive around 6:30, and after I check in am planning
> > > to spend the rest of the night writing code. Anyone want to help
> > > commandeer a random lobby to join in on the fun?
> >
> > > Andrew
> >
> > Count me in. Sounds like a great way to kick off the conference. My
> > plane gets in at 1:39, so I can also meet earlier if anyone is up for
> > it.
> >
> > Also looking for a Saturday evening activity, since the after-party
> > ran out of tickets so quickly. Am I the only Clojurian who didn't
> > check for new mail between 1:22pm and ~4pm, or are there just a lot
> > more Clojurians than I imagined? :-)
> >
> > Looking forward to meeting everyone in a few days!
> >
> > Eric Lavigne
> > 352-871-7829http://twitter.com/ericlavigne
> > lavigne.e...@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

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

2010-10-18 Thread lprefontaine
No email received but just got one :)))

Luc P.

Eric Lavigne  wrote ..
> > What's this about an after party?
> 
> I received an email today at 1:22pm with the following link, but when
> I tried to register at ~4pm it said sold out. More recently, tickets
> became available again and I have one printed out on my desk.
> Hopefully there's one left for you, too. :-)
> 
> http://conjafterparty.eventbrite.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

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Simple loop in Clojure is ~15 times slower than in Java

2010-10-18 Thread Sean Corfield
Using the latest 1.3.0-master-SNAPSHOT:

user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (== a b
"Elapsed time: 3.355 msecs"
nil
user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (= a b
"Elapsed time: 3.884 msecs"
nil

Yay!

On Mon, Oct 18, 2010 at 2:40 PM, Jürgen Hötzel  wrote:
> 2010/10/18 Dmitriy S. :
>> On Oct 18, 5:46 pm, Jürgen Hötzel  wrote:
>>> Note the difference between "=" and "==", "=" will result in a cast to
>>> the wrapped types for it's arguments.
>>
>> It seems that '=' is always slower than '==',
>> even if types are primitive, look:
>>
>> Clojure 1.2.0
>> user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (= a
>> b
>> "Elapsed time: 38.438735 msecs"
>> nil
>> user=> (time (let [a (int 3) b (int 5)] (dotimes [_ 100] (== a
>> b
>> "Elapsed time: 4.79083 msecs"
>> nil
>> user=>
>
> Rich just added primitve = support:
>
> http://github.com/clojure/clojure/commit/df8c65a286e90e93972bb69392bc106128427dde
>
> 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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Michael Ossareh
>
>
> Eric Lavigne  wrote ..
> > > What's this about an after party?
>
>

jealous :(

/me darns this startup life that doesn't permit travel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Dot special form problem.

2010-10-18 Thread Sergio Arbeo
So sorry. Now it is working. Don't know why though.


-- 
http://sergio.arbeo.net
http://www.serabe.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


Best syntax for clojure-clr generics

2010-10-18 Thread Seth
I would like to start a discussion on the best syntax for clojure-clr
generics because in most large pieces of software on CLR you have to
specify types to create generic classes. Heres my proposal.

<> Reader macro expands to the macro g
example:

(AGenericClass.  arg1
arg2)
expands to
(AGenericClass. (g Double Integer (a-form-which-returns-class) arg1
arg2)
expands to
(AGenericClass. (#generic-id-gen-symbol Double Integer ...) ...)

and the . operator will look for the #generic-id-gen-symbol as the
first argument and will then realize it must create a generic class,
the symbol would be invalid in any other place. Or maybe the <> would
add metadata to the object, and the . macro could access this metadata
to determine if it needs to create a generic?

I think the <> Syntax would be the easiest and most convenient to use.

Any opinions or other 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: Dot special form problem.

2010-10-18 Thread Sergio Arbeo
On 18 October 2010 22:05, Kevin Downey  wrote:
> clojure works something like reader -> macro expansion -> compiler (eval) -> 
> run
>
> the exception you are seeing means that your macro expansion contains
> a form that the compiler doesn't know how to generate code for. for
> example if your macro expansion contained a Graphics2d object the
> compiler would barf because it doesn't know how to generate code that
> will reconstruct that Graphics2d object at runtime.
>
> this happens a lot if you write macros and don't understand the
> difference between the stages given above. macros should generally not
> be running code, they should be emitting code that then gets compiled
> and later run.

Thank you for the explanation.

Serabe

-- 
http://sergio.arbeo.net
http://www.serabe.com

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Andrew Gwozdziewycz
On Mon, Oct 18, 2010 at 4:13 PM, Kyle R. Burton  wrote:
> Andrew,
>
> Several of us are car pooling down from Philly and should be arriving
> some time between 6 and 8pm.  I will be hoping to drop off our bags
> and get dinner somewhere and otherwise be social with other
> conferencegoers.  Are there any recommendations for dinner the night
> before?  Any social events or get-togethers on Thursday evening?
>

I don't know of any social events going on. I had considered trying to
have a Clojure specific Hack and Tell (http://hackandtell.org) because
there are certainly more than enough crazy and cool things happening
in clojure to warrant it, but it sounds like arrivals would make it
hard to coordinate some sort of effort like that. I'd certainly be
willing to take part in some sort of social event, dinner or
otherwise, and code afterwards (I don't drink, so I'll still be sober
:)).

I'd also certainly like to catch up with Philly folks (provided I know
them, (or meet them if I don't)).

> On Mon, Oct 18, 2010 at 12:32 PM, Andrew Gwozdziewycz  
> wrote:
>> Hey Conj goers,
>>
>> I'm scheduled to arrive around 6:30, and after I check in am planning
>> to spend the rest of the night writing code. Anyone want to help
>> commandeer a random lobby to join in on the fun?
>>
>> Andrew
>> --
>> http://www.apgwoz.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
>
>
>
> --
> Twitter: @kyleburton
> Blog: http://asymmetrical-view.com/
> Fun: http://snapclean.me/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
http://www.apgwoz.com

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


Re: Conj arrivals and Thursday night...

2010-10-18 Thread Christopher Petrilli
I'll be driving down from DC, and probably arriving between 5-6.  Just
as a note, I'd highly recommend not being anywhere near DC between
4-8p due to traffic.  It could easily add 2 hours to your trip.

On Mon, Oct 18, 2010 at 4:13 PM, Kyle R. Burton  wrote:
> Andrew,
>
> Several of us are car pooling down from Philly and should be arriving
> some time between 6 and 8pm.  I will be hoping to drop off our bags
> and get dinner somewhere and otherwise be social with other
> conferencegoers.  Are there any recommendations for dinner the night
> before?  Any social events or get-togethers on Thursday evening?
>
> Regards,
>
> Kyle
>
> On Mon, Oct 18, 2010 at 12:32 PM, Andrew Gwozdziewycz  
> wrote:
>> Hey Conj goers,
>>
>> I'm scheduled to arrive around 6:30, and after I check in am planning
>> to spend the rest of the night writing code. Anyone want to help
>> commandeer a random lobby to join in on the fun?
>>
>> Andrew
>> --
>> http://www.apgwoz.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
>
>
>
> --
> Twitter: @kyleburton
> Blog: http://asymmetrical-view.com/
> Fun: http://snapclean.me/
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
| Chris Petrilli
| petri...@amber.org

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

2010-10-18 Thread Phil Hagelberg
On Mon, Oct 18, 2010 at 3:02 PM, Rob Lachlan  wrote:
> There seems to be a discrepancy between what keyword names are
> supposed to be allowed, according to the reader documentation, and
> which the reader actually allows.  For instance, periods are supposed
> to be disallowed in keyword names, and only one forward slash allowed,
> but no errors are thrown at something like this:

I think the official stance is that there's a big difference between
what is officially supported and what you happen to be able to do in
the current version without things blowing up.

> Using the keyword function, we seem to be able to make keywords out of
> any pair arbitrary strings, even including spaces.

I submitted a patch for this over a year ago, but I gather there were
some concerns about the runtime cost of such behaviour. It's one of
the most long-standing tickets still open:

https://www.assembla.com/spaces/clojure/tickets/17-gc-issue-13-%09validate-in-(keyword-s)-and-(symbol-s)

-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


Behaviour of clojure.set functions with non-sets.

2010-10-18 Thread Phil Hagelberg
It looks like the behaviour of some clojure.set functions is either
undefined or possibly erroneous when called with non-set arguments:

user> (clojure.set/union #{:a :b} [:b :c])
#{:a :c :b}
user> (clojure.set/union #{:a} [:b :c])
[:b :c :a]

Seems likely that the behaviour in such cases is just undefined, but I
wonder if it would be worth calling set on each argument just to avoid
weird edge-case bugs. Is it a cheap operation to call set on a set?

-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


Re: Keyword names and namespaces

2010-10-18 Thread Rob Lachlan
I see, thank you for linking to the ticket, Phil that really clarifies
things.  I suppose that I would tend more to Chas Emerick's view in
his sept 28 comment (on the ticket), questioning whether there is a
need to validate Keywords (and possibly symbols) stringently.  But
I'll take your point that we shouldn't count on the current behaviour
continuing.

Rob

On Oct 18, 9:24 pm, Phil Hagelberg  wrote:
> On Mon, Oct 18, 2010 at 3:02 PM, Rob Lachlan  wrote:
> > There seems to be a discrepancy between what keyword names are
> > supposed to be allowed, according to the reader documentation, and
> > which the reader actually allows.  For instance, periods are supposed
> > to be disallowed in keyword names, and only one forward slash allowed,
> > but no errors are thrown at something like this:
>
> I think the official stance is that there's a big difference between
> what is officially supported and what you happen to be able to do in
> the current version without things blowing up.
>
> > Using the keyword function, we seem to be able to make keywords out of
> > any pair arbitrary strings, even including spaces.
>
> I submitted a patch for this over a year ago, but I gather there were
> some concerns about the runtime cost of such behaviour. It's one of
> the most long-standing tickets still open:
>
> https://www.assembla.com/spaces/clojure/tickets/17-gc-issue-13-%09val...)
>
> -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


Re: Behaviour of clojure.set functions with non-sets.

2010-10-18 Thread Rob Lachlan
It's not free.

(defn set
  "Returns a set of the distinct elements of coll."
  {:added "1.0"}
  [coll] (clojure.lang.PersistentHashSet/create ^clojure.lang.ISeq
(seq coll)))

It seems to go element by element, irrespective of whether it was
given a hashset.

Rob

On Oct 18, 9:43 pm, Phil Hagelberg  wrote:
> It looks like the behaviour of some clojure.set functions is either
> undefined or possibly erroneous when called with non-set arguments:
>
> user> (clojure.set/union #{:a :b} [:b :c])
> #{:a :c :b}
> user> (clojure.set/union #{:a} [:b :c])
> [:b :c :a]
>
> Seems likely that the behaviour in such cases is just undefined, but I
> wonder if it would be worth calling set on each argument just to avoid
> weird edge-case bugs. Is it a cheap operation to call set on a set?
>
> -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