Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Mark Engelberg
I'm still trying to get my head around the new features. Seeing more code examples will definitely help. In the meantime, here is some stream-of-consciousness thoughts and questions. Datatypes: I'm a little worried about the strong overlap between reify/proxy, deftype/defstruct, and defclass/ge

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Krukow
On Nov 12, 1:10 pm, Rich Hickey wrote: > An early version of the code for a few important new language > features, datatypes[1] and protocols[2] is now available in the 'new' > branch[3]. Note also that the build system[4] has builds of the new > branch, and that the new branch works with curren

Re: Generalizing -> & ->>

2009-11-12 Thread Laurent PETIT
Oh yes, thanks for refreshing my memory. And indeed it makes sense to place the question mark in the "questioned" side :) 2009/11/13 Wilson MacGyver : > Yes, it's groovy, and it's "?." It's called safe navigation operator > > http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator%28

Re: swap two elements in an arbitrary collection

2009-11-12 Thread Mark Tomko
Let's try this again: (defn swap [coll i j] (if (= i j) coll (let [li (min i j) ui (max i j)] (let [[pre-li post-li] (split-at li coll)] (let [[post-li-pre-ui post-li-post-ui] (split-at (- ui 1 li) (rest post-li))] (concat pre-li

Re: Generalizing -> & ->>

2009-11-12 Thread Wilson MacGyver
Yes, it's groovy, and it's "?." It's called safe navigation operator http://groovy.codehaus.org/Operators#Operators-SafeNavigationOperator%28%3F.%29 On Thu, Nov 12, 2009 at 6:03 PM, Laurent PETIT wrote: > 2009/11/3 Alex Osborne : >> >> Sean Devlin wrote: >>> This is slightly unrealted, but how d

Re: swap two elements in an arbitrary collection

2009-11-12 Thread Mark Tomko
Oh, I posted too soon. My implementation has a bug. On Nov 12, 9:56 pm, Mark Tomko wrote: > I came up with a way to do it, but I'm sure there's a simpler way. > Here's what I have: > > (defn swap [coll i j] >   (let [li (min i j) ui (max i j)] >     (let [[pre-li post-li] (split-at li coll)] >  

swap two elements in an arbitrary collection

2009-11-12 Thread Mark Tomko
I came up with a way to do it, but I'm sure there's a simpler way. Here's what I have: (defn swap [coll i j] (let [li (min i j) ui (max i j)] (let [[pre-li post-li] (split-at li coll)] (let [[post-li-pre-ui post-li-post-ui] (split-at (- ui 1) (rest post-li))] (concat p

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Chouser
On Thu, Nov 12, 2009 at 7:59 PM, Chouser wrote: > On Thu, Nov 12, 2009 at 7:10 AM, Rich Hickey wrote: >> >> If you have the time and inclination, please try them out. Feedback is >> particularly welcome as they are being refined. > > For what it's worth, here are 2-3 finger trees implemented usin

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Chouser
On Thu, Nov 12, 2009 at 7:10 AM, Rich Hickey wrote: > > If you have the time and inclination, please try them out. Feedback is > particularly welcome as they are being refined. For what it's worth, here are 2-3 finger trees implemented using defprotocol and deftype. http://tinyurl.com/yeh5fgg/fi

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Meikel Brandmeyer
Hi, Am 12.11.2009 um 13:10 schrieb Rich Hickey: An early version of the code for a few important new language features, datatypes[1] and protocols[2] is now available in the 'new' branch[3]. Note also that the build system[4] has builds of the new branch, and that the new branch works with curr

There should be better API doc organization

2009-11-12 Thread Michael Jaaka
HI! Current documentation on the clojure.org is not context based. I know that there is a cheat sheet, but there should be also something like this for HTML version, where I just click a function link name and can read doc (and examples - but about it read just below). Current documentation giv

Re: Generalizing -> & ->>

2009-11-12 Thread Laurent PETIT
2009/11/3 Alex Osborne : > > Sean Devlin wrote: >> This is slightly unrealted, but how does one pronounce ->, ->> and the >> like?  Is this documented? > > The doc-strings usually give you a nice hint.  I usually use "thread" > for -> and "thread last" for ->>.  The actual symbols I think of as > "

Re: sorted-set-by fails when given no values

2009-11-12 Thread Timothy Pratley
On Nov 13, 6:42 am, Albert Cardona wrote: > 20:26 < chouser> leafw: sorted-set-by allows for an empty list of initial >                  values, but passes that on to PersistentTreeSet/create as >                  null, but create doesn't check for null it just blindly calls >                  .

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Michael Jaaka
Oh its looks like Google Go (http://golang.org) and Nice Interfaces (http://nice.sourceforge.net/). Good! It sounds better than overrated polyphormism and class hierarchy. Wiadomość napisana przez Rich Hickey w dniu 2009-11-12, o godz. 15:39: > > > On Nov 12, 8:29 am, Sean Devlin wrote: >> Ri

Re: getting emacs etags for Clojure source?

2009-11-12 Thread Phil Hagelberg
On Nov 12, 12:36 pm, Stuart Halloway wrote: > Using slime is moving higher on my todo list every day. > > Right now, I have the tags working across all my clojure projects.   > Will slime give me that if I compile them all into jars (with source)   > and put them on the classpath? Yep. I've got

Relevance Hacker-In-Res wants Clojure coders

2009-11-12 Thread Stuart Halloway
There have been a lot of "write Clojure from home" references on the list lately, so here is the opposite end of the spectrum. Want to come hang out in meatspace with a bunch of Clojurians*, working in several interesting problem domains? http://blog.thinkrelevance.com/2009/11/11/hacker-in-r

Re: getting emacs etags for Clojure source?

2009-11-12 Thread Stuart Halloway
Using slime is moving higher on my todo list every day. Right now, I have the tags working across all my clojure projects. Will slime give me that if I compile them all into jars (with source) and put them on the classpath? Stu > On Nov 9, 6:36 am, Stuart Halloway wrote: >> I have a poor ma

sorted-set-by fails when given no values

2009-11-12 Thread Albert Cardona
Hi all, When creating a sorted set, the function sorted-set-by cannot be called without at least one element, despite the elements being optional. Chouser on irc.freenode.net #clojure suggested this is a bug, because: 20:26 < chouser> leafw: sorted-set-by allows for an empty list of initial

Re: vimclojure indentation problem.

2009-11-12 Thread Meikel Brandmeyer
Hi, On Nov 12, 5:01 pm, MarkSwanson wrote: > > >> See if this makes a difference: > > >> syntax sync fromstart > > I think one of the primary objectives of vimclojure should be to > consistently render correctly - and it can only do that with 'syntax > sync fromstart'. Once upon a time, sync fr

Re: Gensym collisions can be engineered.

2009-11-12 Thread Kevin Tucker
Personally I think preventing unexpected gensym collisions is the more important property, otherwise it's not even worth having, might as well just make your own cryptic names. I don't think you can have both. -- You received this message because you are subscribed to the Google Groups "Clojure

Re: Problem w/ daemon threads

2009-11-12 Thread Sean Devlin
Blargh!!! I've committed a good old-fashioned PEBCAK. I should have been more specific. I executed this in SLIME/OSX and enclojure/XP. The problem was that the output wasn't going to *out* like I'd expect. I tried a different example, and everything is cool. user=>(def my-agent (agent 0)) us

Re: Problem w/ daemon threads

2009-11-12 Thread David Brown
On Thu, Nov 12, 2009 at 07:50:31AM -0800, Sean Devlin wrote: >(defn daemon > "Creates a new daemon thread and sets runnable to f" > [f] > (let [t (Thread. f)] >(do > (.setDaemon t true) > (.start t) > t))) > >And I tried calling > >user=>(daemon #(println "foo")) > >I get the

Re: vimclojure indentation problem.

2009-11-12 Thread MarkSwanson
> >> See if this makes a difference: > >> syntax sync fromstart I think one of the primary objectives of vimclojure should be to consistently render correctly - and it can only do that with 'syntax sync fromstart'. -- You received this message because you are subscribed to the Google Groups "Clo

Problem w/ daemon threads

2009-11-12 Thread Sean Devlin
Hi all, I'm trying to get a periodic daemon thread working. I've read some of the stuff here: http://groups.google.com/group/clojure/browse_thread/thread/4bc06d413fda157f/e953bb0c9286c5a7 With no luck. My code looks like this (defn daemon "Creates a new daemon thread and sets runnable to f"

Re: vimclojure indentation problem.

2009-11-12 Thread Michael Wood
2009/11/12 Meikel Brandmeyer : > Hi, > > On Nov 12, 11:30 am, Michael Wood wrote: > >> See if this makes a difference: >> syntax sync fromstart >> >> (although I've been having trouble making that work from .vimrc or >> similar.  It seems to be ignored and I haven't yet managed to track >> down wh

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Rich Hickey
On Nov 12, 8:29 am, Sean Devlin wrote: > Rich, > Just read the section on reify.  I'm not quite sure what this new > mechanism lets me do.  Could you provide an example of the problem it > solves?  I personally would benefit from seeing the "Old, painful way" > contrasted to the "New, awesome wa

Re: Strange behavior seen when ints have leading zeros

2009-11-12 Thread Ramakrishnan Muthukrishnan
On Thu, Nov 12, 2009 at 6:38 PM, Robert Campbell wrote: > C:\dev\clojure>java -cp clojure.jar clojure.lang.Repl > Clojure 1.1.0-alpha-SNAPSHOT > user=> (def grid1 [01 02 03 04 05 06 07]) > #'user/grid1 > user=> grid1 > [1 2 3 4 5 6 7] > user=> (def grid2 [01 02 03 04 05 06 07 08]) > java.lang.Numb

Re: Strange behavior seen when ints have leading zeros

2009-11-12 Thread Robert Campbell
Oh, that's pretty neat. Thanks! On Thu, Nov 12, 2009 at 2:36 PM, Fogus wrote: >> Why does Clojure hate 8's? :-) > > It doesn't.  By adding a leading zero you're telling Clojure that you > want octal numbers.  There is no number 08 in octal, instead to write > the base-10 number 8 you would use 0

Re: Strange behavior seen when ints have leading zeros

2009-11-12 Thread Fogus
> Why does Clojure hate 8's? :-) It doesn't. By adding a leading zero you're telling Clojure that you want octal numbers. There is no number 08 in octal, instead to write the base-10 number 8 you would use 010 in octal. -m -- You received this message because you are subscribed to the Google

Re: Datatypes and Protocols - early experience program

2009-11-12 Thread Sean Devlin
Rich, Just read the section on reify. I'm not quite sure what this new mechanism lets me do. Could you provide an example of the problem it solves? I personally would benefit from seeing the "Old, painful way" contrasted to the "New, awesome way". This would probably help with the other feature

Strange behavior seen when ints have leading zeros

2009-11-12 Thread Robert Campbell
C:\dev\clojure>java -cp clojure.jar clojure.lang.Repl Clojure 1.1.0-alpha-SNAPSHOT user=> (def grid1 [01 02 03 04 05 06 07]) #'user/grid1 user=> grid1 [1 2 3 4 5 6 7] user=> (def grid2 [01 02 03 04 05 06 07 08]) java.lang.NumberFormatException: Invalid number: 08 java.lang.Exception: Unmatched deli

Datatypes and Protocols - early experience program

2009-11-12 Thread Rich Hickey
An early version of the code for a few important new language features, datatypes[1] and protocols[2] is now available in the 'new' branch[3]. Note also that the build system[4] has builds of the new branch, and that the new branch works with current contrib. If you have the time and inclination,

Re: vimclojure indentation problem.

2009-11-12 Thread Meikel Brandmeyer
Hi, On Nov 12, 11:30 am, Michael Wood wrote: > See if this makes a difference: > syntax sync fromstart > > (although I've been having trouble making that work from .vimrc or > similar.  It seems to be ignored and I haven't yet managed to track > down why or where it's overridden.) It may be set

Re: vimclojure indentation problem.

2009-11-12 Thread Meikel Brandmeyer
Hi, On Nov 12, 9:10 am, David Brown wrote: > Speaking of vimclojure, has anyone else encountered situations where > the vimclojure indent decides that the indentation of top-level > constructs should be two spaces over?  I haven't been able to figure > out a pattern, and sometimes I can even fix

Re: clojure vim shebang

2009-11-12 Thread Meikel Brandmeyer
Hi, On Nov 12, 12:21 am, John Ky wrote: > Does anyone know why if the first character in my *.clj file is '#', then > when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file? Ok. I could reproduce the issue and also found the solution. The culprit is setfiletype in ftdetect/cl

Re: clojure vim shebang

2009-11-12 Thread Meikel Brandmeyer
Hi, Am 12.11.2009 um 00:21 schrieb John Ky: Does anyone know why if the first character in my *.clj file is '#', then when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file? What does ":echo &ft" say? I have the general symptom, that Vim sometimes does not recognise th

Re: vimclojure indentation problem.

2009-11-12 Thread Michael Wood
2009/11/12 Jeff Rose : > Yes, I also have the same issue.  Sometimes if I re-indent the file it > goes away, and other times I re-indent the file and all of a sudden > half of the functions are 2 spaces over.  (2 spaces is my tab width > though, so I'm not sure if it's a tab or always 2 spaces...)

Re: clojure event handling

2009-11-12 Thread Kevin Downey
http://paste.lisp.org/display/87611#2 "infinite seq of swing events" On Thu, Nov 12, 2009 at 1:48 AM, Jeff Rose wrote: > On Nov 12, 1:22 am, nchubrich wrote: >> I'm curious what the best idiomatic way of handling events is (e.g. >> receiving a series of messages and dispatching functions on the

Re: clojure event handling

2009-11-12 Thread Jeff Rose
On Nov 12, 1:22 am, nchubrich wrote: > I'm curious what the best idiomatic way of handling events is (e.g. > receiving a series of messages and dispatching functions on the basis > of the messages).  One could use the 'experimental' add-watch(er) > functions.  But it might also be nice to do somet

Re: vimclojure indentation problem.

2009-11-12 Thread Jeff Rose
Yes, I also have the same issue. Sometimes if I re-indent the file it goes away, and other times I re-indent the file and all of a sudden half of the functions are 2 spaces over. (2 spaces is my tab width though, so I'm not sure if it's a tab or always 2 spaces...) -Jeff On Nov 12, 9:10 am, Dav

vimclojure indentation problem.

2009-11-12 Thread David Brown
Speaking of vimclojure, has anyone else encountered situations where the vimclojure indent decides that the indentation of top-level constructs should be two spaces over? I haven't been able to figure out a pattern, and sometimes I can even fix it by just scrolling up and back. David -- You rec

Re: clojure vim shebang

2009-11-12 Thread David Brown
On Thu, Nov 12, 2009 at 10:21:32AM +1100, John Ky wrote: >Does anyone know why if the first character in my *.clj file is '#', then >when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file? Vim runs the type detectors that examine the file before the ones based on filename. The