On 13.01.2009, at 19:07, cliffc wrote:
> 1- If you think that HotSpot/Java is slower than C++ by any
> interesting amount, I'd love to see the test case. Being the
I have to admit that I haven't done many tests, but for those I did I
found little to no difference, provided the tests have suff
+1 (and a windows .bat file for the unwashed)
I strongly suggest that the script name needs to be retained in
*command-line-args*.
ie: clj myscript.clj 1 2
*command-line-args* should be ("myscript.clj" 1 2)
not (1 2) which is the current behavior of your script with the
current clojure.main
$0 or
Another thing you might want to test is the fairness of the rw-lock in
your RWDict, because even a couple of very active readers can easily
starve out any number of writers when the rw-lock is non-fair. The
reason is simple: readers can interleave but writers cannot, and
writers can only get in wh
Here's my theory.
In your when example, "when" is a macro that is expanded to an "if"
special form. Your other examples, however, wrap your code in a
function call.
Now, functions in Clojure can't really take primitive arguments, so in
spite of your coercion efforts Clojure introduces boxing in
> My question is how the first agent (agent nil) and *agent* used
> later in another nestedsend-offrelated?
Agents execute their function with *agent* bound to themselves, so the
example given chains itself. This is necessary because the function is
only passed in the value of the agent, not the
Thanks for the answers.
I'm very excited about Clojure, it seems to have all the features I
was missing from Java and Ruby.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send
On Jan 16, 9:06 am, Timothy Pratley wrote:
> +1 (and a windows .bat file for the unwashed)
+ 1 too.
> I strongly suggest that the script name needs to be retained in
> *command-line-args*.
> ie: clj myscript.clj 1 2
No, please don't, or it would not be coherent with the way java
handles it.
M
S. Sierra,
Here is a good test case. It would be nice if the Java interop form
worked, without having to be wrapped in an anonymous function.
user=> (use 'clojure.contrib.test-is)
nil
user=> (.startsWith "abc" "a")
true
user=> (is (.startsWith "abc" "a"))
java.lang.Exception: Unable to resolve
I second the vote for _On Lisp_. I have ported the examples to Clojure:
http://blog.thinkrelevance.com/2008/12/12/on-lisp-clojure
Stuart
>> When I found that out, I was surprised. My knowledge of lisp comes
>> from reading, in the past few months:
>> - ANSI Common Lisp
>> - Practical Common Lis
> There are two pools of threads servicing agent actions. The send pool
> is fixed in size and based on the number of available cores. The send-
> off pool is variable in size and grows as needed to accommodate the
> largest number of simultaneous pending send-off calls that your
> program p
On Jan 16, 2009, at 7:31 AM, lpetit wrote:
Maybe for scripts a global var such as *script-name* could be set
automatically ?
I like this. I've also seen several requests for a way to know when
code is running in a script which could be satisfied by this as well.
This would be an easy cha
> goes up by only %15 for 3 threads... I would expect it to go up by %50
Actually I would expect it to go up by %100
t1t2
t1
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this grou
Long, long ago (Tuesday) when Beta 5 of the book shipped, there were
some breakages in the sample code due to changes in clojure-contrib. I
believe everything is now fixed in the github repository
(http://github.com/stuarthalloway/programming-clojure
).
Summary of the issues:
1. clojure.co
On Jan 16, 5:15 am, Christian Vest Hansen
wrote:
> Here's my theory.
>
> In your when example, "when" is a macro that is expanded to an "if"
> special form. Your other examples, however, wrap your code in a
> function call.
>
> Now, functions in Clojure can't really take primitive arguments, so
On a hunch I rearranged such that the agents are not recreated for
each run, but instead are reused from a pre-established set:
http://groups.google.com/group/clojure/web/mt2.2.clj
Strangely (from my understanding of agents) this has a significant
impact on the result!!!
threads: 1
"Elapsed tim
Sorry for the quad-post, but I just noticed:
http://groups.google.com/group/clojure/browse_thread/thread/6ac273446b4a7183
And actually that is what made the big difference in performance (I'd
done a svn update for something unrelated).
So I guess two mysteries solved with one patch!
Boris I sugges
> So I guess two mysteries solved with one patch!
Actually I spoke too soon... the mt2.clj is still giving the
'unexpected' behavior... I am still mystified.
But going to bed now :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
This is probably a silly question, well outside the scope of this
conversation (but maybe not, and I didn't want to start a whole thread on
it).
Is it much much easier to make byte code than assembly code? I mean, I
understand why running on a VM makes sense as far as instantly inheriting
all the
I keep running into the following problem trying to supply agent
validation function. Here is sample code from page 135 (from book
version beta 5)
(use '[clojure.contrib.except :only (throw-if)])
(def counter (agent 0 #(throw-if (not (number? %)) "not a number")))
triggers the following exceptio
Hi Telman,
The signature for agent has changed. Use:
(def counter (agent 0 :validator number?))
I will update the prose in Beta 6.
Stuart
> I keep running into the following problem trying to supply agent
> validation function. Here is sample code from page 135 (from book
> version bet
On Jan 16, 2009, at 15:47, e wrote:
> Is it much much easier to make byte code than assembly code? I
> mean, I understand why running on a VM makes sense as far as
> instantly inheriting all the massive amounts of things out here for
> Java but would it be possible to shoot for someth
Hello, and thanks for all the help with the IntelliJ plugin.
The next feature I want to implement is "references". That is, one
selects a symbol, and then can go to the location where that symbol was
defined (e.g. def, defn, let, etc.). One can also get a list of all the
locations where that
On Jan 16, 9:47 am, e wrote:
> Is it much much easier to make byte code than assembly code?
To some extent, yes. JVM bytecode is certainly simpler than x86
assembly. The big win is that bytecode is platform-neutral, so you
don't have to rewrite your compiler for each architecture. Java's
ju
Thank you very much, Stuart!
I think it's a good idea for me to start reading Clojure source code
and keep track of the changes, as the language changes so quickly...
On Jan 16, 10:02 am, Stuart Halloway
wrote:
> Hi Telman,
>
> The signature for agent has changed. Use:
>
> (def counter
Peter Wolf a écrit :
> Note that I need a 100% reliable solution, if I am going to implement
> automatic refactoring on top of it. No one wants refactoring that
> messes up the code 5% of the time.
>
Even Java refactoring tools messes up the code each time something is
too dynamic (reflecti
Hello, fellow Stuarts, and others,
Fixed now, SVN rev. 377. I've temporarily abandoned the fancier error
reporting I had for functional predicates. I'm going to try to
restore that without breaking anything else. :)
Peace, love, and happy testing,
-Stuart Sierra
On Jan 16, 7:54 am, Stuart Ha
I am working on this GUI tool and want to keep 'global' data
structures in memory. For example, lets say I have a checkbox and
want to be able to keep and access the state of that checkbox at any
time. Right now, I am thinking the easiest thing to do is using a
Java hashmap and change the state
On Jan 16, 11:10 am, BerlinBrown wrote:
> I am working on this GUI tool and want to keep 'global' data
> structures in memory. For example, lets say I have a checkbox and
> want to be able to keep and access the state of that checkbox at any
> time. Right now, I am thinking the easiest thing
On Jan 16, 2009, at 8:37 AM, Stephen C. Gilardi wrote:
I like this. I've also seen several requests for a way to know when
code is running in a script which could be satisfied by this as well.
For clarity, here's what I'm proposing based on recent discussion in
this thread:
[1] When cloj
On Fri, Jan 16, 2009 at 11:27 AM, Stephen C. Gilardi wrote:
>
> [1] When clojure.main runs a script, it will set *command-line-script* to
> the script name as it appears on the command line.
>
> Example:
>
>java -cp clojure.jar clojure.main -i dir-utils.clj list-dir.clj
> :verbose :depth
Hi Berlin,
Probably ref, if the state must be coordinate with other state, or
atom, if it is totally independent. But you might be able to avoid
using mutable state at all. We would need a larger example to tell.
Stuart
> On Jan 16, 11:10 am, BerlinBrown wrote:
>> I am working on this GUI
BerlinBrown a écrit :
>
> On Jan 16, 11:10 am, BerlinBrown wrote:
>
>> I am working on this GUI tool and want to keep 'global' data
>> structures in memory. For example, lets say I have a checkbox and
>> want to be able to keep and access the state of that checkbox at any
>> time. Right now,
On Jan 16, 11:49 am, Christophe Grand wrote:
> BerlinBrown a écrit :
>
> > On Jan 16, 11:10 am, BerlinBrown wrote:
>
> >> I am working on this GUI tool and want to keep 'global' data
> >> structures in memory. For example, lets say I have a checkbox and
> >> want to be able to keep and access
BerlinBrown a écrit :
> Thanks all, this is what I ended up with:
> For noobs like myself, I am using this code to monitor files and
> refresh it when the file gets modified. I used 'ref' and 'agent'.
>
> (def file-monitor-agent (agent false))
> (def file-state (ref {:open-state false}))
> (de
I think I may have found a minor issue with gen-class, but wanted to
confirm with the group that I'm not just doing something stupid...
(gen-class :name mypkg.foo
:prefix ""
:methods [[my-method [Object] Object]])
Results in the following method signature in the .class file
- is not a "Java letter or digit" so it is not allowed in java method names.
http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8
user=> (Character/isJavaIdentifierPart (int \-))
false
user=>
On Fri, Jan 16, 2009 at 9:56 AM, Greg Harman wrote:
>
> I think I may have found a
On Jan 16, 12:47 pm, Christophe Grand wrote:
> BerlinBrown a écrit :
>
> > Thanks all, this is what I ended up with:
> > For noobs like myself, I am using this code to monitor files and
> > refresh it when the file gets modified. I used 'ref' and 'agent'.
>
> > (def file-monitor-agent (agent
On Fri, Jan 16, 2009 at 12:13 PM, BerlinBrown wrote:
>
> On Jan 16, 12:47 pm, Christophe Grand wrote:
>> BerlinBrown a écrit :
>>
>> > Thanks all, this is what I ended up with:
>> > For noobs like myself, I am using this code to monitor files and
>> > refresh it when the file gets modified. I
BerlinBrown a écrit :
>
> On Jan 16, 12:47 pm, Christophe Grand wrote:
>
>> BerlinBrown a écrit :
>>
>>
>>> Thanks all, this is what I ended up with:
>>> For noobs like myself, I am using this code to monitor files and
>>> refresh it when the file gets modified. I used 'ref' and 'agent'
On Jan 16, 9:32 am, Peter Wolf wrote:
> Hello, and thanks for all the help with the IntelliJ plugin.
>
> The next feature I want to implement is "references". That is, one
> selects a symbol, and then can go to the location where that symbol was
> defined (e.g. def, defn, let, etc.). One can
On Jan 16, 11:02 am, Stuart Sierra
wrote:
> Fixed now, SVN rev. 377. I've temporarily abandoned the fancier error
> reporting I had for functional predicates. I'm going to try to
> restore that without breaking anything else. :)
Ok, I figured out how to do it. Now (rev. 380) you get nice erro
Ah, that'll do it. Thanks.
On Jan 16, 1:02 pm, Kevin Downey wrote:
> - is not a "Java letter or digit" so it is not allowed in java method names.
>
> http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.8
>
> user=> (Character/isJavaIdentifierPart (int \-))
> false
> user=>
>
>
>
On Jan 16, 10:32 am, Peter Wolf wrote:
> The next feature I want to implement is "references". That is, one
> selects a symbol, and then can go to the location where that symbol was
> defined (e.g. def, defn, let, etc.).
Try looking at clojure.contrib.repl-utils and its "source" macro.
-Stua
> SVN 1216 - thanks for the report.
Thanks for the quick fix!
-Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe fr
I'm also very interested in this topic.
The only reason to write "and" as a macro is for performance reasons.
It's much more convenient, programming-wise, if and is a function.
Is there anyway to write a macro/function that acts as a function when
necessary (so it can be passed as an argument),
and is also written as a macro to short circuit evaluation:
clojure.core/and
([] [x] [x & rest])
Macro
Evaluates exprs one at a time, from left to right. If a form
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it re
On Fri, Jan 16, 2009 at 12:49 PM, CuppoJava wrote:
>
> I'm also very interested in this topic.
>
> The only reason to write "and" as a macro is for performance reasons.
That's not the only reason. Another reason is to have the option to
avoid evaluating all of the arguments. Functions always eva
As I chew on this, a couple of things don't sit right with me
regarding use cases:
1. IMHO gen-class should fail with an appropriate message/exception
rather than trying to "fix" the signature. This is what the Java
compiler would do if I made the same mistake in Java. More to the
point, an exter
Looks like you are attempting to compile with a 1.4.x JDK. You need
to compile with JDK 1.5 or higher.
-Ryan
On Jan 15, 5:42 pm, Ron Parker wrote:
> I am trying to build Clojure on Fedora 10. When I first run ant, I get
> a message about the compliance level 1.4 not supporting target version
>
On Jan 16, 2009, at 2:46 PM, Greg Harman wrote:
>
> As I chew on this, a couple of things don't sit right with me
> regarding use cases:
>
> 1. IMHO gen-class should fail with an appropriate message/exception
> rather than trying to "fix" the signature. This is what the Java
> compiler would do
> > > (defn maximal-elements [f s]
> > > "Return a seq of elements of s maximizing (f elt)."
> > > (when (seq s)
> > > (loop [max-elts (first s),
> > > max-val (f (first s)),
> > > rest-elts (rest s)]
> > > (if (empty? rest-elts)
> > > max-elts
> > > (
> > 2. If I want the Clojure functions that underlie the methods in the
> > generated class used directly by my Clojure code as well (which I do),
> > then I'm stuck having to either violate standard Clojure/Lisp function
> > naming conventions in favor of Java-friendly naming or I have to write
>
Hello,
While I understand this solution has been long in place for Lips, I
don't think it looks like the ideal solution, e.g. in a world where
the "source code" is still in files, and not managed by the "lisp
image". I'm aware of just smalltalk that does this cleanly (it is even
managing versions
On Fri, Jan 16, 2009 at 12:22 PM, Greg Harman wrote:
>
>> > 2. If I want the Clojure functions that underlie the methods in the
>> > generated class used directly by my Clojure code as well (which I do),
>> > then I'm stuck having to either violate standard Clojure/Lisp function
>> > naming conve
> Is there anyway to write a macro/function that acts as a function when
> necessary (so it can be passed as an argument), but expands into a
> macro (for speed) when deemed possible?
I don't think this is possible without some sort of support for a
macro/function duality in core Clojure. In the
On Fri, Jan 16, 2009 at 3:41 PM, Michael Reid wrote:
>
>> Is there anyway to write a macro/function that acts as a function when
>> necessary (so it can be passed as an argument), but expands into a
>> macro (for speed) when deemed possible?
>
> I don't think this is possible without some sort of
On Jan 16, 2009, at 11:37 AM, Chouser wrote:
It would also be useful for a .clj file to be able to determine if
itself is the main script or if instead it's being loaded some other
way (-i, load-file, require, etc.).
How about this which is not quite the same, but has nice properties of
its
Hi and thanks for all the feedback
How does SLIME handle this case?
user=> (def foo 1)
#'user/foo
user=> (defn bah [] (let [foo 2] foo))
#'user/bah
user=> (bah)
2
If I select the "foo" inside the let, I want the local one
How does the running image figure that out? What does the API to the
L
I have the following structure setup:
In ~/src/foo/bar/alpha.clj :
(ns foo.bar.alpha
(:require (foo.bar beta)))
(println (get-stuff))
In ~/src/foo/bar/beta.clj :
(ns foo.bar.beta)
(defn get-stuff [] "from beta")
When I run this command:
java -cp .:~/src/clojure/clojure.jar clojure.lang.Scri
On Jan 16, 2009, at 5:01 PM, Kevin Albrecht wrote:
In ~/src/foo/bar/alpha.clj :
(ns foo.bar.alpha
(:require (foo.bar beta)))
(println (get-stuff))
The :require clause succeeded in loading foo.bar.beta, but :require
does not bring get-stuff into namespace foo.bar.alpha.
You can solve thi
Stuart Sierra said:
> It's not covered much. You get used to it. Think of it this way -- macros
> only exist during compilation. Functions like "apply" get evaluated at
> run-time. A macro like "and" has no value at run-time, so you can't use it
> as an argument to a function.
I'll tell y
I guess another way would be to just rebind *command-line-script* to
nil on subsequent loads? It doesn't feel like an complete solution but
I believe it covers the use cases discussed so far.
--~--~-~--~~~---~--~~
You received this message because you are subscribe
On Jan 16, 2009, at 7:36 PM, Timothy Pratley wrote:
I guess another way would be to just rebind *command-line-script* to
nil on subsequent loads? It doesn't feel like an complete solution but
I believe it covers the use cases discussed so far.
That could work, but I think this kind of mechani
Has anyone here had success in using Clojure with QT Jambi?
I'm currently experimenting with porting my app from Swing to QT, and
although Jambi might well be the theoretically superior framework, it
seems like Swing is a lot easier to use with Clojure.
The issue I'm currently running into is th
On Jan 16, 5:38 pm, levand wrote:
> Has anyone here had success in using Clojure with QT Jambi?
>
> I'm currently experimenting with porting my app from Swing to QT, and
> although Jambi might well be the theoretically superior framework, it
> seems like Swing is a lot easier to use with Clojure.
This is very useful. Thanks for doing it.
On windows xp find-javadoc-url would not work for local javadocs,
maybe because of window's "c:\xx" syntax. Using (.toURL file) seemed
to fix it. Maybe that will work for the other systems also.
(defn find-javadoc-url
"Searches for a URL for the given
Hi,
is #^ type hint below? I don't see any type at all.
It's from clojure core.
(def
#^{:arglists '([& items])
:doc "Creates a new list containing the items."}
list (. clojure.lang.PersistentList creator))
--~--~-~--~~~---~--~~
You received this message b
Just made sense to me today as well.
#^Class
is short form for saying set the metadata for the symbol being defined (in
this case list) to the map {:tag Class}.
#^ is a reader macro for setting metadata for the compiler. That code is
simple tagging the symbol clojure/list.
(meta #'list)
will g
Question: How do I read non-printing characters in the reader?
When I call (char 3) at the REPL, it gives me \ and then the puts the
ascii 3 to the output (under slime this shows up as \\003).
But there seems to be no reader way to read these non-printing
characters. There are special cases for
69 matches
Mail list logo