Re: What's this?

2009-02-20 Thread Laurent PETIT
Straight to the point of your question : it's an exception StackTrace, :-) Now if you want some more question to be answered, you may well be a little bit more explicit, as Berlin suggested too ! ;-) -- Laurent 2009/2/21 Feng > > Exception java.lang.StackOverflowError: > [1] clojure.lang.Pe

Re: Importing lots of Java classes at once

2009-02-20 Thread Jason Wolfe
I have a horrible hack to do this, which uses even more appalling code than [2] ripped off from a different forum, but which (in my limited experience) seems to work OK. I'll email it to you privately, and to anyone else who wants to use it (just ask). -Jason On Feb 20, 9:33 pm, Brian Carper w

Importing lots of Java classes at once

2009-02-20 Thread Brian Carper
One could argue that wildcard imports in Java (import package.*) are evil, pollute your namespaces, create potential naming conflicts, etc. One would probably be correct. One could also argue that having to manually type a list of dozens of classnames is pretty tedious, especially if all you wan

Re: What's this?

2009-02-20 Thread Berlin Brown
On Feb 20, 11:08 pm, Feng wrote: > Exception java.lang.StackOverflowError: >   [1] clojure.lang.PersistentHashMap$LeafNode.nodeSeq > (PersistentHashMap.java:567), pc = 2 >   [2] clojure.lang.PersistentHashMap$BitmapIndexedNode$Seq.create > (PersistentHashMap.java:503), pc = 21 >   [3] clojure.l

What's this?

2009-02-20 Thread Feng
Exception java.lang.StackOverflowError: [1] clojure.lang.PersistentHashMap$LeafNode.nodeSeq (PersistentHashMap.java:567), pc = 2 [2] clojure.lang.PersistentHashMap$BitmapIndexedNode$Seq.create (PersistentHashMap.java:503), pc = 21 [3] clojure.lang.PersistentHashMap$BitmapIndexedNode.nodeSeq

generic functions update

2009-02-20 Thread mikel
Taking Chouser's suggestion of using a proxy that implements the IDeref interface, and overrides deref to provide access to a closed- over atom, I rewrote generic functions without resorting to gen-class or external Java files. That makes me happy; good suggestion, Chouser. I made a couple of oth

Re: Contributors and community

2009-02-20 Thread Vincent Foley
To me, the most incredible thing about Clojure is that this all happened in about a year! Choosing to be hosted on an established platform, though sometimes criticized by some people, was a very effective way to get people to start writing useful programs quickly with libraries they were used to.

Re: Have "get" calculate "not-found" value only if key does not exist

2009-02-20 Thread Jason Wolfe
That looks about right. I proposed adding this to clojure.contrib as "lazy-get": http://code.google.com/p/clojure-contrib/issues/detail?id=10 along with a corresponding "safe-get" function that errors if the key is not found. -Jason On Feb 20, 4:42 pm, Rowdy Rednose wrote: > What is the eas

Have "get" calculate "not-found" value only if key does not exist

2009-02-20 Thread Rowdy Rednose
What is the easiest way to make clojure's get function evaluate the value for 'not-found' only if the key is not found? Do I have to write a macro like (defmacro my-get [map key not-found] `(if (contains? ~map ~key) (get ~map ~key) ~not-found)) --~--~-~--~~~--

Re: Reading... from a reader

2009-02-20 Thread Phil Hagelberg
"Stephen C. Gilardi" writes: > I see that issue 79 against Clojure requesting this change is still > open. If auto-wrapping of readers is no longer a change you'd like to > see, would you please either withdraw it (if you as the originator > have that capability) or add a comment to it requestin

Re: Reading... from a reader

2009-02-20 Thread Stephen C. Gilardi
On Feb 12, 2009, at 11:00 PM, Phil Hagelberg wrote: Yikes. I hadn't thought of that--I was only using read in cases where I wanted to get a single object from the reader. Taking things off the reader and then pushing them back on seems a little odd to me--isn't there a way to just "peek" at

Re: clojure.core.read-line broken - can we please fix it?

2009-02-20 Thread Rayne
I filed it as an issue a few days ago, until then I wrote my own read- line from the old read-line. On Feb 20, 4:32 pm, "Stephen C. Gilardi" wrote: > On Feb 20, 2009, at 12:58 PM, Perry Trolard wrote: > > > Hope I didn't imply by the above that I was suggesting a name change. > > > I know my pro

Re: Example use of agent with macro

2009-02-20 Thread Berlin Brown
On Feb 20, 10:29 am, Laurent PETIT wrote: > Hello Rich, thanks for answering. > > You may not have followed the following of the thread, where I precised my > mind by saying what I really wanted to do (but did not at first) was using > with-local-vars, since the value to be mutated is confined

Re: clojure.core.read-line broken - can we please fix it?

2009-02-20 Thread Stephen C. Gilardi
On Feb 20, 2009, at 12:58 PM, Perry Trolard wrote: Hope I didn't imply by the above that I was suggesting a name change. I know my proposed version is ugly, but since BufferedReader & LineNumberingPR can't be unified, special-case-ing for the latter strikes me as an acceptable fix. But removin

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
Thanks for explanation, all! Frantisek On 20 Ún, 20:57, Jason Wolfe wrote: > It probably does an "identical?" call on a pair before calling > compare, for efficiency.  In other words, it may "work" on non- > comparable types, but only when passed n instances of the exact same > object: > > user

Re: Contributors and community

2009-02-20 Thread Mibu
For me, Clojure made programming exhilarating again. Thank you, Rich and everyone else for making this happen. On Feb 20, 9:59 pm, Rich Hickey wrote: > There have been many new additions to the contributors list: > > http://clojure.org/contributing > > and many new donations: > > https://sourc

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Rich Hickey
On Feb 20, 2:18 pm, Jason Wolfe wrote: > Hmmm, that is weird ... I would expect the sort to throw an exception, > but it seems to complete happily. (If you try it with a vector > instead of a list, it will error). > Fixed in svn 1298 - thanks for the report. Rich --~--~-~--~~---

Contributors and community

2009-02-20 Thread Rich Hickey
There have been many new additions to the contributors list: http://clojure.org/contributing and many new donations: https://sourceforge.net/project/project_donations.php?group_id=137961 We're now at 1500+ members on the group, and still growing, all while maintaining a friendly, helpful atmos

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Jason Wolfe
It probably does an "identical?" call on a pair before calling compare, for efficiency. In other words, it may "work" on non- comparable types, but only when passed n instances of the exact same object: user> (sorted-set '(1) '(1)) ; Exception user> (let [x '(1)] (sorted-set x x)) #{(1)} This

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
It looks that it is more complicated than that: user=> (sorted-set () ()) #{()} user=> (sorted-set {} {}) #{{}} user=> (sorted-set #{} #{}) #{#{}} Frantisek On 20 Ún, 20:33, Vincent Foley wrote: > I'm pretty sure that sorted-set works only with values that are > instances of a class that implem

Re: Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Vincent Foley
I'm pretty sure that sorted-set works only with values that are instances of a class that implements Comparable. user=> (instance? Comparable []) true user=> (instance? Comparable {}) false user=> (instance? Comparable ()) false user=> On Feb 20, 2:21 pm, Frantisek Sodomka wrote: > sorted-set

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Chouser
On Fri, Feb 20, 2009 at 1:59 PM, Steffen Glückselig wrote: > > I was trying to use Clojure to verify the behavior some method in > Java. > > Namely I wanted to quickly check whether Collections.sort does the > sorting I need. > > So I came up with: > > (let [list '("1" "KB" "K6" "2" "EÜ" "EZ" "ES

Possible bug in sorted-set, question about comparisons

2009-02-20 Thread Frantisek Sodomka
sorted-set works for vectors, but doesn't work for lists, maps and sets: user=> (sorted-set [1 4]) #{[1 4]} user=> (sorted-set [1 4] [1 4]) #{[1 4]} user=> (sorted-set [4 1] [1 4]) #{[1 4] [4 1]} user=> (sorted-set '(1 4)) #{(1 4)} user=> (sorted-set '(1 4) '(1 4)) java.lang.ClassCastException: c

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Jeffrey Straszheim
The Clojure collections are immutable, which is their entire reason for existing. However, there is nothing stopping you from creating a plain old Java collection in Clojure. (let [list (ArrayList. '("Fred" "mary" "sue")] (do (java.util.Collections/sort list) list)) Should work. On Fri

Re: Calling method in Java that mutates passed argument

2009-02-20 Thread Jason Wolfe
Hmmm, that is weird ... I would expect the sort to throw an exception, but it seems to complete happily. (If you try it with a vector instead of a list, it will error). Anyway, the typical way to do this would be to convert your Clojure data structure to a mutable Java type first, then convert i

Calling method in Java that mutates passed argument

2009-02-20 Thread Steffen Glückselig
I was trying to use Clojure to verify the behavior some method in Java. Namely I wanted to quickly check whether Collections.sort does the sorting I need. So I came up with: (let [list '("1" "KB" "K6" "2" "EÜ" "EZ" "ES")] (do (java.util.Collections/sort list) list)) But since Collect

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-20 Thread Kevin Albrecht
That is correct. There is no reason that you need to compile the clj files before running them. Just include the clojure.jar package and everything will work fine. On Feb 20, 6:41 am, Jeffrey Straszheim wrote: > If your CLJ files are in the classpath, and you include clojure.jar, then > your g

Re: Contributing

2009-02-20 Thread Jeffrey Straszheim
I haven't read _The Reasoned Schemer_, but I have read the logic programming sections of SICP and Norvig .. as well as some non-lispy texts. I *suspect* TRS's material is at a similar weight. What I'm trying to do now goes quite a bit beyond those implementations. Plus, they are all use a top-do

Re: Contributing

2009-02-20 Thread jim
There's a logic programming module in the files section. It implements the system found in "The Reasoned Schemer". On Feb 18, 2:59 pm, Jeffrey Straszheim wrote: > Did you cover logic programming?  Any bottom up logic query techniques? > (My motives are probably transparent.) > > On Wed, Feb 18,

Re: General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread Berlin Brown
On Feb 20, 10:35 am, Tom Ayerst wrote: > You probably don't want to be doing this. Your function looks like it could > use a lazy sequency and a filter. > > e.g. (doseq [e (filter odd? [1 2 3 4 5 6 7])] (prn e)) > > You can get a long way with partition, for, filter and reduce; It is a pain >

Re: clojure.core.read-line broken

2009-02-20 Thread Perry Trolard
Hope I didn't imply by the above that I was suggesting a name change. I know my proposed version is ugly, but since BufferedReader & LineNumberingPR can't be unified, special-case-ing for the latter strikes me as an acceptable fix. But removing the type hint so that the function works out of the

Re: Where did nil go?

2009-02-20 Thread Rock
On 20 Feb, 17:10, Jeffrey Straszheim wrote: > There have been some major changes in the last week or so.   > Seehttp://clojure.org/lazyfor a brief overview. > Also:http://blog.n01se.net/?p=39 > > On Fri, Feb 20, 2009 at 10:31 AM, Rock wrote: > > > After watching Rich's video presentations and

Re: Contributing

2009-02-20 Thread Joshua
Based on the time frame, I'll look into doing the items Chouser submitted. If I finish early, I may look into the Hindley Milner optimization. Joshua On Feb 20, 11:51 am, chris wrote: > Would you perhaps consider working on integrating some form of type > inference into clojure to cut down on t

Re: Yet another "how do I make gen-class work?" thread

2009-02-20 Thread Chouser
On Thu, Feb 19, 2009 at 4:51 PM, mikel wrote: > > If I can implement a custom printing function that gets called on > generic functions, that presupposes that I have some way to tell that > an object is a generic function. So, yes, if I solve the problem, then > the problem is solved. :-) Hm, per

Re: Contributing

2009-02-20 Thread chris
Would you perhaps consider working on integrating some form of type inference into clojure to cut down on the number of required type declarations? We know that clojure runs *much* faster when it isn't doing reflection. It would be nice if I could annotate one function and have the annotation au

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread Jeffrey Straszheim
You could also hide the vector inside your list model code, and require modification through an api. This would let you know what updates to send to the Swing object without having to walk the list. On Fri, Feb 20, 2009 at 11:11 AM, Rowdy Rednose wrote: > > Thanks pmf and Jeffrey, > > so I guess

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread Rowdy Rednose
Thanks pmf and Jeffrey, so I guess the idea is to have the TableModel hold on to the (dereferenced) vector and when the agent fires, the model would dereference the ref again and compare that value with the old one. It would then have to do a diff on those 2. That is one of the unelegant ideas I

Re: Where did nil go?

2009-02-20 Thread Jeffrey Straszheim
There have been some major changes in the last week or so. See http://clojure.org/lazy for a brief overview. Also: http://blog.n01se.net/?p=39 On Fri, Feb 20, 2009 at 10:31 AM, Rock wrote: > > After watching Rich's video presentations and reading Stuart's fine > book, I was absolutely convinced

Where did nil go?

2009-02-20 Thread Rock
After watching Rich's video presentations and reading Stuart's fine book, I was absolutely convinced that if you take the *rest* of an empty list, what you've got left is nil. Instead, with the recent svn version of Clojure, I'm getting the empty list (actually sequence of course) again: user=>

Re: Bug with clojure eval: ExceptionInInitializerError

2009-02-20 Thread Jeffrey Chu
As always, thanks for the quick fix! - Jeff On Feb 20, 7:11 am, Rich Hickey wrote: > On Feb 19, 8:18 pm, Jeffrey Chu wrote: > > > > > Hi, > > > Okay, I'm reasonably sure this is a bug with clojure's eval. Here's an > > even more succinct version: > > > (defn lazy-identity [a] > >   (if (seq? a)

Re: General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread Tom Ayerst
You probably don't want to be doing this. Your function looks like it could use a lazy sequency and a filter. e.g. (doseq [e (filter odd? [1 2 3 4 5 6 7])] (prn e)) You can get a long way with partition, for, filter and reduce; It is a pain to get your head around it at first if your are not us

Re: General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread Stuart Sierra
On Feb 20, 10:12 am, BerlinBrown wrote: > This is a general termingology question.  What is this idiom, called > where you pass a function as an argument to another function and then > use that function with in a loop. I think this is sometimes called "inversion of control." -Stuart Sierra --~-

Re: Example use of agent with macro

2009-02-20 Thread Laurent PETIT
Hello Rich, thanks for answering. You may not have followed the following of the thread, where I precised my mind by saying what I really wanted to do (but did not at first) was using with-local-vars, since the value to be mutated is confined in the function, and the macro ensures (via the use of

Re: General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread Matt Revelle
Higher-order functions (HOFs), are functions that use "lower" functions to perform a task. The map and reduce functions are both HOFs. On Feb 20, 2009, at 10:16 AM, Jeffrey Straszheim wrote: > The OO folks call this an "internal iterator" or "visitor". > However, I'd recommend against ad

dependencies + observers + java interop: how to?

2009-02-20 Thread max3000
Hi, I'm new to clojure and lisp in general. I'm trying semi-porting a real world application but at this time I lack patterns to reason about clojure solutions to problems. I thought I'd ask the community about one such problem I’m facing. To give a simple example for the following discussion, s

Re: Example use of agent with macro

2009-02-20 Thread Rich Hickey
On Feb 20, 2009, at 5:33 AM, Christophe Grand wrote: > > Laurent PETIT a écrit : >> If I'm damn sure that the value will be set once from within the same >> thread (here we are in the SWT UI Thread), is there a reason to >> prefer >> atoms ? >> (This is a real question, not a disguised affirma

Re: General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread Jeffrey Straszheim
The OO folks call this an "internal iterator" or "visitor". However, I'd recommend against adopting their point of view. On Fri, Feb 20, 2009 at 10:12 AM, BerlinBrown wrote: > > This is a general termingology question. What is this idiom, called > where you pass a function as an argument to ano

General Question Clojure(Lisp) Idiom, cross cutting? What is the terminology

2009-02-20 Thread BerlinBrown
This is a general termingology question. What is this idiom, called where you pass a function as an argument to another function and then use that function with in a loop. I thought it reminded me of that aspect oriented programming? cross cutting of concerns? For example, I do that a lot, whe

Re: Bug with clojure eval: ExceptionInInitializerError

2009-02-20 Thread Rich Hickey
On Feb 19, 8:18 pm, Jeffrey Chu wrote: > Hi, > > Okay, I'm reasonably sure this is a bug with clojure's eval. Here's an > even more succinct version: > > (defn lazy-identity [a] > (if (seq? a) > (map lazy-identity a) > a)) > > user=> (lazy-identity '(apply + '(1 2 3))) > (apply + (quo

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-20 Thread Jeffrey Straszheim
If your CLJ files are in the classpath, and you include clojure.jar, then your good. On Fri, Feb 20, 2009 at 9:30 AM, rob wrote: > > What do you mean when you say there is no need to compile your program > to distribute it? Doesn't that require end users to set up a clojure > environment? And

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-20 Thread rob
The tip on compilation is really useful. Thanks! On Feb 16, 11:08 am, levand wrote: > If you have a Clojure namespace that uses gen-class, and if there is a > method called '-main' within that namespace, then the resultant > *.class file is equivalent to a Java class with a 'main' method, and

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-20 Thread rob
It's true, responding to clicks should not necessarily require mutation, but probably anything beyond that GUI-wise would require it. So I guess it's a minor quibble that one or two of the basic aspects are not as elegant as they could be (thanks to Java). But I'll file this under "worse is bett

Re: compiling a GUI app and also: interference of Java's built-in architechture

2009-02-20 Thread rob
What do you mean when you say there is no need to compile your program to distribute it? Doesn't that require end users to set up a clojure environment? And how would you deploy a web-based application without compiling it? On Feb 19, 6:51 pm, Kevin Albrecht wrote: > I can vouch for using SWT

Re: doc suggestion for future function

2009-02-20 Thread Jeffrey Straszheim
As far as I can tell, futures are *not* agents, but wrap the java.util.concurrent.Future class. However, they do run in the same thread pool that the agents use, so your point still stands. On Fri, Feb 20, 2009 at 9:09 AM, Mark Volkmann wrote: > > The doc string for the future function should p

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread Jeffrey Straszheim
It would be pretty easy to wrap an agent (as pmf suggests) to notify your model class if a Vector changes. You could then do something like (map = old_vec new_vec) And then look for false results in the array and send a notification to Swing. On Fri, Feb 20, 2009 at 5:40 AM, Rowdy Rednose wrote

doc suggestion for future function

2009-02-20 Thread Mark Volkmann
The doc string for the future function should probably mention that it uses an Agent so shutdown-agents should be called at the end of applications that use it. -- R. Mark Volkmann Object Computing, Inc. --~--~-~--~~~---~--~~ You received this message because you

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread pmf
Ok,here's a small example that propagates changes to a ref's vector to a watcher: ;; define your model (def model (ref ["abc" "def" "ghi"])) ;; define a watcher (def model-watcher (agent nil)) ;; connect your model to the watcher (add-watcher model :send model-watcher (fn [state source] (printl

Re: clojure and embedded derby

2009-02-20 Thread BrianS
One last question about clojure and derby: once I store a character large object type (CLOB), does anyone know of a best-practices way of converting it back into string from a resultset-seq for use in clojure processing? Thanks in advance for any help in this area. Brian --~--~-~--~~

Re: Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread pmf
On Feb 20, 11:40 am, Rowdy Rednose wrote: > Any elegant ideas or examples on how to do this when the underlying > data structure is (a ref to) one of clojure's (immutable) collections, > so that a change to that structure will fire the appropriate event? You can use add-watcher to notify state c

Re: My SLIME installation diary

2009-02-20 Thread Boris Schmid
Nice. It starts to work flawless. Did another installation test on a fresh ubuntu. 1. mark emacs-snapshot and ant for installation in synaptic. You'll automatically download the other files you need then. 2. get clojure-mode from http://github.com/technomancy/clojure-mode/ , and store the .el fil

Re: Example use of agent with macro

2009-02-20 Thread Laurent PETIT
2009/2/20 Christophe Grand > > Laurent PETIT a écrit : > > If I'm damn sure that the value will be set once from within the same > > thread (here we are in the SWT UI Thread), is there a reason to prefer > > atoms ? > > (This is a real question, not a disguised affirmation that I'm doing > > the

Anyone tried to create a dynamic TableModel (or ListModel)?

2009-02-20 Thread Rowdy Rednose
All the clojure swing examples I've seen so far use JTables in a static way, i.e. the data is not programmatically modified once the table got created. Has anyone actually tried to implement a TableModel that is backed by a clojure Vector/Map and fires events to TableModelListeners when the under

Re: Example use of agent with macro

2009-02-20 Thread Christophe Grand
Laurent PETIT a écrit : > If I'm damn sure that the value will be set once from within the same > thread (here we are in the SWT UI Thread), is there a reason to prefer > atoms ? > (This is a real question, not a disguised affirmation that I'm doing > the right thing, so please arguments welcom

Re: Example use of agent with macro

2009-02-20 Thread Laurent PETIT
Well, I had not particularly optimization concerns in mind. I was just more thinking about what could be the right thing to do. I feel that atoms are useful to allow atomic operations on a value from several threads. If I'm damn sure that the value will be set once from within the same thread (here

Re: Example use of agent with macro

2009-02-20 Thread Christophe Grand
Laurent PETIT a écrit : > I haven't tried with something simpler that the array-like method, I > suspect it won't work in clojure, too. And I didn't want to use > clojure's mutable methods because : > - we already are in an IO operation, the mutation is local to the > operation > - I don't want