Re: Beginner's question regarding implementing a constructor using gen-class

2010-04-28 Thread Alex Osborne
Hi Gregg, Gregg Williams writes: > (ns genclassInteger > (:gen-class >:extends [java.lang.Integer]) > ;(:import (java.lang Integer)) ; < unnecessary, right? > ) > - > > This returns the error: > > Exception in thread "main" java.lang.ClassNotFoundException: > [java/lang/

Re: Beginner's question regarding implementing a constructor using gen-class

2010-04-28 Thread Alex Osborne
Gregg Williams writes: > Now I'm working on > the "Graph Editor" program described at > http://www.piccolo2d.org/learn/grapheditor.html > . > > In this sample program (which you don't really need to look at) I need > to subclass a Piccolo2D class to create a class named GraphEditor , > but unlik

beginer jedit problem

2010-04-28 Thread Marko Srepfler
Windows 7 jre 1.6 command mode error on getting started jline C:\clojure-1.1.0>dir Volume in drive C has no label. Volume Serial Number is 303A-A5FF Directory of C:\clojure-1.1.0 28.04.2010. 10:43 . 28.04.2010. 10:43 .. 28.04.2010. 10:2877 .gitign

Re: Insert into an indexed seq

2010-04-28 Thread James Reeves
On Apr 27, 7:45 pm, Sean Devlin wrote: > However, there are still problems > that require me to use an expensive operation. Could you give an example of such a problem? There may be another way of solving it you have not considered. - James -- You received this message because you are subscrib

Re: deftype and final classes

2010-04-28 Thread Jarkko Oranen
On Apr 28, 5:00 am, Richard Newman wrote: > Opinions, thoughts, critiques, "you're insane"s, etc. welcome. The patches look fine to me and the change is well justified since you have a real use case. I don't think restricting deftype to final classes would serve any real purpose. I'd just go a

Re: deftype and final classes

2010-04-28 Thread Rich Hickey
On Apr 27, 10:00 pm, Richard Newman wrote: > Further to IRC conversations: > > I'm attempting to generate a JAX-WS service using Clojure. The main   > stumbling block was annotations; that's been removed, so I gave it a   > shot using deftype. > > My first strike works code-wise, so I sent it to

Re: Insert into an indexed seq

2010-04-28 Thread Rich Hickey
On Apr 27, 2010, at 2:45 PM, Sean Devlin wrote: You're right, inserting into a vector is fundamentally slow. Inserting into a list (must traverse elements) or String (Char Array) isn't any better. I get why Clojure doesn't include certain operations on certain data structures (e.g. assoc on a

Can't figure out how to use binding

2010-04-28 Thread SpiderPig
Hi, I wrote this code to redirect a repl to a JFrame. I used the JConsole class from Beanshell (def console (bsh.util.JConsole.)) (def frame (doto (javax.swing.JFrame.) (.add console) (.setSize 500 500) (.setVisible true) )) (binding [*out* (java.io.OutputStreamWriter. (.getOut console))]

Testing equality

2010-04-28 Thread WoodHacker
Can someone explain to me why this doesn't work: (let [ p "Bill/" sep (System/getProperty "file.separator") ] (if (= (last p) sep) (println "found separator") (println "no separator") ) The (= (last p) sep) always returns false. If I print

Re: Testing equality

2010-04-28 Thread David Nolen
On Wed, Apr 28, 2010 at 9:30 AM, WoodHacker wrote: > Can someone explain to me why this doesn't work: > > (let [ p "Bill/" > sep (System/getProperty "file.separator") > ] > > (if (= (last p) sep) > (println "found separator") > (println "no separator

Re: Testing equality

2010-04-28 Thread Teemu Antti-Poika
On Apr 28, 4:30 pm, WoodHacker wrote: > Can someone explain to me why this doesn't work: > >   (let [ p     "Bill/" >           sep (System/getProperty "file.separator") >            ] > >       (if (= (last p) sep) >           (println "found separator") >           (println "no separator") >  

Re: Can't figure out how to use binding

2010-04-28 Thread Meikel Brandmeyer
Hi, On 28 Apr., 01:52, SpiderPig wrote: >      (.start (Thread. #(clojure.main/repl bindings are thread-local. So your in/out bindings are not valid in the new thread. Try the following: (.start (Thread. (bound-fn [] (clojure.main/repl))) Sincerely Meikel -- You received this message be

Re: Testing equality

2010-04-28 Thread Adrian Cuthbertson
(last p) returns a char \/ (first p) returns \B) so, use (= (str (last p)) sep) -Rgds, Adrian. On Wed, Apr 28, 2010 at 3:30 PM, WoodHacker wrote: > Can someone explain to me why this doesn't work: > >  (let [ p     "Bill/" >          sep (System/getProperty "file.separator") >           ] > >  

Re: Testing equality

2010-04-28 Thread Mike DeLaurentis
Depending on what you're trying to do with paths, you may want to construct File objects and then get the paths from them. For example, (let [home (File. "/Users/Bill") bashrc (File . home ".bashrc")] (.getPath bashrc)) I think that tends to be less cumbersome than stringing path compo

Re: Questions about program design

2010-04-28 Thread Andrew Brookins
On Tue, Apr 27, 2010 at 10:21 AM, Miki wrote: > Hello Andrew, > >> So, for people like me, can any of you suggest some transcribed >> lectures, screencasts, books, blog posts, or other errata that discuss >> the difference between program design in a language like Clojure and >> an OO language lik

Re: beginer jedit problem

2010-04-28 Thread Chris Perkins
On Apr 28, 4:56 am, Marko Srepfler wrote: > C:\clojure-1.1.0>java -cp jline-0.9.91.jar:clojure.jar You need to separate your classpath entries with a semicolon, not a colon. - Chris Perkins -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Defining a namespace inside a let

2010-04-28 Thread Nate Young
On Apr 26, 5:25 pm, David McNeil wrote: > I am experimenting with clojure.test and I encountered the following > situation which I cannot explain. > > This code: > > (println (do >            (ns ns01 >              (:use clojure.test)) >            (deftest test1 nil) >            (run-tests))) >

Re: Serializable Collections ?

2010-04-28 Thread Jules
Brian, Thanks for getting back to me :-) I look forward to your changes making it into the mainline. I'm going to register with Assembla and watch this ticket. If I find a way to vote for it, I will do. Jules On Apr 27, 3:59 pm, Brian Hurt wrote: > On Tue, Apr 27, 2010 at 9:10 AM, Jules wro

Re: deftype and final classes

2010-04-28 Thread Richard Newman
What are you going to do about: default public constructor? The JAX-WS tools don't really care if javac generates a default constructor or if Clojure does. The deftype constructor with no fields defined is: public com.example.FooBarService(); which -- assuming it calls super() and ini

Reading properties file the proper way

2010-04-28 Thread K.
Hello, What is the best way to read a property file in a path independent way? I would like to be able to read the file and this regardless of where my clojure program is called from (this must also work if my program is bundled as a jar). clojure.contrib.java-utils/read-properties is nice but it

Re: Reading properties file the proper way

2010-04-28 Thread Phil Hagelberg
On Wed, Apr 28, 2010 at 10:01 AM, K. wrote: > I did try with ClassLoader/getSystemResourceAsStream : > > However this breaks with "lein swank" since lein swank uses its own > classloader. The problem with this is that it's using the System classloader. Try using the thread's classloader: (into {

Re: ClojureCLR start-up time

2010-04-28 Thread Joerthan Panest
Defining CLR2 in release on the new2 branch allowed me to compile without issue. I still have the several second delay, and from what little I kind find around I suppose that is typical. Is that correct? Is there any way to bring that down? Thank you, Joerthan On Apr 23, 9:45 pm, dmiller wrote:

seq fns promoted to clojure.core!

2010-04-28 Thread Stuart Halloway
Several clojure.contrib.seq/seq-utils functions have been promoted (with some modification) to clojure.core. Here's the super-terse summary from the code comment: ;; moved to clojure.core: flatten, partition-all, frequencies, ;; reductions, shuffle, partition-by ;;

clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Stuart Halloway
After review, several seq functions from clojure-contrib have been promoted to clojure [1], [2], [3]. Hopefully the FAQ below will answer the major questions you may have: 1. Is this a breaking change to Clojure? No. Rich is super-careful to grow Clojure by expansion, not by breaking change

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 4:31 PM, Stuart Halloway wrote: After review, several seq functions from clojure-contrib have been promoted to clojure [1], [2], [3]. Hopefully the FAQ below will answer the major questions you may have: Cool! 3. Why did some of the fn names change? ...Similarly, includ

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Meikel Brandmeyer
Hi, On Wed, Apr 28, 2010 at 05:06:21PM -0400, Douglas Philips wrote: > Wait, what? Why should seq-contains? be slower than contains? Isn't > this exactly the kind of thing that protocols are supposed to be > solving? Your nice video showed that very thing, right? If you have a map or a set looki

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 5:14 PM, Meikel Brandmeyer wrote: If you have a map or a set looking up a key is fast. So contains? is fast (read O(1) resp. something like O(log32 N)). seq-contains? does a linear search through a sequence. That is O(N). Protocols cannot change this. How is having an optimiz

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Meikel Brandmeyer
Hi, On Wed, Apr 28, 2010 at 05:26:46PM -0400, Douglas Philips wrote: > How is having an optimized version of seq-contains? for sets/maps > any different from what Stuart showed in his video, where reduce can > have a specialization that is faster on some types? A faster reduce is still O(N). If

constructing a lazy sequence from a Java API that returns pages of data

2010-04-28 Thread .Bill Smith
I have a Java API that retrieves "pages" of data from a database: you specify the page number and the page size, it it retrieves row numbers page-number*page_size through (page-number+1)*page_size - 1. I'd like to construct a lazy sequence that gets its data using that Java API. I'm using Clojur

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 5:32 PM, Meikel Brandmeyer wrote: On Wed, Apr 28, 2010 at 05:26:46PM -0400, Douglas Philips wrote: How is having an optimized version of seq-contains? for sets/maps any different from what Stuart showed in his video, where reduce can have a specialization that is faster on so

Re: constructing a lazy sequence from a Java API that returns pages of data

2010-04-28 Thread ataggart
(defn pages ([src size] (pages src 0 size)) ([src start size] (lazy-seq (if-let [page (.getPage src start size)] (cons page (pages src (inc start) size)) On Apr 28, 2:38 pm, ".Bill Smith" wrote: > I have a Java API that retrieves "pages" of data from a database: you > sp

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Meikel Brandmeyer
Hi, On Wed, Apr 28, 2010 at 05:39:37PM -0400, Douglas Philips wrote: > Stuart's comment was to not use seq-contains? on maps or sets. > There is no reason that it cannot be the same speed as contains? if > a set or map is passed in. Ah, ok. I misunderstood what you were saying. But I think it do

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Stuart Halloway
The "seq" in "seq-contains?" says "I want a sequential search." Protocols *could* make this do something different, but that would violate the contract of this function. Another way to put it: If you wrote a protocol to pick a fast implementation based on type, then seq-contains? would be t

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 6:10 PM, Stuart Halloway wrote: The "seq" in "seq-contains?" says "I want a sequential search." Protocols *could* make this do something different, but that would violate the contract of this function. How would having it work faster if passed a set or map violate that?

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Stuart Halloway
Another way to put it: If you wrote a protocol to pick a fast implementation based on type, then seq-contains? would be the fn that the protocol would call if it couldn't find anything faster. There have to be primitive things somewhere... If so, then why isn't there a vector-first and a li

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 6:55 PM, Stuart Halloway wrote: Specializations are available where there is a clear use case, e.g. contains?, peek (instead of last), disj, etc. ... Tying to concrete types is limiting. *Never* having special purpose fns that know about performance characteristics is also

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 6:06 PM, Meikel Brandmeyer wrote: Ah, ok. I misunderstood what you were saying. But I think it doesn't change the argumentation. If seq-contains? was fast on maps and sets, people would abandon contains? because seq-contains? is "always right": works on seqs, fast on maps and

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Mark Engelberg
On Wed, Apr 28, 2010 at 2:39 PM, Douglas Philips wrote: > If some function I call uses seq-contains? (so that it can get all the > wonderful seq-ness abstractness clojure offers) I should have to know that > internal detail and not pass in a map or set? or worse, fail to get an > optimization i

Re: seq fns promoted to clojure.core!

2010-04-28 Thread liebke
Unfortunately, group-by is a commonly used function name, used in both Incanter and swank-clojure. I've renamed Incanter's group-by to group- on, but the naming conflict of clojure.core/group-by and swank- clojure.util/group-by is preventing swank from starting up using either lein swank or the swa

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Stuart Halloway
Wow, and I thought this was a sore subject before, when there was no seq-contains? and its absence was always a Top 5 FAQ. :-) I'll wait for Rich to maybe chime in on seq-contains?. Other than seq- contains? are people liking the new fns? Anybody having issues we didn't anticipate? Stu O

Re: seq fns promoted to clojure.core!

2010-04-28 Thread Phil Hagelberg
On Wed, Apr 28, 2010 at 4:43 PM, liebke wrote: > Unfortunately, group-by is a commonly used function name, used in both > Incanter and swank-clojure. I've renamed Incanter's group-by to group- > on, but the naming conflict of clojure.core/group-by and swank- > clojure.util/group-by is preventing s

Re: seq fns promoted to clojure.core!

2010-04-28 Thread Stuart Halloway
One option is to configure lein to use a specific timestamp instead of snapshot. Then you can back off the edge a little. Stu Unfortunately, group-by is a commonly used function name, used in both Incanter and swank-clojure. I've renamed Incanter's group-by to group- on, but the naming confli

Re: seq fns promoted to clojure.core!

2010-04-28 Thread Phil Hagelberg
On Wed, Apr 28, 2010 at 4:50 PM, Stuart Halloway wrote: > One option is to configure lein to use a specific timestamp instead of > snapshot. Then you can back off the edge a little. Yeah, using Clojure version "1.2.0-master-20100426.160114-46" would allow you to hold off on bringing in the change

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Michael Gardner
On Apr 28, 2010, at 6:38 PM, Mark Engelberg wrote: > 2. Rename contains? to contains-key? and make a function with the new > semantics called contains? Disadvantage - breaks existing code. You could also alias contains? to contains-key?, use seq-contains? (or some other new name) for this new

Re: ClojureCLR start-up time

2010-04-28 Thread dmiller
You're brave being on the new2 branch. It's pretty raw development in there. The current commit is okay, I try to mark the interim ones. Yes, the CLR2 symbol needs to be defined. That flag became necessary when they made some incompatible namespace changes in the DLR to accommodate CLR 2 verus C

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Rich Hickey
On Apr 28, 7:17 pm, Douglas Philips wrote: > On 2010 Apr 28, at 6:55 PM, Stuart Halloway wrote: > > > Specializations are available where there is a clear use case, e.g. > > contains?, peek (instead of last), disj, etc. > ... > > Tying to concrete types is limiting. *Never* having special purpo

Re: constructing a lazy sequence from a Java API that returns pages of data

2010-04-28 Thread .Bill Smith
Thanks Alex. On Apr 28, 4:55 pm, ataggart wrote: > (defn pages >   ([src size] (pages src 0 size)) >   ([src start size] >     (lazy-seq >       (if-let [page (.getPage src start size)] >         (cons page (pages src (inc start) size)) > > On Apr 28, 2:38 pm, ".Bill Smith" wrote: > > > > >

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 7:38 PM, Mark Engelberg wrote: But I think you're not fully appreciating the complexity of the situation. This is not just about performance, but a question of two different possible semantics for "contains?", which is why it can't *only* be addressed with a protocol. ...

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Meikel Brandmeyer
Hi, On 29 Apr., 01:38, Mark Engelberg wrote: > 1.  Don't include seq-contains?  The behavior you want can usually be > achieved by using (some #{item} coll).  Disadvantage - if you're > testing to see if the collection contains nil, that won't work. Not entirely correct. (some #(= % item) coll)

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Douglas Philips
On 2010 Apr 28, at 11:04 PM, Rich Hickey wrote: It is an important aspect of Clojure that, in general, performance guarantees are part of the semantics of functions. In particular, functions are not supported on data structures where they are not performant. Understood. That isn't the poin

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Meikel Brandmeyer
Hi, On 29 Apr., 01:43, Stuart Halloway wrote: > I'll wait for Rich to maybe chime in on seq-contains?. Other than seq- > contains? are people liking the new fns? Anybody having issues we   > didn't anticipate? I was a little bit surprised about map-indexed and keep-indexed. Why specialised func

Re: beginer jedit problem

2010-04-28 Thread Marko Srepfler
Same error I think the problem is that jline extract dll and load, probably Windows 7 security dont allow this, on windows 7 x64 with 64 bit java says error in jline.dll C:\clojure>java -cp jline-0.9.91.jar;clojure.jar jline.ConsoleRunner clojure.mai n Exception in thread "main" java.lang.ClassNot

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-28 Thread Mark Engelberg
On Wed, Apr 28, 2010 at 10:49 PM, Douglas Philips wrote: > What is the purpose, goal, design-rationale of not making seq-contains? fast > on maps or sets? I think Rich's point is that if seq-contains? is sometimes fast and sometimes slow, then it makes it harder to reason about a program that use