Re: clojure vim shebang
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 vimclojure name-based autodetector uses 'setfiletype' which only sets the filetype if it hasn't been detected already. The simplest fix is to change the 'setfiletype' in the ftdetect/clojure.vim file to 'filetype'. This tells it to force the filetype to clojure when it ends in '.clj' no matter what it was detected as. You can also make line 2 of the file be something like: ; vim: set filetype=clojure : and just override it on an individual basis. David -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
vimclojure indentation problem.
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 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
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, David Brown cloj...@davidb.org 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 it by just scrolling up and back. David -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure event handling
http://paste.lisp.org/display/87611#2 infinite seq of swing events On Thu, Nov 12, 2009 at 1:48 AM, Jeff Rose ros...@gmail.com wrote: On Nov 12, 1:22 am, nchubrich nicholas.chubr...@gmail.com 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 something stream-oriented, e.g. a doseq on a stream of events. But the trouble is this dies as soon as the events stop arriving. Can event seqs be 'kept alive' somehow (preferably without blocking)? This seems like a pretty basic capability, so I figured it was worth provoking discussion about. Nick. I think the typical way to handle this currently is by using a typical handler function that is called whenever an event is fired. If the events will be long running then you can use agents or a thread pool (executor framework). If you need to dispatch events to other handlers then use multi-methods. It seems that what you are really asking for though, is a way to treat a stream of events as a sequence. This is what they recently introduced in .net land, with the RX framework: http://www.leading-edge-dev.de/?p=501 Given that clojure has a nice library of sequence manipulation and predicate functions, I think doing something similar could be useful. I don't have a clear sense for how it would work though. You could form a pipeline of sequence processing functions that get called whenever a new event is fired, maybe by using a promise that gets fulfilled when the event hits the pipeline? -Jeff -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: clojure vim shebang
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 the filetype correctly for self-defined types. Please consider to ask these questions on the vimclojure group. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: clojure vim shebang
Hi, On Nov 12, 12:21 am, John Ky newho...@gmail.com 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/clojure.vim. As a quick fix change the following line there: au BufNewFile,BufRead *.clj setfiletype clojure into au BufNewFile,BufRead *.clj set filetype=clojure I will also patch this for the next release. Thanks for the report. Sincerely Meikel -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
Hi, On Nov 12, 9:10 am, David Brown cloj...@davidb.org 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 it by just scrolling up and back. I encountered this also from time to time. (Actually, I can reproduce it with certain files.) But unfortunately, I haven't found out, yet, what the reason is. You might want to try: :syn syn fromstart to see if this helps. But this is only a guess. The indenting relies on the highlighting, which only syncs back a certain amount. So if scrolling helps, maybe the highlighting was fixed (re-syncronised), which then in turn also fixes the indenting problem. But as I said: just a guess. I'll try to track this down. Sincerely Meikel -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
Hi, On Nov 12, 11:30 am, Michael Wood esiot...@gmail.com 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 be syntax plugins. Try putting it in .vim/after/syntax/ clojure.vim. Sincerely Meikel PS: For windows: .vim == vimfiles -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Datatypes and Protocols - early experience program
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, please try them out. Feedback is particularly welcome as they are being refined. Thanks, Rich [1] http://www.assembla.com/wiki/show/clojure/Datatypes [2] http://www.assembla.com/wiki/show/clojure/Protocols [3] http://github.com/richhickey/clojure/tree/new [4] http://build.clojure.org/ -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Strange behavior seen when ints have leading zeros
C:\dev\clojurejava -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 delimiter: ] java.lang.Exception: Unmatched delimiter: ) user= Why does Clojure hate 8's? :-) -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
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 features too. Thanks, Sean On Nov 12, 7:10 am, Rich Hickey richhic...@gmail.com 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 current contrib. If you have the time and inclination, please try them out. Feedback is particularly welcome as they are being refined. Thanks, Rich [1]http://www.assembla.com/wiki/show/clojure/Datatypes [2]http://www.assembla.com/wiki/show/clojure/Protocols [3]http://github.com/richhickey/clojure/tree/new [4]http://build.clojure.org/ -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Strange behavior seen when ints have leading zeros
On Thu, Nov 12, 2009 at 6:38 PM, Robert Campbell rrc...@gmail.com wrote: C:\dev\clojurejava -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 delimiter: ] java.lang.Exception: Unmatched delimiter: ) user= I guess that's because if you precede a number with 0, it is treated as Octal numbers and there is no Octal 8. :-) Just a guess. I may be wrong. -- Ramakrishnan -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Strange behavior seen when ints have leading zeros
Oh, that's pretty neat. Thanks! On Thu, Nov 12, 2009 at 2:36 PM, Fogus mefo...@gmail.com 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 010 in octal. -m -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Strange behavior seen when ints have leading zeros
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 Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
On Nov 12, 8:29 am, Sean Devlin francoisdev...@gmail.com 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 way. This would probably help with the other features too. reify is the most subtle, as it is a subset of proxy, limited to implementing interfaces only, and less dynamic (no equivalent to update-proxy). What you get in return is a construct with fewer host implications, and much better performance, as stated in the wiki doc: The result is better performance than proxy, both in construction (proxy creates the instance and a fn instance for each method), and invocation. reify is preferable to proxy in all cases where its limitations are not prohibitive. Rich -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
2009/11/12 Meikel Brandmeyer m...@kotka.de: Hi, On Nov 12, 11:30 am, Michael Wood esiot...@gmail.com 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 be syntax plugins. Try putting it in .vim/after/syntax/ clojure.vim. Thanks, that seems to have fixed it. -- Michael Wood esiot...@gmail.com -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Problem w/ daemon threads
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 [f] (let [t (Thread. f)] (do (.setDaemon t true) (.start t) t))) And I tried calling user=(daemon #(println foo)) I get the thread back, but it does not appear to execute. I've tried this on OSX and XP. Does anyone know what I'm doing wrong? Sean -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
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 Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problem w/ daemon threads
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 thread back, but it does not appear to execute. I've tried this on OSX and XP. Does anyone know what I'm doing wrong? I tried this on Linux, and prints foo once, which is what I would expect. If you want it to be period, though, you'll need to use something like Executors/newSingleThreadScheduledExecutor to create a scheduler for it. I tried writing a periodic scheduler using agents (and a ref to manage state). Turns out that getting shutdown working robustly is actually fairly tricky. I recommend just using the scheduler available in Java. David -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Problem w/ daemon threads
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)) user=(daemon #(send my-agent inc)) user=@my-agent 1 D'oh! Sean On Nov 12, 11:09 am, David Brown cloj...@davidb.org wrote: 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 thread back, but it does not appear to execute. I've tried this on OSX and XP. Does anyone know what I'm doing wrong? I tried this on Linux, and prints foo once, which is what I would expect. If you want it to be period, though, you'll need to use something like Executors/newSingleThreadScheduledExecutor to create a scheduler for it. I tried writing a periodic scheduler using agents (and a ref to manage state). Turns out that getting shutdown working robustly is actually fairly tricky. I recommend just using the scheduler available in Java. David -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Gensym collisions can be engineered.
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 group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: vimclojure indentation problem.
Hi, On Nov 12, 5:01 pm, MarkSwanson mark.swanson...@gmail.com 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 fromstart was very slow. With today's computers it should not be a problem anymore. However, people are obsessed about speed, so I chose the safe setup, which also works on large files. But obviously it does have its problems on certain constellations. I think I asked for feedback in a previous thread, if someone has problems with sync fromstart. So far I got no response. So I will most likely switch to sync fromstart for the next release. Sincerely Meikel -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
sorted-set-by fails when given no values
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 values, but passes that on to PersistentTreeSet/create as null, but create doesn't check for null it just blindly calls .length on it. An example: ; This works: (reduce (fn [s b] (conj s b)) (sorted-set-by #(int (- (%1 :med) (%2 :med))) {:med Double/MAX_VALUE}) [{:med 4} {:med 1} {:med 10}]) ; Output: #{{:med 1} {:med 4} {:med 10} {:med 1.7976931348623157E308}} ; But this doesn't work: (reduce (fn [s b] (conj s b)) (sorted-set-by #(int (- (%1 :med) (%2 :med [{:med 4} {:med 1} {:med 10}]) ; Output: Caused by: java.lang.NullPointerException at clojure.lang.PersistentTreeSet.create(PersistentTreeSet.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:90) at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:202) at clojure.core$sorted_set_by__4242.doInvoke(core.clj:291) at clojure.lang.RestFn.invoke(RestFn.java:415) at user$eval__1103.invoke(NO_SOURCE_FILE:5) at clojure.lang.Compiler.eval(Compiler.java:4623) -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: getting emacs etags for Clojure source?
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 stuart.hallo...@gmail.com wrote: I have a poor man's version: find . -name '*.clj' | xargs etags --regex=@/Users/stuart/bin/ clojure.tags clojure.tags = /[ \t\(]*def[a-z]* \([a-z-!]+\)/\1/ /[ \t\(]*ns \([a-z.]+\)/\1/ Anyone have a better approach? If you've got slime running, M-. will be bound to slime-edit- definition, which queries the actual live instance to jump directly to the file/line that defs the var. No need to maintain an independent database. Of course, this only works for vars that have been required, but this is usually not a big deal. -Phil --~--~-~--~~~---~--~~ 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~--- -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Relevance Hacker-In-Res wants Clojure coders
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-residence-update-and-call-to-action Stu *disclosure: and a bunch of Rubyists -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: getting emacs etags for Clojure source?
On Nov 12, 12:36 pm, Stuart Halloway stuart.hallo...@gmail.com 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 a 1.0 version of swank-clojure just waiting to propagate out to the ELPA repository; should make experimenting with slime much easier. -Phil -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
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 francoisdev...@gmail.com 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 way. This would probably help with the other features too. reify is the most subtle, as it is a subset of proxy, limited to implementing interfaces only, and less dynamic (no equivalent to update-proxy). What you get in return is a construct with fewer host implications, and much better performance, as stated in the wiki doc: The result is better performance than proxy, both in construction (proxy creates the instance and a fn instance for each method), and invocation. reify is preferable to proxy in all cases where its limitations are not prohibitive. Rich -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: sorted-set-by fails when given no values
On Nov 13, 6:42 am, Albert Cardona sapri...@gmail.com 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 .length on it. I'll create a patch to address, Rich I take it you'll accept a ticket for this? -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Generalizing - -
2009/11/3 Alex Osborne a...@meshy.org: 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 arrow and double arrow. Then -? in contrib is short-circuiting thread. Not sure about the symbol, perhaps questionable arrow? ;-) The question mark ? is there to mimic (somewhat) what one can find in OO languages such as groovy (I think it's groovy, is it ?) : someObject.?propA.?prop2 where .? will check if the object is null before trying to get a property (or method) on it. If null : returns null, if not null, returns the property etc. Initially i wanted to name it -? but the final ? is by convention reserved for predicates, so Rich suggested -? (and also .?. for the .. equivalent). -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
There should be better API doc organization
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 given in a long list is context free and its much harder to learn. Just look at the Java API - you click on HashMap and can read all related to it methods. Because function programing is beased on small number of data types and many functions which modify them it is a must be for shorter learing curve. Other suggestion is to make an ability to post an example by the community for each method use (on the official clojure API page). This would be moderated by 2 or 3 people (maybe even Rich Hickey himself) and after acceptance it would be available to see by all. Functional requirments: code syntax coloured, ability to comment own code (or just use ; to comment it), capatcha to block vi***ra adv., rating by anonymous to see which examples are worth of keeping on the official API doc. Finally there should be also algorithm cheeat sheet. Like: Chapter: Loops Goal: do a loop on sequence and break processing after meeting a condition Imperative equivalent: while with break after if condtion becomes true) Examples: blah blah Comments: moderated commnets goes here Goal: do an infinitive loop on a sequence Imperative equivalent: infinitve for(;;) Examples: blah blah Comments: moderated comments goes here Goal: do a reading from lazy sequence Imperative eq: reading stream until coondtion in while becomes false Examples: blah balh Comments: moderated comments goes here etc. All this would make Clojure first joice for learning FP. Clojure would get Critical Mass, so it would become very popular. These all functionalites would greatly save all of us some time. Believe in community, we live in Web 2.0 times. Be so flexible and open minded as your language is Rich. Bye! PS. Link to contrib-lib API is now somehow hard to find (I had to bookmark it). -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
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 current contrib. If you have the time and inclination, please try them out. Feedback is particularly welcome as they are being refined. I implemented my lazymap library in terms reify where gen-class was required before. Seems to work smoothly, but it is also only a simple lib. Should ISeqs still extend ASeq? Is this a case where we still need gen-class? Otherwise I hadn't much chance to test... http://bitbucket.org/kotarak/lazymap/ Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Datatypes and Protocols - early experience program
On Thu, Nov 12, 2009 at 7:10 AM, Rich Hickey richhic...@gmail.com 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/finger_tree.clj Here's an earlier version that's almost idectical except its implemented using def-interface and reify instead: http://tinyurl.com/y9jned5/finger_tree.clj --Chouser -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
On Thu, Nov 12, 2009 at 7:59 PM, Chouser chou...@gmail.com wrote: On Thu, Nov 12, 2009 at 7:10 AM, Rich Hickey richhic...@gmail.com 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/finger_tree.clj I should have noted that this is a very early version and doesn't yet take advantage of some features now available like reusing the same protocol function in multiple protocols, or using 'case' instead of 'cond' or 'condp'. --Chouser -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
swap two elements in an arbitrary collection
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 pre-li (list (nth coll j)) post-li-pre-ui (list (nth coll i)) (rest post-li-post-ui)) Basically, I find the lower index and the upper index. I then find the elements in the collection that appear before the lower index, and the elements that appear between the lower index and the upper index, and the elements that appear after the upper index. I then create a new list that is the concatenation of these sublists, in order. It's sort of the definition of swap on an immutable data structure, but it feels like an awful lot of code. I considered using subvec: http://clojure.org/api#toc548 But I didn't want to require that my input collection be a vector, or convert it to one. This the precursor to my implementing a heap data structure, as a little toy application. -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: swap two elements in an arbitrary collection
Oh, I posted too soon. My implementation has a bug. On Nov 12, 9:56 pm, Mark Tomko mjt0...@gmail.com 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)] (let [[post-li-pre-ui post-li-post-ui] (split-at (- ui 1) (rest post-li))] (concat pre-li (list (nth coll j)) post-li-pre-ui (list (nth coll i)) (rest post-li-post-ui)) Basically, I find the lower index and the upper index. I then find the elements in the collection that appear before the lower index, and the elements that appear between the lower index and the upper index, and the elements that appear after the upper index. I then create a new list that is the concatenation of these sublists, in order. It's sort of the definition of swap on an immutable data structure, but it feels like an awful lot of code. I considered using subvec: http://clojure.org/api#toc548 But I didn't want to require that my input collection be a vector, or convert it to one. This the precursor to my implementing a heap data structure, as a little toy application. -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Generalizing - -
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 laurent.pe...@gmail.com wrote: 2009/11/3 Alex Osborne a...@meshy.org: 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 arrow and double arrow. Then -? in contrib is short-circuiting thread. Not sure about the symbol, perhaps questionable arrow? ;-) The question mark ? is there to mimic (somewhat) what one can find in OO languages such as groovy (I think it's groovy, is it ?) : someObject.?propA.?prop2 where .? will check if the object is null before trying to get a property (or method) on it. If null : returns null, if not null, returns the property etc. Initially i wanted to name it -? but the final ? is by convention reserved for predicates, so Rich suggested -? (and also .?. for the .. equivalent). -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Omnem crede diem tibi diluxisse supremum. -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: swap two elements in an arbitrary collection
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 (list (nth coll ui)) post-li-pre-ui (list (nth coll li)) (rest post-li-post-ui))) The code is actually even more complicated. I'm sure with a little more time I could clean it up. On Nov 12, 9:59 pm, Mark Tomko mjt0...@gmail.com wrote: Oh, I posted too soon. My implementation has a bug. On Nov 12, 9:56 pm, Mark Tomko mjt0...@gmail.com 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)] (let [[post-li-pre-ui post-li-post-ui] (split-at (- ui 1) (rest post-li))] (concat pre-li (list (nth coll j)) post-li-pre-ui (list (nth coll i)) (rest post-li-post-ui)) Basically, I find the lower index and the upper index. I then find the elements in the collection that appear before the lower index, and the elements that appear between the lower index and the upper index, and the elements that appear after the upper index. I then create a new list that is the concatenation of these sublists, in order. It's sort of the definition of swap on an immutable data structure, but it feels like an awful lot of code. I considered using subvec: http://clojure.org/api#toc548 But I didn't want to require that my input collection be a vector, or convert it to one. This the precursor to my implementing a heap data structure, as a little toy application. -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Generalizing - -
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 wmacgy...@gmail.com: 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 laurent.pe...@gmail.com wrote: 2009/11/3 Alex Osborne a...@meshy.org: 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 arrow and double arrow. Then -? in contrib is short-circuiting thread. Not sure about the symbol, perhaps questionable arrow? ;-) The question mark ? is there to mimic (somewhat) what one can find in OO languages such as groovy (I think it's groovy, is it ?) : someObject.?propA.?prop2 where .? will check if the object is null before trying to get a property (or method) on it. If null : returns null, if not null, returns the property etc. Initially i wanted to name it -? but the final ? is by convention reserved for predicates, so Rich suggested -? (and also .?. for the .. equivalent). -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Omnem crede diem tibi diluxisse supremum. -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
On Nov 12, 1:10 pm, Rich Hickey richhic...@gmail.com 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 current contrib. If you have the time and inclination, please try them out. Feedback is particularly welcome as they are being refined. I really like the semantics of your constructs. I have a comment about regularity of syntax: The way to specify method names in reify and deftype vs. function names defprotocol and extend are different. It looks like when dealing with interface-method implementations one uses .methodName (i.e., with the dot), but when dealing with protocol functions one uses no dot. Further, extend uses maps (the docs says why this is the case). I was thinking this may make syntax irregular. I suspect this is a deliberate design choice to distinguish clojure protocols from java interfaces? Is this the case? A stupid example: ;;uses dot (deftype Sometype [x] [java.lang.Comparable] (.compareTo [o] ...)) ::uses no dot (defprotocol RSeqable :on clojure.lang.Seqable Seqable and reverse seqable (rseq [s] reverse seq)) ;;do I mix dot and not? (extend ::Sometype :RSeqable {:rseq (fn [a]...)) :.seq (fn [a] ...)} ;; do I write :.seq here or :seq? I guess one can reintroduce the regularity using the :on feature of protocol functions. Any thoughts? /Karl -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Datatypes and Protocols - early experience program
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/gen-class. I can just imagine the questions a year from now when people join the Clojure community and want to understand how they differ. So I think that eventually, there needs to be a very clear story as to why you'd choose one over the other. Or better yet, maybe some of the older constructs can be phased out completely. Is there a way to customize the way that types defined by deftype print in the REPL? While these datatype and protocol constructs are taking shape, maybe now is the time to discuss what kind of privacy settings are worthwhile in a language like Clojure. I think Java's system of private/public/protected is probably overkill for Clojure. But do people feel that some degree of data hiding is worthwhile? For example, might you want to hide some deftype fields from keyword lookup? Protocols: I don't understand whether there's any way to provide a partial implementation or default implementation of a given protocol/interface, and I believe this to be an important issue. For example, a protocol for and that provides a default implementation of in terms of and a default implementation of in terms of , so that you only need to implement one and you get the other for free. I'm also thinking about the relationship in Clojure's source between ISeq and ASeq. ASeq provides the partial, default implementation of more in terms of next, for example. How does this kind of thing look with the new protocol system? -- 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 are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en