bit-and reflection warning

2010-06-02 Thread rzeze...@gmail.com
When using bit-and with longs I get a reflection warning.  How can I
make this go away?


user (bit-and (long -10) 0x)
Reflection warning, NO_SOURCE_FILE:1 - call to and can't be resolved.
4294967286

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

2010-06-02 Thread Konrad Hinsen

On 1 Jun 2010, at 20:24, Travis Hoffman wrote:


I was curious what it would take to add a complex number type to
Clojure Core. If anyone else is curious, it doesn't take much:

1.) Add clojure.lang.Complex
2.) Add a Pattern and code to match, parse and create complex numbers
in LispReader (parses number of the form 1.0+0.0i)
3.) Add ComplexOps class (and a few related


Two comments:

1) The first decision concerning complex numbers is what you want to  
use them for. There at least three reasonable internal  
representations, depending on the application domains:

a) (defrecord complex [^Float real ^Float imag])
b) (defrecord complex [^java.lang.Number real ^java.lang.Number imag])
c) (defrecord complex [real imag])

The first is good for numerical work as it occurs in science and  
engineering. It permits the most efficient implementation because all  
operations can be expressed in terma of Java primitive types. The  
second is the most consistent with Clojure's numerical stack, allowing  
real and imaginary parts to be integers, ratios, big integers etc. -  
but there would need to be a check to prevent complex numbers to be  
used inside complex numbers. The last one is the most general in that  
complex numbers are seen as mathematical structures rather than as  
numbers; it permits complex polynomials and other data structures that  
are not numbers. As a consequence, it can't be implemented in the  
number hierarchy.


An implementation equivalent to c) but predating defrecord and deftype  
can be found in clojure-contrib. I think it is useful to have  
(otherwise I wouldn't have written it), but I don't think it should be  
part of the language itself. If I were to choose a representation to  
be added to clojure.core, I'd pick b).


2) It is a good idea to provide an imaginary type in addition to  
complex. There is an old and much-cited paper that explains the  
reasons very well; it comes down to eliminating needless  
multiplications and additions with zero when dealing with pure  
imaginaries, which occur rather frequently. Another advantage is that  
there is no need for complex literals; just have 1j return an  
imaginary literal and use addition to construct complex values.



I tried to follow Ratio's example as closely as I could, though there
is some trickiness things about implementing lt ... there really isn't
an accepted definition for saying one complex number is greater than
another.


I'd even say that it is accepted that there is no such definition:  
complex numbers have no order relation. You certainly shouldn't try to  
implement java.lang.Comparable.



I'm a bit new to Git/GitHub and to Clojure, but if you're curious I
think I correctly created a fork of the master branch with my changes.


Could you give the link to your fork?


How would I go about submitting a ticket to add the Complex type and
to create a patch to submit my proposed changes?


1) Join the clojure-dev list and discuss your proposal there.
2) Send a contributor agreement to Rich.
3) Join the clojure group on assembla.com
4) Follow the instructions at http://clojure.org/contributing to  
prepare a patch.


But please start with 1), that's the most important step!

Konrad.

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

2010-06-02 Thread Konrad Hinsen

On 2 Jun 2010, at 02:38, Daniel wrote:


This touches upon another subject though: Clojure lacks a good math
library (though Liebke might kill me for that).


Incanter is great but it's not a math library in the sense of what you  
propose. I'd say you have a chance to survive :-)


Has anybody thought about a wrapper for Apfloat as a starting  
point?  Anybody with any

experience, good or bad, using that?


Thought about, yes, but no more than that. I don't have any experience  
with Apfloat either. But I'd happily join a Clojure maths interest  
group to work on such problems!


Konrad.

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


apply with constructors

2010-06-02 Thread Mark Rathwell
I apologize for my ignorance, I've been struggling with this one for a
couple hours and can't figure it out.  Why does apply not work with
constructors, special forms, etc.?  Is there some other standard way to
unpack a list?  My question is outlined below, I have a variable length list
of parameters that I want to send to the matching constructor:

;; parameter list, can also be of length 3 or 4
user= (def params '(example.com 5222))
(def params '(example.com 5222))
#'user/params

;; thought this would work
user= (apply ConnectionConfiguration. params)
(apply ConnectionConfiguration. params)
java.lang.ClassNotFoundException: ConnectionConfiguration.
(NO_SOURCE_FILE:66)

;; thought this would work also
user= (apply new ConnectionConfiguration params)
(apply new ConnectionConfiguration params)
java.lang.Exception: Unable to resolve symbol: new in this context
(NO_SOURCE_FILE:68)

;; can do it with eval, but what is the correct way?
user= (eval `(ConnectionConfiguration. ~...@params))
(eval `(ConnectionConfiguration. ~...@params))
#ConnectionConfiguration
org.jivesoftware.smack.connectionconfigurat...@a0430b6

Any input is appreciated.

Thanks.

 - Mark

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-06-02 Thread sergey-miryanov
Feka, do you select a text on page and press button in toolbar?

On Jun 1, 8:49 pm, feka tfek...@gmail.com wrote:
 Good idea! Thanks. (And try-clojure is good idea, too. So they also
 merit the thanks.)

 I can't make it grab the selection and evaluate it though. Am I
 missing something? Mac OS X 10.6.3, Chromium (Revision 48615)

 Feka

 On May 31, 12:04 pm, sergey-miryanov sergey.mirya...@gmail.com
 wrote:



  Hi all,

   I made a little extension for google chrome. It allows to start try-
  clojure REPL via clicking on toolbar button. Also it grabs selected
  text and evaluates it in REPL.

  Feel free to comment, report bugs and suggestions.

  /Sergey

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

2010-06-02 Thread Konrad Hinsen
On 02.06.2010, at 02:51, Mark Rathwell wrote:

 I apologize for my ignorance, I've been struggling with this one for a couple 
 hours and can't figure it out.  Why does apply not work with constructors, 
 special forms, etc.?  Is there some other standard way to unpack a list?  My 
 question is outlined below, I have a variable length list of parameters that 
 I want to send to the matching constructor:

Constructors calls translate directly to Java constructor calls, meaning that 
the number of arguments must be known at compile time.

Assuming your constructor takes a fixed number of arguments, the easiest 
solution to your problem is to wrap the constructor in a function:

(apply (fn [p1 p2] (new Connection.Configuration p1 p2)) params)

If your class has multiple constructors with different arity, there are ways to 
look up the right constructor using reflection, but I have forgotten the 
details already.

Konrad.

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

2010-06-02 Thread Meikel Brandmeyer
Hi,

On Jun 2, 2:51 am, Mark Rathwell mark.rathw...@gmail.com wrote:

 ;; can do it with eval, but what is the correct way?
 user= (eval `(ConnectionConfiguration. ~...@params))
 (eval `(ConnectionConfiguration. ~...@params))
 #ConnectionConfiguration
 org.jivesoftware.smack.connectionconfigurat...@a0430b6

The best way is to use reflection.

Calls to a constructor are hard-wired in the JVM bytecode, AFAIU. So
you have to know the arguments. If you *don't* know the arguments at
compile time, you have to lookup and call the correct constructor at
runtime via reflection.

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


Re: Android 'dex' stage takes a very long time with Clojure

2010-06-02 Thread MHOOO
No, I have yet to set up a public repo. I'll see to it that I at least
set one up for the modified clojure-master project sometime today or
tomorrow. As for a hello-world project, I'm currently running into
some issues with android's call stack limit: (use 'swank.swank) kinda
uses too much of that. I've possibly solved the problem by running
clojure entirely in its own thread, however for some reason I get
exceptions about *compile-path* not being set upon initialization, so
I've tried to fix the problem by manually specifying it - but that
results in strange errors which I have yet to resolve.

On Jun 2, 1:30 am, Matt Clark matt.clar...@gmail.com wrote:
 Do you have a public repository of the work you've done so far? I'm
 very interested to learn more about this.

 On May 29, 7:31 pm, MHOOO thomas.karol...@googlemail.com wrote:

  Well, that was easy enough. I modified the load function inside
  RT.java to load classes/namespaces out of .dex files. (use
  'my.compiled.namespace) will now look for either the compiled .class
  (and load it), or it will look for a .clj (and compile  load it -
  thanks to George Jahad's work), or it will look for a .dex file
  (my.compiled.namespace.dex) inside the .apk and try to load the
  class from there.
  Charming!
  I've already split clojure-master into several parts (.dex files for
  core,main,zip,set,walk,xml,java,inspector,pprint,repl), so now the
  next step would be to figure out how to get it all together and
  integrate it with leiningen: Build clojure-master .dex files (- done)
  with a custom main (- todo) which calls the users main android
  activity (- todo), package everything into an apk (- done) and
  install it on the emulator (- done).

  On May 29, 4:07 pm, MHOOO thomas.karol...@googlemail.com wrote:

   I'd like to try to compile the clojure code (i.e. its different parts
   like .core, .main, .set, etc) into different .dex files so as to speed
   up both compilation (since you'll only have to recompile those .dex
   files which have changed) and start-up (since only those .dex files
   are loaded which are needed during program runtime). However I'm not
   quite sure where to hook into as I have only little understanding of
   how clojure loads files. Is there a function somewhere in the java/
   clojure side of the code which is responsible for finding a namespace
   (possibly compiling it first) and loading it?



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


Re: clojure.contrib.repl-utils show

2010-06-02 Thread looselytyped
Hello!

I figured it out. For the record, it was me being stupid about it. The
problem was doing a (use 'clojure.contrib.repl-utils) would barf
because 'source' is declared in both clojure.repl and
clojure.contrib.repl-utils (This has probably to do with what Sean
said - some repl functions are being promoted to core).

I needed to do a (use '[clojure.contrib.repl-utils :only (show)]) -
this way the name collision would be avoided. (I am not sure why emacs
tab-autocomplete would not show repl-utils as an option, but it may
have to do with the collision).

The lab-repl script loads the 'show' function this way. That's why it
worked with lab-repl but not with a 'lein swank' since with lein I
have to explicitly 'use' any contrib libraries.

I am sorry for the confusion. Please forgive me.

Warm regards,

Raju

On Jun 1, 5:14 pm, looselytyped raju.gan...@gmail.com wrote:
 Hi Sean,

 Yes, it certainly looks like it's being pulled into clojure core.
 Thank you for the response.

 If I may say so - I think your series on vimeo is awesome. Thank you
 for taking the time and making the effort.

 Kind regards,

 Raju

 On Jun 1, 11:13 am, Sean Devlin francoisdev...@gmail.com wrote:

  Keep in mind thatREPL-utils is being discussed for inclusion in core
  in 1.2.  Therefore, any edge build will have to pay extra attention to
  what is going on.  This will be easier to track when frozen betas 
  RC's come out.

  Sean

  On Jun 1, 10:52 am, looselytyped raju.gan...@gmail.com wrote:

   Hi Meikel,

   Thank you for the response. I did not do that, but a quick glance at
   the clojure.contribgithub repo tells me there is no 'show' function
   in it. I will try it at home (it's on my home computer).

   It's odd because it was working just fine - then I did a 'lein clean'
   and 'lein deps' and it was then I could not refer to 'show'.

   Kind regards,
   Raju

   On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote:

Hi,

On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote:

 For some reason, the 'show' function from clojure.contrib.repl-utils
 does not work. In fact the only completions I get when trying to get
 torepl-* are

 clojure.contrib.repl-ln
 clojure.contrib.repl_ln

Did you (require 'clojure.contrib.repl-ln)? Maybe
labrepl does that for you.

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


Re: clojure.contrib.repl-utils show

2010-06-02 Thread looselytyped
Hello!

I figured it out. For the record, it was me being stupid about it. The
problem was doing a (use 'clojure.contrib.repl-utils) would barf
because 'source' is declared in both clojure.repl and
clojure.contrib.repl-utils (This has probably to do with what Sean
said - some repl functions are being promoted to core).

I needed to do a (use '[clojure.contrib.repl-utils :only (show)]) -
this way the name collision would be avoided. (I am not sure why emacs
tab-autocomplete would not show repl-utils as an option, but it may
have to do with the collision).

The lab-repl script loads the 'show' function this way. That's why it
worked with lab-repl but not with a 'lein swank' since with lein I
have to explicitly 'use' any contrib libraries.

I am sorry for the confusion. Please forgive me.

Warm regards,

Raju

On Jun 1, 5:14 pm, looselytyped raju.gan...@gmail.com wrote:
 Hi Sean,

 Yes, it certainly looks like it's being pulled into clojure core.
 Thank you for the response.

 If I may say so - I think your series on vimeo is awesome. Thank you
 for taking the time and making the effort.

 Kind regards,

 Raju

 On Jun 1, 11:13 am, Sean Devlin francoisdev...@gmail.com wrote:

  Keep in mind thatREPL-utils is being discussed for inclusion in core
  in 1.2.  Therefore, any edge build will have to pay extra attention to
  what is going on.  This will be easier to track when frozen betas 
  RC's come out.

  Sean

  On Jun 1, 10:52 am, looselytyped raju.gan...@gmail.com wrote:

   Hi Meikel,

   Thank you for the response. I did not do that, but a quick glance at
   the clojure.contribgithub repo tells me there is no 'show' function
   in it. I will try it at home (it's on my home computer).

   It's odd because it was working just fine - then I did a 'lein clean'
   and 'lein deps' and it was then I could not refer to 'show'.

   Kind regards,
   Raju

   On Jun 1, 1:28 am, Meikel Brandmeyer m...@kotka.de wrote:

Hi,

On Jun 1, 4:16 am, looselytyped raju.gan...@gmail.com wrote:

 For some reason, the 'show' function from clojure.contrib.repl-utils
 does not work. In fact the only completions I get when trying to get
 torepl-* are

 clojure.contrib.repl-ln
 clojure.contrib.repl_ln

Did you (require 'clojure.contrib.repl-ln)? Maybe
labrepl does that for you.

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


Re: review the clojure.string code

2010-06-02 Thread Tom Hickey
Including a space is correct when changing a string to upper
case (hence Java's toUpperCase), though no space would be fine there
as well.

As a verb, uppercase (no space) is correct. So the function should
either match java and be called to-upper-case or (preferably, IMO)
simply be uppercase.

Tom

On May 30, 11:23 pm, Stuart Halloway stuart.hallo...@gmail.com
wrote:
 But they can be separate words, and Java treats them so (.toUpperCase, 
 .toLowerCase).

 Stu



  Also, according to Merriam-Webster, uppercase and lowercase don't have
  hyphens in them.

  RJ

  On May 30, 3:49 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
  I have been working on a branch [1] and haven't updated the ticket yet 
  [2]. Given the number of diverse (and sometimes opposite!) opinions 
  already expressed on this topic, I thought a little extra community review 
  would be in order. David and I organized the work into several fairly 
  small commits so you can grab the branch and see  the individual decisions 
  being made.

  Thanks!
  Stu

  [1]http://github.com/stuarthalloway/clojure/tree/string
  [2]https://www.assembla.com/spaces/clojure/tickets/359-promote-contrib-s...

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

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


Re: review the clojure.string code

2010-06-02 Thread ataggart
+1 on uppercase / lowercase

On Jun 2, 8:49 am, Tom Hickey thic...@gmail.com wrote:
 Including a space is correct when changing a string to upper
 case (hence Java's toUpperCase), though no space would be fine there
 as well.

 As a verb, uppercase (no space) is correct. So the function should
 either match java and be called to-upper-case or (preferably, IMO)
 simply be uppercase.

 Tom

 On May 30, 11:23 pm, Stuart Halloway stuart.hallo...@gmail.com
 wrote:



  But they can be separate words, and Java treats them so (.toUpperCase, 
  .toLowerCase).

  Stu

   Also, according to Merriam-Webster, uppercase and lowercase don't have
   hyphens in them.

   RJ

   On May 30, 3:49 pm, Stuart Halloway stuart.hallo...@gmail.com wrote:
   I have been working on a branch [1] and haven't updated the ticket yet 
   [2]. Given the number of diverse (and sometimes opposite!) opinions 
   already expressed on this topic, I thought a little extra community 
   review would be in order. David and I organized the work into several 
   fairly small commits so you can grab the branch and see  the individual 
   decisions being made.

   Thanks!
   Stu

   [1]http://github.com/stuarthalloway/clojure/tree/string
   [2]https://www.assembla.com/spaces/clojure/tickets/359-promote-contrib-s...

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

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


The State of Clojure, Summer 2010

2010-06-02 Thread Chas Emerick
I have now been using Clojure as my primary programming language for  
almost exactly two years. Clojure 1.2 is nearing release. The Clojure  
community is larger than it ever has been, and shows no sign of  
slackening its growth.
It seems like now would be a good time to take stock of where the  
community is, how people came to use Clojure, and how it's being used  
in the world. To do that, I put together a quick, 9-question survey  
through Google Spreadsheets, embedded below.


Hopefully enough responses will come through that we'll be able to get  
a good picture of the current state of affairs, and maybe a little  
insight into where Clojure can and should make headway in the future.


The survey is available here: http://muckandbrass.com/web/x/AQBf

Of course, after people have had enough time to participate, all of  
the data will be opened up for everyone to see.


Cheers,

- Chas

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


Re: Emacs - Problem with running tests (yes I installed with ELPA)

2010-06-02 Thread Karsten Lang
I don't suppose

(add-hook 'slime-connected-hook 'slime-redirect-inferior-output)

would work?

On Tue, Jun 1, 2010 at 11:00 PM, Paul Hobbs paul_ho...@hmc.edu wrote:
 I have a similar issue whenever I try to print anything from slime.
 --
 Paul Hobbs


 On Mon, May 31, 2010 at 11:41 PM, Steve Molitor stevemoli...@gmail.com
 wrote:

 When I run clojure-test-run-tests I can't see the intermediate test
 output.  Messages like the following flash by as the tests run:

    error in process filter: Elisp destructure-case failed: (:write-
 string Testing my-stuff))

 I do see the final message: Ran 3 test. 0 failures, 0 errors.  If
 there are failures or errors the offending lines are correctly
 highlighted in the source, but I can't see the error/failure message
 (these would have flashed by very quickly with the 'error in process
 filter' messages).

 I think it's a problem with slime evaluation.  Clojure-test-mode calls
 slime-eval-async when the problem occurs.  I can cause the same issue
 when I manually run slime-interactive-eval (C-c C-e) with the
 expression (clojure.test/run-tests).  The tests run but error in
 process filter: Elisp destructure-case failed messages fly by.

 I am using the test-is library.  I'm using GNU Emacs 23.1.90.1 with
 clojure packages that I installed today via ELPA.  (I installed
 clojure-test-mode, and its dependencies included clojure-mode, slime,
 etc.)

 Thanks,

 Steve

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from 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: Having trouble getting full performance from a quad-core with trivial code

2010-06-02 Thread Zak Wilson
ka, I ran some more tests, including partition-work and your version
of fac. I also ran some code from http://shootout.alioth.debian.org in
both C and Java.

On these 10-element sequences, partition-work seems to be a few tens
of milliseconds slower than partition-all. It does look generally
useful though; I'll run some more tests with it.

Your version of fac doesn't change the performance characteristics on
the Mac much: two cores are almost twice as fast as one, but three or
four result in single-digit percentage gains. My fac was 8% faster on
four cores instead of two. Yours was 1% faster. I also tried with a 12-
element sequence to try to ensure that all the cores had the same
amount of work. In that situation, four and two were even closer.

I ran the Java versions of the Mandelbrot and spectral norm benchmarks
from the above-linked site, as those appeared to keep all the cores
busy. Java versions of both run nearly twice as fast on the Mac Pro as
my dual-core laptop, which is in line with expected results on a
trivially parallel problem (the laptop is slightly faster per-core).

The problem here seems to be Clojure-specific. There's some sort of
overhead here that keeps the CPUs busy (top reports 390%), but very
little extra desirable work is actually getting done. If this is
indeed a Clojure problem, I'm happy to try to help track it down. I'm
not very familiar with the profiling and monitoring tools for the JVM,
so a pointer in the right direction there would be appreciated.

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

2010-06-02 Thread Mike Meyer
On Wed, 2 Jun 2010 13:33:30 +0200
Konrad Hinsen konrad.hin...@fastmail.net wrote:

 Constructors calls translate directly to Java constructor calls, meaning that 
 the number of arguments must be known at compile time.
 
 Assuming your constructor takes a fixed number of arguments, the easiest 
 solution to your problem is to wrap the constructor in a function:
 
   (apply (fn [p1 p2] (new Connection.Configuration p1 p2)) params)
 
 If your class has multiple constructors with different arity, there are ways 
 to look up the right constructor using reflection, but I have forgotten the 
 details already.

Can you let the fn call figure that out for you? Like so:

(apply (fn ([p1 p2] (new Connection.Configuration p1 p2))
   ([p1 p2 p3] (new Connection.Configuration p1 p2 p3)))
   params)

I realize that reflection is probably better in this case, but was
wondering if this would work.

  mike
-- 
Mike Meyer m...@mired.org 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: apply with constructors

2010-06-02 Thread Konrad Hinsen

On 2 Jun 2010, at 21:10, Mike Meyer wrote:

If your class has multiple constructors with different arity, there  
are ways to look up the right constructor using reflection, but I  
have forgotten the details already.


Can you let the fn call figure that out for you? Like so:

   (apply (fn ([p1 p2] (new Connection.Configuration p1 p2))
   ([p1 p2 p3] (new Connection.Configuration p1 p2 p3)))
   params)

I realize that reflection is probably better in this case, but was
wondering if this would work.


I think it should, though I didn't try. Obviously you would make that  
function by a macro, so it's in fact a viable alternative to reflection.


Konrad.

--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: let's all link to the getting started pages!

2010-06-02 Thread mmwaikar
Hi,

Sorry for posting to an old thread, but thought this might be a good
one to ask.

My question is this - isn't ClojureBox an Emacs? If yes, then why
don't we include it in the above Wiki?

Thanks,
Manoj.

On Apr 7, 3:39 pm, Avi Schwartz the1...@gmail.com wrote:
 On March 30th Eric Thorsen released version 1.1 of the Enclojure plugin for
 NetBeans and posted to the enclojure group the following information. You
 may want to update the information about Enclojure and NetBeans:

 Requirements:
 Netbeans 6.8

 To use the new release:
 1. If you already have Enclojure installed, go to the 
 Tools-Plugins-Installed and click on Show Details.  Find the Clojure 
 plugin and

 Uninstall it.
 This should be the last time you'll need to do this now that the
 update site is in place.

 2. Setup the autoupdate for Enclojure
 There is an autoupdate URL that you can use that will keep you up to
 date with releases from now on.  You'll need to set this up 1x by
 going into the Tools-Plugins-Settings and click Add.
 Call the Update Center Enclojure and use the following 
 URL:http://www.enclojure.org/file/view/Autoupdate_Site.xml.gz

 3. Install the plugin
 Again, in the Tools-Plugins dialog:
 Go to Available Plugins and select the Enclojure Clojure Plugin
 and click install.
 This will download the plugin and take you through the install
 process.

 From now on, the releases will be done via the update center.

 Thanks,
 Avi

 On Tue, Apr 6, 2010 at 10:55 AM, Stuart Halloway
 stuart.hallo...@gmail.comwrote:

  People getting started with Clojure have struggled to find an up-to-date
  source for information on getting their editor of choice up and running.
  This is unfortunate, since there is good support in a bunch of different
  editors.

  The Getting Started page on Assembla (
 http://www.assembla.com/wiki/show/clojure/Getting_Started) should
  ameliorate this problem. A bunch of people have contributed or tested
  instructions for Netbeans/Enclojure, Eclipse/Counterclockwise, IDEA/La
  Clojure, Emacs, Vim, and Leiningen.

  Now we just need to make this page more google-findable. If you have a
  blog/twitter/whatever-the-kids-use-these-days, please link out to the
  Assembla page, especially if you written up your own getting started
  instructions.

  Also, if you think the instructions suck please let me know how to make
  them better.

  Big thanks to everyone who wrote or tested the setup instructions, and to
  the unsung heroes who implemented the editor support modes.

  Thanks,
  Stu

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

  To unsubscribe, reply using remove me as the subject.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: : Google Chrome extension for TryClojure (try-clojure.org)

2010-06-02 Thread Heinz N. Gies
On Jun 1, 2010, at 22:26 , Sina K. Heshmati wrote:

 Heinz N. Gies he...@licenser.net said:
 
 The DNS is fixed, try-clojure.org is now working too :)
 
 Not anymore! I was actually using it. I missed C-a C-k though.
You make me cry :P thanks for the hint this time it was my evil doing ;) fixed 
now! and I promise I don't touch it any more!

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

2010-06-02 Thread Mark Rathwell
Ah, makes sense now, thank you.  I know the parameter list will be one of
three possibilities, so probably makes more sense to specify the conditions
than to use reflection.  I don't have a repl handy, but either of the below
should work:

;; using apply (per Konrad)
(cond
  (= (count params) 2)
  (apply (fn [p1 p2] (new ConnectionConfiguration p1 p2)) params)
  (= (count params) 3)
  (apply (fn [p1 p2 p3] (new ConnectionConfiguration p1 p2 p3)) params)
  (= (count params) 4)
  (apply (fn [p1 p2 p3 p4] (new ConnectionConfiguration p1 p2 p3 p4))
params))

;; without apply
(cond
  (= (count params) 2)
  (ConnectionConfiguration. (nth params 0) (nth params 1))
  (= (count params) 3)
  (ConnectionConfiguration. (nth params 0) (nth params 1) (nth params 2))
  (= (count params) 4)
  (ConnectionConfiguration. (nth params 0) (nth params 1) (nth params 2)
(nth params 3)))

Thanks again.

 - Mark

On Wed, Jun 2, 2010 at 7:34 AM, Meikel Brandmeyer m...@kotka.de wrote:

 Hi,

 On Jun 2, 2:51 am, Mark Rathwell mark.rathw...@gmail.com wrote:

  ;; can do it with eval, but what is the correct way?
  user= (eval `(ConnectionConfiguration. ~...@params))
  (eval `(ConnectionConfiguration. ~...@params))
  #ConnectionConfiguration
  org.jivesoftware.smack.connectionconfigurat...@a0430b6

 The best way is to use reflection.

 Calls to a constructor are hard-wired in the JVM bytecode, AFAIU. So
 you have to know the arguments. If you *don't* know the arguments at
 compile time, you have to lookup and call the correct constructor at
 runtime via reflection.

 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


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

Re: Clojure Eclipse Getting Started Question

2010-06-02 Thread Shikhar Mishra
Thanks Matt, that did the trick.

On Tue, May 25, 2010 at 2:16 PM, Matthias von Rohr 
matthias.vonr...@gmail.com wrote:

 set the cursor somewhere in your (defn...) expression then press Ctrl
 + Alt + x (evaluate in REPL). After that you method call should work.

 Matt

 On May 24, 5:08 pm, Shikhar shikh...@gmail.com wrote:
  Hi,
   I've just installed the Counterclockwise plugin and written a hello
  world program in a file named hello.clj
  Code
  ---
  (ns hello)
  (defn a method method [args] (println Hello args))
  
  /Code
 
  When I run the above file as Clojure REPL via eclipse
 
  Console
  
  Clojure 1.1.0
  1:1 user= #Namespace hello
  1:2 hello= (method World)
  java.lang.Exception: Unable to resolve symbol: method in this context
  (repl-1:2)
  1:3 hello=
  -
  /Console
 
  Any thoughts on what I could be doing wrong? Thanks.
 
  Shikhar
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group athttp://
 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.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
-shikhar

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from 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: Emacs - Problem with running tests (yes I installed with ELPA)

2010-06-02 Thread Steve Molitor
The version of slime I am using (20100404) doesn't define any
slime-redirect-inferior-output function.  Perhaps it has been renamed?

Steve

On Wed, Jun 2, 2010 at 1:06 PM, Karsten Lang karstenl...@gmail.com wrote:

 I don't suppose

 (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)

 would work?

 On Tue, Jun 1, 2010 at 11:00 PM, Paul Hobbs paul_ho...@hmc.edu wrote:
  I have a similar issue whenever I try to print anything from slime.
  --
  Paul Hobbs
 
 
  On Mon, May 31, 2010 at 11:41 PM, Steve Molitor stevemoli...@gmail.com
  wrote:
 
  When I run clojure-test-run-tests I can't see the intermediate test
  output.  Messages like the following flash by as the tests run:
 
 error in process filter: Elisp destructure-case failed: (:write-
  string Testing my-stuff))
 
  I do see the final message: Ran 3 test. 0 failures, 0 errors.  If
  there are failures or errors the offending lines are correctly
  highlighted in the source, but I can't see the error/failure message
  (these would have flashed by very quickly with the 'error in process
  filter' messages).
 
  I think it's a problem with slime evaluation.  Clojure-test-mode calls
  slime-eval-async when the problem occurs.  I can cause the same issue
  when I manually run slime-interactive-eval (C-c C-e) with the
  expression (clojure.test/run-tests).  The tests run but error in
  process filter: Elisp destructure-case failed messages fly by.
 
  I am using the test-is library.  I'm using GNU Emacs 23.1.90.1 with
  clojure packages that I installed today via ELPA.  (I installed
  clojure-test-mode, and its dependencies included clojure-mode, slime,
  etc.)
 
  Thanks,
 
  Steve
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en

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


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

Re: let's all link to the getting started pages!

2010-06-02 Thread Craig Andera
Someone wrote an installer [1] that I've used successfully.

[1] http://github.com/paulbatum/clojure-clr/downloads

On Wed, Apr 7, 2010 at 4:37 PM, Sean Devlin francoisdev...@gmail.com wrote:
 Anyone have instructions for CLR?

 On Apr 7, 2:50 pm, Meikel Brandmeyer m...@kotka.de wrote:
 Hi,

 On Wed, Apr 07, 2010 at 01:53:47PM -0400, Wilson MacGyver wrote:
  I noticed there is no section or link on using clojure with gradle. What
  can I do to help make that happen?

 Will add it.

 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

 To unsubscribe, reply using remove me as the subject.


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

2010-06-02 Thread Stuart Halloway
For the cases currently implemented, the perf difference is negligible. I don't 
think there is anything wrong with a helper protocol, but I also don't think 
the cond-based approach is a problem, unless there are real use cases for 
making these open.

Pondering whether this should be a protocol was *certainly* worth doing: 
replace and replace-first were asymmetric in their arg handling, and the 
difference was a bug. I have updated the patch. Thanks!

Stu

 In perusing the patch for ticket #359 (promoting string), I came
 across the following fn:
 
 http://gist.github.com/422392
 
 I was wondering why there is a cond that dispatches on the instance?
 predicate, instead of a helper protocol being used.  Is a helper
 protocol bad style?  Is cond faster?  Is it important that this be
 closed?  Did I simply read the patch wrong?
 
 Thanks,
 Sean
 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from 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: apply with constructors

2010-06-02 Thread rzeze...@gmail.com

 Can you let the fn call figure that out for you? Like so:

     (apply (fn ([p1 p2] (new Connection.Configuration p1 p2))
                ([p1 p2 p3] (new Connection.Configuration p1 p2 p3)))
            params)

 I realize that reflection is probably better in this case, but was
 wondering if this would work.


Seems it would.

user (apply (fn ([ch] (String. ch))
 ([ch off len] (String. ch off len))) [(char-array [\r
\y \a \n])])
ryan
user (apply (fn ([ch] (String. ch))
 ([ch off len] (String. ch off len))) [(char-array [\r
\y \a \n]) 0 2])
ry

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

2010-06-02 Thread rzeze...@gmail.com
I was able to make this go away by adding a method to Numbers.java.  I
have a use case where I'm calling bit-and with two longs tens of
millions of times.  Is there another way I could avoid this reflection
without this change to the Java source?


diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/
Numbers.java
index 2aaabee..051 100644
--- a/src/jvm/clojure/lang/Numbers.java
+++ b/src/jvm/clojure/lang/Numbers.java
@@ -1880,6 +1880,10 @@ static public int and(int x, int y){
return x  y;
 }

+static public long and(long x, long y){
+   return x  y;
+}
+
 static public int or(int x, int y){
return x | y;
 }

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