Re: Try + finally question

2010-04-29 Thread ka
Hi ppl, Above I wrote a macro with-open-flexi! ... which I'm planning to use in my app's API . .. please let me know if there are any bugs / gotchas / improvements etc... I didn't get any responses, so does it means there is something so obviously wrong that you can't even begin where to start :)

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread ataggart
I know it won't matter, but for posterity if nothing else... Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be tha

Re: Try + finally question

2010-04-29 Thread Alex Osborne
ka writes: > Above I wrote a macro with-open-flexi! ... which I'm planning to use > in my app's API . .. please let me know if there are any bugs / > gotchas / improvements etc... > > I didn't get any responses, so does it means there is something so > obviously wrong that you can't even begin wh

Re: Try + finally question

2010-04-29 Thread Laurent PETIT
Maybe juste the name ? wouldn't with-open-close be a better reminder of how the bindings are constructed ? 2010/4/29 Alex Osborne : > ka writes: > >> Above I wrote a macro with-open-flexi! ... which I'm planning to use >> in my app's API . .. please let me know if there are any bugs / >> gotchas

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Rich Hickey
On Apr 29, 2010, at 1:57 AM, Meikel Brandmeyer wrote: 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 ab

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Mark J. Reed
I like this proposal. I'd make contains? an alias for contains-key? with a deprecation warning, and just forget about seq-contains? in favor of contains-val? On Thursday, April 29, 2010, ataggart wrote: > I know it won't matter, but for posterity if nothing else... > > Functions named contains-k

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Laurent PETIT
2010/4/29 Mark J. Reed : > I like this proposal.  I'd make contains? an alias for contains-key? > with a deprecation warning, and just forget about seq-contains? in > favor of contains-val? This makes a lot of sense to me. (and have, as suggested by ataggart, contains-key? complain if passed a seq

seq-contains? in practice

2010-04-29 Thread Stuart Halloway
"In theory, there is no difference between theory and practice. In practice, there is." -Yogi Berra (maybe). The recent thread on the new seq functions spun off into a theoretical discussion about whether about the merits of having contains? and seq- contains? as separate functions. I would

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Stuart Halloway
Thinking about this one. I like this proposal. I'd make contains? an alias for contains-key? with a deprecation warning, and just forget about seq-contains? in favor of contains-val? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: seq-contains? in practice

2010-04-29 Thread Meikel Brandmeyer
Hi, did you also check some? I would use (some #{item} coll) or (some #(= % item) coll) from core instead of sucking in 3.5Mb contrib for includes?. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

confusing error from rand-int

2010-04-29 Thread Lee Spector
I'm getting an error from clojure-1.1.0 (with Java 1.6.0_16 under linux) that really has me scratching my head. Probably something obvious but I'm baffled and would love it if someone could point out what's going on. The error that I get is: Caused by: java.lang.IllegalArgumentException: n mus

Re: seq-contains? in practice

2010-04-29 Thread Stuart Halloway
Good point, and no. There are several (but not dozens) of calls to some. It appears that all of them are places where search is known to be O(n) on small data, and (most importantly!) *none* of them include an instance check to see if there is an associative collection available. Stu Hi

Re: confusing error from rand-int

2010-04-29 Thread Timothy Pratley
Hi Lee, On 29 April 2010 22:31, Lee Spector wrote: > The error that I get is: > > Caused by: java.lang.IllegalArgumentException: n must be positive >at java.util.Random.nextInt(Random.java:250) > Hopefully this will give you the clue you need: user=> (. thread-local-random-generator (ne

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Douglas Philips
On 2010 Apr 29, at 2:17 AM, Mark Engelberg wrote: 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

Re: beginer jedit problem

2010-04-29 Thread Chris Perkins
On Apr 29, 2:05 am, Marko Srepfler wrote: > Same error > C:\clojure>java -cp jline-0.9.91.jar;clojure.jar jline.ConsoleRunner > clojure.main > Exception in thread "main" java.lang.ClassNotFoundException: > clojure.main Does it work without jline? eg: just "java -cp clojure.jar clojure.main". I'

Re: Annotations

2010-04-29 Thread Timothy Pratley
On 24 April 2010 10:06, Rich Hickey wrote: > I've started adding some support for Java annotations, > Feedback welcome Neato! I've been hoping for this - thanks :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Douglas Philips
On 2010 Apr 29, at 4:21 AM, ataggart wrote: Functions named contains-key? and contains-val? would make a lot more sense to me than the current contains? and new seq-contains?. Anyone looking at contains-val? should expect it to be O(n). The only effective difference would be that the test value

Re: seq-contains? in practice

2010-04-29 Thread Antony Blakey
While I have no position on seq-contains?, I question this methodology, which I've seen a few times now. It's early days for Clojure, you're sampling a very small codebase, and there may be as yet unforseen idiomatic uses (such as you point out for testing) which invalidates this argument. In ad

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Douglas Philips
On 2010 Apr 29, at 7:52 AM, Laurent PETIT wrote: 2010/4/29 Mark J. Reed : I like this proposal. I'd make contains? an alias for contains-key? with a deprecation warning, and just forget about seq-contains? in favor of contains-val? This makes a lot of sense to me. (and have, as suggested by a

Re: Naming factory functions

2010-04-29 Thread Timothy Pratley
On 23 April 2010 12:21, joshua-choi wrote: > When it comes to naming factory functions—functions that create things— > clojure.core gives four precedents: > > 1. Name it exactly what the new object is called. vector, hash-map, > set. > 2. Name it a shortened version of #1. vec. > 3. Prefix #1 wit

Re: beginer jedit problem

2010-04-29 Thread Marko Srepfler
java -cp clojure.jar clojure.main works nice on windows 7 On Apr 29, 3:03 pm, Chris Perkins wrote: > On Apr 29, 2:05 am, Marko Srepfler wrote: > > > Same error > > C:\clojure>java -cp jline-0.9.91.jar;clojure.jar jline.ConsoleRunner > > clojure.main > > Exception in thread "main" java.lang.Cla

Re: confusing error from rand-int

2010-04-29 Thread Lee Spector
Beautiful! That is definitely it. I produce many many very big bignums in this application. Thanks so much! -Lee PS I noticed after I sent this that the subject line was wrong -- the error wasn't from rand-int, it was from my avoiding rand-int. Clojure's rand-int does the right thing. On A

Re: seq-contains? in practice

2010-04-29 Thread Douglas Philips
On 2010 Apr 29, at 8:27 AM, Meikel Brandmeyer wrote: did you also check some? I would use (some #{item} coll) or (some #(= % item) coll) from core instead of sucking in 3.5Mb contrib for includes?. Odd, isn't it, that there is a special function zero? when everyone could just use #(= 0 %) May

Re: seq-contains? in practice

2010-04-29 Thread Stuart Halloway
Agreed: Rich's explanation is the more important bit. My point is that we may be wasting time arguing about something that nobody actually does. If idiomatic usage changes as the community grows, we *could* add a collection-generic contains. While I have no position on seq-contains?, I ques

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Mark Hamstra
On Apr 29, 2:17 am, Mark Engelberg wrote: > 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, th

Re: seq-contains? in practice

2010-04-29 Thread Mike K
On Apr 29, 5:10 am, Stuart Halloway wrote: > (There are a few calls to seq-contains? in the test suite for contrib,   > and I wrote all of them. If you write lots of unit tests you already   > know why such calls make sense there.) For those of us who are newbies, would you mind being more expli

Re: seq-contains? in practice

2010-04-29 Thread Laurent PETIT
The final proposition in the other thread to rename contains? into contains-key? and seq-contains? into contains-val? seems good, no ? Don't you think they are better names ? (contains-key? indicates more clearly that the coll is viewed as an associative thing ; contains-val? implies it will work w

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Sean Devlin
(send contains-val? inc) On Apr 29, 9:06 am, Douglas Philips wrote: > On 2010 Apr 29, at 4:21 AM, ataggart wrote: > > > Functions named contains-key? and contains-val? would make a lot more > > sense to me than the current contains? and new seq-contains?.  Anyone > > looking at contains-val? shou

Re: Defining a namespace inside a let

2010-04-29 Thread alux
Hello, interesting. Is this a bug?? Somehow the println seems to do strange things here. If I evaluate in namespace user (do (ns ns-1) (def my-namespace *ns*) my-namespace) The REPL switches to the namespace ns-1 and the var my-namespace is in ns-1 If I evaluate in namespace user (print

Re: seq-contains? in practice

2010-04-29 Thread Meikel Brandmeyer
Hi, On 29 Apr., 15:34, Douglas Philips wrote: > > did you also check some? I would use (some #{item} coll) > > or (some #(= % item) coll) from core instead of sucking in > > 3.5Mb contrib for includes?. > > Isn't your real beef/bug-report here that you won't use a meaning/ > intention conveying

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Michael Gardner
On Apr 29, 2010, at 3:21 AM, ataggart wrote: > I know it won't matter, but for posterity if nothing else... > > Functions named contains-key? and contains-val? would make a lot more > sense to me than the current contains? and new seq-contains?. Anyone > looking at contains-val? should expect it

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread MarkSwanson
On Apr 29, 4:21 am, ataggart wrote: > I know it won't matter, but for posterity if nothing else... > > Functions named contains-key? and contains-val? would make a lot more > sense to me than the current contains? and new seq-contains?.  Anyone > looking at contains-val? should expect it to be O

Re: seq-contains? in practice

2010-04-29 Thread MarkSwanson
On Apr 29, 9:57 am, Stuart Halloway wrote: > Agreed: Rich's explanation is the more important bit. > > My point is that we may be wasting time arguing about something that   > nobody actually does. If idiomatic usage changes as the community   > grows, we *could* add a collection-generic contain

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

2010-04-29 Thread Gregg Williams
Alex, thanks for your two posts and for taking the time to look at the original source code. Some comments: Re: Integer being final. Actually, I remembered that...and then forgot. Tired? Clueless? You decide. I'm going to fold your observations into a new test program to see what happens; thanks.

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

2010-04-29 Thread Meikel Brandmeyer
Hi, On Thu, Apr 29, 2010 at 12:09:06PM -0700, Gregg Williams wrote: > Re: subclassing: Unless I'm missing something, I still want to > subclass PCanvas because the class adds another method, updateEdge, > which gets called within the drag event handler. Maybe you can make it a normal clojure fun

Re: Naming factory functions

2010-04-29 Thread ataggart
I think names such as vector and hash-map are ok precisely because they are such fundamental types, and bindings typically use one-char names; brevity matters. (And vec is just a special case of vector) I'm not sure if there's some deeper nuance in the naming between the make-* and create-* funct

Re: Defining a namespace inside a let

2010-04-29 Thread Armando Blancas
> The REPL switches to the namespace ns-1 and the var my-namespace is in > user ! I don't see that with CLJ 1.2 on Windows: user=> (do (ns ns-1) (def my-namespace *ns*) my-namespace) # ns-1=> (ns user) nil user=> (println (do (ns ns-1) (def my-namespace *ns*) my-namespace)) # nil ns-1=> (var my-n

Agents, eval, quasi-quote & closures

2010-04-29 Thread Sean Devlin
I'm having a lot of trouble getting an app to work. I'm using agents in a GUI app. For the sake of discussion I've got the following things defined: (def test-coll [{:a 1 :b 2 :c 3} {:a 4 :b 5 :c 6} {:a 7 :b 8 :c 9} {:a 10 :b 11 :c 12} ]) (def test-query (agent '[test-coll

Re: ClojureCLR start-up time

2010-04-29 Thread Joerthan Panest
On Apr 28, 10:06 pm, dmiller wrote: > Startup times have crept up slowly with some of the recent changes in > the compiler.   I have a plan to simplify the loading process.  I've > been avoiding making too many ancillary changes in the compiler while > I've been porting all the compiler changes th

Re: Agents, eval, quasi-quote & closures

2010-04-29 Thread Laurent PETIT
Hello Sean, You want (def test-query (agent `[test-coll (take 2)])) to fully qualify test-coll (and also take, btw) because when passed to eval on the agent's thread, who knows to which value *ns* will be bound ? (tested on my machine) HTH, -- Laurent 2010/4/29 Sean Devlin : > I'm havi

Re: seq-contains? in practice

2010-04-29 Thread Heinz N. Gies
On Apr 29, 2010, at 15:10 , Stuart Halloway wrote: > "In theory, there is no difference between theory and practice. In practice, > there is." -Yogi Berra (maybe). ... > Also, AFAICT, there are *no* examples of using instance checks to select the > right containment function. So the theoretical

Re: Agents, eval, quasi-quote & closures

2010-04-29 Thread Sean Devlin
Right... Is there a way to force an agent thread to be evaluated in a certain namespace? You see, the current design accepts a string, and uses read-string to parse it. i.e. I call a form like this a lot (send test-query conj (read-string (get-input))) Sean On Apr 29, 4:40 pm, Laurent PETIT wr

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Boris Mizhen - 迷阵
> +1. I can't imagine any use case for looking up a whole [key, value] pair in > a hash-map. Actually this is quite useful when you want to do something for each value and need to know the key as well - for example copy some key/value pairs to another map Boris > > -- > You received this message

Re: clojure 1.2 seq fn enhancement FAQ

2010-04-29 Thread Mark J. Reed
Iterating through the pairs is useful. Asking if a given [k, v] is included is not - you can just ask if (= (assoc k) v) instead. It'd be nice if (contains-val) returned the key(s) as its true result, but probably not useful enough to warrant the complexity of dealing with false keys, explicit tr

Re: seq-contains? in practice

2010-04-29 Thread Stefan Kamphausen
Hi, On 29 Apr., 14:10, Stuart Halloway wrote: > "In theory, you may be right about 'contains?.' In practice, Rich   > Hickey is right." - Stu Halloway. :-) probably a little off-topic, but to me the most irritating thing about contains? is, that it just returns nil (RT/F, that is) for lists. Th

what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
Clojure 1.2.0-master-SNAPSHOT user=> (use `clojure.contrib.string) java.lang.IllegalStateException: repeat already refers to: #'clojure.core/repeat in namespace: user (NO_SOURCE_FILE:0) By going through the source, I see c.c.s deliberately exclude certain symbols but don't know how to do it in th

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread ataggart
user=> (defn repeat [x] x) java.lang.Exception: Name conflict, can't def repeat because namespace: user refers to:#'clojure.core/repeat (NO_SOURCE_FILE:1) user=> (ns my.ns (:refer-clojure :exclude [repeat])) nil my.ns=> (defn repeat [x] x) #'my.ns/repeat On Apr 29, 6:08 pm, gary ng wrote: > Cloj

Does clojure.contrib.io.slurp work with binary files?

2010-04-29 Thread Matt Culbreth
Howdy, I'm writing a very simple network server that needs to send a mix of text and binary (usually image) data over a network stream. I'm using slurp to read data from a file and send it to a stream, but sometimes that's failing. I've got a theory that it has to do with slurp not reading binar

Re: Does clojure.contrib.io.slurp work with binary files?

2010-04-29 Thread Mike Mazur
Hi, On Fri, Apr 30, 2010 at 10:30, Matt Culbreth wrote: > I'm using slurp to read data from a file and send it to a stream, but > sometimes that's failing.  I've got a theory that it has to do with > slurp not reading binary data correctly.  Is that true?  Do I need to > go down to the lower leve

Re: Does clojure.contrib.io.slurp work with binary files?

2010-04-29 Thread Alex Osborne
Hi Matt, Matt Culbreth writes: > I'm using slurp to read data from a file and send it to a stream, but > sometimes that's failing. I've got a theory that it has to do with > slurp not reading binary data correctly. Is that true? Do I need to > go down to the lower level Java classes and build

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
On Thu, Apr 29, 2010 at 7:24 PM, ataggart wrote: > user=> (defn repeat [x] x) > java.lang.Exception: Name conflict, can't def repeat because > namespace: user refers to:#'clojure.core/repeat (NO_SOURCE_FILE:1) > user=> (ns my.ns (:refer-clojure :exclude [repeat])) > nil > my.ns=> (defn repeat [x]

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread Meikel Brandmeyer
Hi, On Thu, Apr 29, 2010 at 08:32:12PM -0700, gary ng wrote: > thanks. Though I found this behavior a bit annoying. What seems to be > happening is that I need to exclude all the symbols that is excluded by > c.c.string again if I use 'use ...' why would 'repeat' all of a sudden > appear again if

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
On Thu, Apr 29, 2010 at 9:11 PM, Meikel Brandmeyer wrote: > > c.c.string is not designed to be used like that. Use require plus an > alias: (require '[clojure.contrib.string :as s]). Then repeat is the > core repeat and s/repeat is the string repeat. > > What would be the use case of 'use' then ?

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread David Nolen
On Fri, Apr 30, 2010 at 1:32 AM, gary ng wrote: > > > On Thu, Apr 29, 2010 at 9:11 PM, Meikel Brandmeyer wrote: > >> >> c.c.string is not designed to be used like that. Use require plus an >> alias: (require '[clojure.contrib.string :as s]). Then repeat is the >> core repeat and s/repeat is the

labrepl: kl...@feersum:~/projects/labrepl$ script/repl java.lang.ExceptionInInitializerError (control.clj:9)

2010-04-29 Thread klang
leiningen reinstalled with self-install labrepl cloned and lein deps run without any hickups laprepl starts up with the following error and localhost:8080 does not respond kl...@feersum:~/projects/labrepl$ script/repl Clojure 1.2.0-master-SNAPSHOT java.lang.ExceptionInInitializerError (control.c

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread ataggart
On Apr 29, 10:43 pm, David Nolen wrote: > My rule of thumb is: > > use + :only > require + :as (inc *1) -- 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

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

2010-04-29 Thread Gregg Williams
Have you ever wanted to abandon a simple program with a bug that has been DRIVING YOU CRAZY because it's just got to be something SO simple, you'd be embarrassed to admit that you didn't see WHAT WAS STARING YOU IN THE FACE all along? Well, this is mine: (ns org.InfoML.genclassObject (:gen-class

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

2010-04-29 Thread Antony Blakey
On 30/04/2010, at 3:46 PM, Gregg Williams wrote: > Have you ever wanted to abandon a simple program with a bug that has > been DRIVING YOU CRAZY because it's just got to be something SO > simple, you'd be embarrassed to admit that you didn't see WHAT WAS > STARING YOU IN THE FACE all along? Well,