Re: Type hint Java array of your own Java class
On Thu, Feb 5, 2009 at 7:33 AM, Christophe Grand wrote: > > Chouser a écrit : >> (defn foobar [#^#=(array-of MyClass) myarray]) >> >> Again, I apologize for even suggesting this > Wow what a clever (ab)use of reader macros! This is where a raptor jumps in from the left and eats someone :) > > -- > Professional: http://cgrand.net/ (fr) > On Clojure: http://clj-me.blogspot.com/ (en) > > > > > > -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
anyone going to FOSDEM?
Hi, are any clojure developers going to FOSDEM, next week-end in Brussels (Belgium)? It would be cool to meet there. (I'm a complete newbie at clojure, but that would make it the more interesting for me to meet other clojure developers:-) Cheers Raphaël --~--~-~--~~~---~--~~ 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 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: Stumped - Java hangs when using Swing in Slime
I've got the same problem as srolls24 and CuppoJava on Windows XP, using Emacs 23 and versions of Clojure, Slime and Swank fetched today. Also, when starting Slime, it opens a connection to *inferior-lisp*, but keeps polling for Swank until I hit return in the inferior-lisp buffer. After that, it very quickly connects the slime-repl. Any thoughts? --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
On Feb 1, 7:22 pm, David Nolen wrote: > I've changed the name of my project since that was a joke > anyway.http://github.com/swannodette/spinoza/tree/master > > Spinoza isn't just for people who want object oriented behaviors. It's also > for anyone who plans on instantiating many structs. Spinoza's make-instance > macro automatically orders your key/values and uses struct not struct-map. > > (defclass shape [object] > (:position [0 0])) > > (defclass rect [shape] > (:position [5 5]) > :width > :height) > > (time (dotimes [x 100] > (make-instance rect :height 100 :width 150))) > > > ~280ms > > (defstruct rect-struct :tag :position :width :height) > (time (dotimes [x 100] > (struct-map rect-struct :tag ::rect :position [50 50] :width 100 :height > 190))) > > > ~800ms > > Also, it is now available under an MIT license, feel free to fork, send > patches at will etc. I'm still quite interested in this project, and I'm tempted to try rewriting a subsystem in my own main project with it, but in the course of developing some behavior that I needed, I went off in a slightly different quasi-object-like direction. If I were going to add something to Spinoza, it would be eql specializers. I'm not going to add anything to Spinoza, though, at least not right now; instead, I'm going to keep working on my own model/protocol/thing subsystem. Similar to Spinoza, it uses maps to represent objects; objects are called 'things'. A thing has a 'model' and a 'protocol'. The model determines what fields the thing has, and whether there are any type restrictions on the values; the protocol determines what operations (that is, what multifunctions) work on the thing. I don't argue that this model is better than what you're doing with Spinoza, but for years (see http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html from 1994) I've wanted an object model that explicitly separates structure from protocol, and since I partially built one in order to satisfy a need I had in a larger project, I think I'll push ahead with it a bit to see whether it's worthwhile. If I were going to add one thing to my own model/protocol/thing subsystem--or add one thing to Clojure to support it--it would be predicate dispatch. Who knows? Maybe I will, if I decide that I want it badly enough. --~--~-~--~~~---~--~~ 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 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: Questions about a Clojure Datalog
On Feb 4, 5:22 pm, John Fries wrote: > Guaranteed-termination is very desirable. However, you can have guaranteed > termination with an open-world assumption just as well. And I think an > open-world assumption does a better job of mimicking human reasoning. > Do you have a specific reasoner/algorithm in mind? 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 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: Map from generator?
On Feb 4, 10:36 pm, Conrad wrote: > It is useful to build a map from a list of keys and a value generator > function. Of Course, such a function is easy to write: > > (defn genmap [keys fun] > (zipmap keys (map fun keys))) > > In fact, it seems so useful that it must be in the standard API > somewhere, but I can't find it... did I miss it somewhere, or was I > right to create my own? Please let me know if I'm reinventing the > wheel. > > It does seem useful, although the zipmap call is already concise. I wonder if this is a frequently reinvented wheel. 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
Hello, Please accept my apologizes if the following remarks/questions sound stupid or silly to you, but I can't resist ask/remark in order to gain a better understanding of what you meant when writing the following : 2009/2/5 mikel > On Feb 1, 7:22 pm, David Nolen wrote: > > > > (time (dotimes [x 100] > > (make-instance rect :height 100 :width 150))) > > > > > ~280ms > > > > (defstruct rect-struct :tag :position :width :height) > > (time (dotimes [x 100] > > (struct-map rect-struct :tag ::rect :position [50 50] :width 100 :height > > 190))) > > > > > ~800ms > > > > Also, it is now available under an MIT license, feel free to fork, send > > patches at will etc. > > > I'm still quite interested in this project, and I'm tempted to try > rewriting a subsystem in my own main project with it, but in the > course of developing some behavior that I needed, I went off in a > slightly different quasi-object-like direction. If I were going to add > something to Spinoza, it would be eql specializers. > > I'm not going to add anything to Spinoza, though, at least not right > now; instead, I'm going to keep working on my own model/protocol/thing > subsystem. Similar to Spinoza, it uses maps to represent objects; > objects are called 'things'. A thing has a 'model' and a 'protocol'. > The model determines what fields the thing has, and whether there are > any type restrictions on the values; the protocol determines what > operations (that is, what multifunctions) work on the thing. Doesn't that sound like multifunctions whose dispatching is tied to the type ('model') of a 'thing' ? And if this is correct, in what does it differ from the concept of interface in Java ? I don't argue that this model is better than what you're doing with > Spinoza, but for years (see > http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html > from 1994) I've wanted an object model that explicitly separates > structure from protocol, and since I partially built one in order to > satisfy a need I had in a larger project, I think I'll push ahead with > it a bit to see whether it's worthwhile. Once again, does'nt this correspond to the introduction of the interface concept in java ? Or, asked differently, compared to what you're thinking about, what does the java 'interface' concept lack ? > If I were going to add one thing to my own model/protocol/thing > subsystem--or add one thing to Clojure to support it--it would be > predicate dispatch. Who knows? Maybe I will, if I decide that I want > it badly enough. > > > > > > -- Cordialement, Laurent PETIT --~--~-~--~~~---~--~~ 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 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: Map from generator?
I frequently use a more general version of this function that reduces a seq to a map, mapping each element in the seq to a [key value] pair for the map. I use this in several different libs: (defn mash "Reduce a seq-able to a map. The given fn should return a 2-element tuple representing a key and value in the new map." [f coll] (reduce (fn [memo elem] (let [[k v] (f elem)] (assoc memo k v))) {} coll)) Where "mash" comes from map + hash. (mash (fn [elem] [(+ 1 elem) (+ 2 elem)]) (list 1 2 3)) => {4 5, 3 4, 2 3} You could also use into: (into {} (map (fn [elem] [(+ 1 elem) (+ 2 elem)]) (list 1 2 3))) => {4 5, 3 4, 2 3} - Mark On Thu, Feb 5, 2009 at 7:33 AM, Rich Hickey wrote: > > > > On Feb 4, 10:36 pm, Conrad wrote: >> It is useful to build a map from a list of keys and a value generator >> function. Of Course, such a function is easy to write: >> >> (defn genmap [keys fun] >> (zipmap keys (map fun keys))) >> >> In fact, it seems so useful that it must be in the standard API >> somewhere, but I can't find it... did I miss it somewhere, or was I >> right to create my own? Please let me know if I'm reinventing the >> wheel. >> >> > > It does seem useful, although the zipmap call is already concise. > > I wonder if this is a frequently reinvented wheel. > > 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 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 -~--~~~~--~~--~--~---
clojure.core/import fix
Test case: --- (add-classpath "file:///home/user/.maven/repository/commons-io/jars/ commons-io-1.4.jar") (ns import-testcase (:refer-clojure) (:import (org.apache.commons.io FileUtils))) --- Loading code above results in java.lang.ClassNotFoundException. This is beacuse clojure.core/import uses java.lang.Class#forName(String) method to load class, which in turn uses classloader that clojure runtime was started with. Classes added to classpath using (add-classpath) are not visible. Shouldn't import handle also classes added to classpath by add-classpath? If so here's the patch that fixes it (by using java.lang.Class#forName(String,boolean,ClassLoader) method): http://groups.google.pl/group/clojure/web/import-fix.diff If throwing ClassNotFoundException is desirable can someone provide me with another way to use unqualified classes added to classpath using add-classpath? Fully qualified class names are visible. Tomasz --~--~-~--~~~---~--~~ 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 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: London Clojurians
On Feb 4, 8:25 am, H Durer wrote: > 2009/2/3 AndrewC. : > [...] > > > The people at Scheme UK have (very) occasional meetings in Shoreditch. > > We could join up with them and get a few more people, perhaps. > > >http://upcoming.yahoo.com/group/4654/ > > > Perhaps someone could do an introductory talk 'Clojure for Schemers' > > and then move on to Compojure. > > I agree -- the schemers group has been quite quiet lately; I'd think > they welcome new faces and interesting talks even if not directly > Scheme related. > > I just wish their meetings weren't always on a Wednesday... > I'll be speaking Thursday evening, March 12, at the London Java Community Meetup: http://www.meetup.com/Londonjavacommunity/calendar/9672764/ This in addition to two talks at QCon London that week: http://www.qconlondon.com/ 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 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: how to reason about two dimentional array(vector) like...
for simplicity, first tried to create two dimentional array(vector) of numbers. On Feb 5, 1:58 am, Emeka wrote: > Where did 'ref' go in your own implementation? > > Emeka --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
test-is: (is (thrown? ...)) & exceptions & REPL
Hello Stuart and all! There is something strange going on with (is (thrown? ...)) form: user=> (use 'clojure.contrib.test-is) nil user=> (is (= 2 2)) true ; this works user=> (/ 1 0) java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0) user=> (is (thrown? ArithmeticException (/ 1 0))) # ; this doesn't work user=> (if) java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:10) user=> (is (thrown? Exception (if))) java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:13) user=> (if true) java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:29) user=> (is (thrown? Exception (if true))) java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:14) ; this works user=> (- 2) -2 user=> (-) java.lang.IllegalArgumentException: Wrong number of args passed to: core$- (NO_SOURCE_FILE:0) user=> (is (thrown? IllegalArgumentException (-))) # Even though 'if' is a special form, shouldn't (is (thrown? Exception (if))) catch the Exception correctly? Also, notice that (if) throws different exception than (-) - would it make sense to unify these exceptions? Another example: user=> (vals {:a 1 :b 2}) (1 2) user=> (vals [1 2]) java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry (user=> (is (thrown? ClassCastException (vals [1 2]))) FAIL in (:20) expected: (thrown? ClassCastException (vals [1 2])) actual: nil nil We can see that exception doesn't get processed/caught correctly. Also see REPL - it prints redundant "(" character after exception was thrown. Hitting ENTER fixes it: user=> (vals [1 2]) java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry (user=> user=> Thank you for looking at this, Frantisek --~--~-~--~~~---~--~~ 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 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: London Clojurians
Another option would be to do a session at one of the erlounges at Erlang Traing and Consulting.The only issue is that someone would have to do a presentation for the erlang people there and I, for one, am not knowledgeable enough to present on Clojure yet. Tom 2009/2/3 AndrewC. > > On Feb 3, 12:54 pm, Tom Ayerst wrote: > > I suggest we work to James' schedule and talk about Compojure in our > first > > meet; how does that sound? > > > > I don't have access to a private venue. If anyone else does that would > be > > cool, otherwise I'll try and find somewhere reasonably quiet, suggestions > > welcome. > > The people at Scheme UK have (very) occasional meetings in Shoreditch. > We could join up with them and get a few more people, perhaps. > > http://upcoming.yahoo.com/group/4654/ > > Perhaps someone could do an introductory talk 'Clojure for Schemers' > and then move on to Compojure. > > > > > > --~--~-~--~~~---~--~~ 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 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: Stumped - Java hangs when using Swing in Slime
On Thu, Feb 5, 2009 at 4:52 AM, David wrote: > > I've got the same problem as srolls24 and CuppoJava on Windows XP, > using Emacs 23 > and versions of Clojure, Slime and Swank fetched today. > > Also, when starting Slime, it opens a connection to *inferior-lisp*, > but keeps polling > for Swank until I hit return in the inferior-lisp buffer. After that, > it very quickly connects > the slime-repl. > > Any thoughts? > David, I had that problem on Windows XP as well. I can't figure out the real issue, but it started when Clojure's Ref.java stopped calling UUID.randomUUID. I had to patch swank-clojure like this to work around it: http://bitbucket.org/shoover/clojure-box-swank-clojuremq/src/11bec919b978/hack-repl-hang The current release of Clojure Box (http://clojure.bighugh.com) contains that change. Shawn --~--~-~--~~~---~--~~ 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 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: test-is: (is (thrown? ...)) & exceptions & REPL
>From a quick glance, it looks like the exceptions that are *not* being caught are those generated by the compiler, who can't understand the code. test-is can't find those because the code doesn't even run in that case. On Thu, Feb 5, 2009 at 8:33 AM, Frantisek Sodomka wrote: > Hello Stuart and all! > > There is something strange going on with (is (thrown? ...)) form: > > user=> (use 'clojure.contrib.test-is) > nil > user=> (is (= 2 2)) > true > > ; this works > user=> (/ 1 0) > java.lang.ArithmeticException: Divide by zero (NO_SOURCE_FILE:0) > user=> (is (thrown? ArithmeticException (/ 1 0))) > # > > ; this doesn't work > user=> (if) > java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:10) > user=> (is (thrown? Exception (if))) > java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:13) > > user=> (if true) > java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:29) > user=> (is (thrown? Exception (if true))) > java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:14) > > ; this works > user=> (- 2) > -2 > user=> (-) > java.lang.IllegalArgumentException: Wrong number of args passed to: core$- > (NO_SOURCE_FILE:0) > user=> (is (thrown? IllegalArgumentException (-))) > # of args passed to: core$-> > > Even though 'if' is a special form, shouldn't (is (thrown? Exception (if))) > catch the Exception correctly? Also, notice that (if) throws different > exception than (-) - would it make sense to unify these exceptions? > > Another example: > > user=> (vals {:a 1 :b 2}) > (1 2) > user=> (vals [1 2]) > java.lang.ClassCastException: java.lang.Integer cannot be cast to > java.util.Map$Entry > (user=> (is (thrown? ClassCastException (vals [1 2]))) > > FAIL in (:20) > expected: (thrown? ClassCastException (vals [1 2])) > actual: nil > nil > > We can see that exception doesn't get processed/caught correctly. > > Also see REPL - it prints redundant "(" character after exception was > thrown. Hitting ENTER fixes it: > > user=> (vals [1 2]) > java.lang.ClassCastException: java.lang.Integer cannot be cast to > java.util.Map$Entry > (user=> > user=> > > Thank you for looking at this, Frantisek > > > > --~--~-~--~~~---~--~~ 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 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: test-is: (is (thrown? ...)) & exceptions & REPL
user=> (deftest test-if (is (thrown? Exception (if java.lang.Exception: Too few arguments to if (NO_SOURCE_FILE:35) user=> (deftest test-div (is (thrown? ArithmeticException (/ 1 0 #'user/test-div Yes, looks like it. Compile-time and run-time exceptions - will have to remember that ;-) Frantisek PS: I still wonder why REPL has that "(" char after exception. Bug? On 5 Ún, 15:28, Jeffrey Straszheim wrote: > From a quick glance, it looks like the exceptions that are *not* being > caught are those generated by the compiler, who can't understand the code. > test-is can't find those because the code doesn't even run in that case. > --~--~-~--~~~---~--~~ 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 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: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
> 2) The current directory (parent of gui2) is in the class-path -cp > option when launching Clojure Updated the guide with note about CLASSPATH - basicaly, I have current directory (".") listed in it. Also, replaced quote character with "quote" word in the code. Updated version so far only here: http://clojure.googlegroups.com/web/clojure-gui-and-netbeans.pdf Vlad --~--~-~--~~~---~--~~ 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 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: Indy .NET programmers discover parentheses
On Thu, Jan 29, 2009 at 10:50 AM, Shawn Hoover wrote: > Heartland Clojure Users, > > I'm giving a presentation on Clojure next month for the Indianapolis ALT.NET > group. The talk is aimed at .NET programmers, introducing Clojure and > showing them why they might care. > > More description and meeting details: > http://indyalt.net/cms/meeting/february-2009/clojure Sounds like fun. I'll plan to be there. --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 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: test-is: (is (thrown? ...)) & exceptions & REPL
On Feb 5, 9:28 am, Jeffrey Straszheim wrote: > From a quick glance, it looks like the exceptions that are *not* being > caught are those generated by the compiler, who can't understand the code. > test-is can't find those because the code doesn't even run in that case. Yes. In the current implementation of test-is, tests are compiled into functions when they are defined. So compile-time exceptions can't be caught. I assume these situations are fairly rare and easily corrected. -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: test-is: (is (thrown? ...)) & exceptions & REPL
On Feb 5, 9:59 am, Frantisek Sodomka wrote: > PS: I still wonder why REPL has that "(" char after exception. Bug? It's the lazy sequence thing again. The REPL starts printing the sequence, beginning with the "(", before the exception gets thrown. Here's a more obvious example: user=> (map #(/ 10 %) [1 2 0 5]) java.lang.ArithmeticException: Divide by zero (10 5 user=> -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: test-is: (is (thrown? ...)) & exceptions & REPL
Laziness is sometimes confusing :) On Thu, Feb 5, 2009 at 11:02 AM, Stuart Sierra wrote: > > On Feb 5, 9:59 am, Frantisek Sodomka wrote: > > PS: I still wonder why REPL has that "(" char after exception. Bug? > > It's the lazy sequence thing again. The REPL starts printing the > sequence, beginning with the "(", before the exception gets thrown. > Here's a more obvious example: > > user=> (map #(/ 10 %) [1 2 0 5]) > java.lang.ArithmeticException: Divide by zero > (10 5 user=> > > > -Stuart Sierra > > > --~--~-~--~~~---~--~~ 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 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: anyone going to FOSDEM?
Raphaël, I will be there presenting the open source meta web project ShiftSpace ( http://shiftspace.org) at the art festival Artefact ( http://www.artefact-festival.be/). Unfortunately this project isn't really Clojure related, it's primarily written in Javascript :) However, two people (including myself) have been playing around with Clojure and wouldn't mind meeting a fellow Clojurian! We arrive on Sunday and are planning on checking FOSDEM out. We're also giving a developer workshop on ShiftSpace in Brussels on the 12th so if you're around come check that out as well. David 2009/2/5 rb > > Hi, > > are any clojure developers going to FOSDEM, next week-end in Brussels > (Belgium)? > > It would be cool to meet there. (I'm a complete newbie at clojure, but > that would make it the more interesting for me to meet other clojure > developers:-) > > Cheers > > Raphaël > > > > --~--~-~--~~~---~--~~ 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 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: Questions about a Clojure Datalog
Yes. I can make a strong endorsement for Kodkod, a Java-based relational model finder. http://alloy.mit.edu/kodkod/ I used it fairly extensively last year to solve scheduling problems, and I've corresponded with its creator. One problem with Datalog-style reasoners is that, because they want to guarantee a certain execution time, they give up much of the expressiveness of relational logic. Instead, Kodkod provides the correct interface to relational logic, and relies on an underlying SAT solver (such as MiniSat) to solve the problems in a reasonable amount of time. This has proven to be a good approach, because SAT solvers have been improving at a tremendous rate over the last 10 years, and are now blazingly fast. Another advantage of Kodkod over, say, FaCT++ or Pellet (which also provide open-world semantics) is that you are not tied into all the assumptions of the semantic web (OWL, RDF, XML, etc), which can get pretty clunky when all you want is an in-memory reasoner. You only have to be reasonably comfortable with relational logic (e.g. "for all x: Red x") to be able to use Kodkod. The only deficiency I found in Kodkod was that, because the author wanted to support an audience whose primary language was Java, the user must express their queries using a Java class-based syntax. But this seems like a perfect use of Clojure, which could provide a much more natural query syntax. On Thu, Feb 5, 2009 at 4:29 AM, Rich Hickey wrote: > > > On Feb 4, 5:22 pm, John Fries wrote: > > Guaranteed-termination is very desirable. However, you can have > guaranteed > > termination with an open-world assumption just as well. And I think an > > open-world assumption does a better job of mimicking human reasoning. > > > > Do you have a specific reasoner/algorithm in mind? > > 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 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 -~--~~~~--~~--~--~---
New York Hadoop User Group, Feb. 10
Hello, New York! If you're interested, I'm presenting at the New York Hadoop User Group [1] next Tuesday, February 10, at 6:30. I'll talk about using Clojure with Hadoop, among other things. [1] http://www.meetup.com/Hadoop-NYC/ -Stuart Sierra --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Macro defining Macros issue.
I've been working on a def-casemacro macro and I've run into some trouble. The macro defines smaller macros based on a supplied name and test function. Each one evaluates the first argument and then uses the test to compare the result to each supplied case, evaluating whatever returns true or raising an error otherwise. Your basic ecase like macros. I've made macros like this in Common Lisp befor without any trouble but in clojure the ` reader macro seems to namespace qualify everything inside of it. This causes Clojure to freek out about all my variables and arguments. So far the only solution I've found is to stick ~' infront of each variable I use. But this is less then ideal cause you end up 2 or 3 backticks in with stuff like ~~' infront of every local variable. Honetsly I'm not sure what could be done about this, I just wanted to point it out in case it hasn't been already. Anyway I got it to work, so for those intrested, here it is: (defn pair-seq [seq] (if seq (lazy-cons [(first seq) (second seq)] (pair-seq (rrest seq))) nil)) (defmacro def-casemacro [casename test] "Defines a macro named casename that uses test to compair the result of form to each key/result pair" `(defmacro ~casename ~(format "Evaluates form and finds the first key/result pair that %s is true for, evaluates it and returns the result. Error if none is found." (print-str test)) [~'form & ~'key-result-pairs] (let [~'key-gen (gensym "key__") ~'kr-pairs (pair-seq ~'key-result-pairs)] `(let [~~'key-gen ~~'form] (cond ~@(mapcat (fn [[~'key ~'result]] `((~'~test ~~'key-gen ~~'key) ~~'result)) ~'kr-pairs) true (throw (new Error (format ~(str "No " '~casename " for key: %s") (str ~~'key-gen) ;; Examples (def-casemacro case =) (def-casemacro instance?-case instance?) (def-casemacro identical?-case identical?) (def-casemacro isa?-case isa?) ;;Umm... Meta-Examples? (comment (case (first '(:foo :bar :biz)) :bar 5 :foo 7 :biz 6) => 7 (instance?-case "foo bar" (if true String Double) 'yay! Integer 'boo...) => yay! (contains?-case #{:foo :bar :biz} :foo 5 :bar 2 :biz 3) => 5 (isa?-case (class "foo") FileInputStream :file-stream InputStream :istream String :string) => :string etc... ) -- -Nate --~--~-~--~~~---~--~~ 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 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: My SLIME installation diary
On Wed, Feb 4, 2009 at 4:36 PM, chris wrote: [snip] > My slime setup currently fails completely on windows, however. The > slime repl never starts; is there a way to get slime to dump all of > its communication (both ways, not just sending) to a file? Ditto, I'm still busted on Windows with the latest snaps of everything, just as I was a couple of weeks ago. Haven't tried installing on my Ubuntu box yet to see if this is indeed windows specific. -tree -- Tom Emerson tremer...@gmail.com http://treerex.blogspot.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 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: Macro defining Macros issue.
Hi, first things first: what you want to do is available as condp in the core library of Clojure. That said, here some things I noticed in your macro. You should not capture variables in your macros. That's bad style and might lead to clashes of names. Clojure provides the foo# notation to generate new symbols via gensym. This makes a call to gensym almost always unnecessary. Your pair-seq function may be written using the partition function from the seq-library: (pair-seq the-seq) <=> (partition 2 the-seq). One may specify a map between the argument vector and the docstring of functions and macros. This map becomes part of the metadata. Here this may be used to get some nice argument names in the doc output for the generated macro instead of the gensym names. Here we go: (defmacro def-casemacro [casename test] "Defines a macro named casename that uses test to compair the result of form to each key/result pair" `(defmacro ~casename ~(format "Evaluates form and finds the first key/result pair that %s is true for, evaluates it and returns the result. Error if none is found." (print-str test)) {:arglists '([~'form ~'key-result-pairs])} [form# & key-result-pairs#] (let [key-gen# (gensym "key__") kr-pairs# (partition 2 key-result-pairs#)] `(let [~key-gen# ~form#] (cond ~@(mapcat (fn [[key# result#]] `((~'~test ~key-gen# ~key#) ~result#)) kr- pairs#) true (throw (new Error (format ~(str "No %s for key: %s") ~~(name casename) (str ~key-gen#) This works for me at least for the case (def-casemacro case =). Hope this helps. Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: Macro defining Macros issue.
On Feb 5, 1:04 pm, Nathanael Cunningham wrote: > I've been working on a def-casemacro macro and I've run into some trouble. > The macro defines smaller macros based on a supplied name and test function. > Each one evaluates the first argument and then uses the test to compare the > result to each supplied case, evaluating whatever returns true or raising an > error otherwise. Your basic ecase like macros. There's some code very similar to what you describe in clojure.contrib.fcase. -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: My SLIME installation diary
I haven't seen a clear argument about the classpath variable one way or another. I also haven't figured out an elegant way to deal with it. I have no problem running a shell script from a terminal I want to develop with to setup classpath to be exactly what I expect it to be on a unix system. On windows, this is a little strange. One thing I am certain about is that as my java setup gets more advanced and I start using more interesting jars and jnilibs, my classpath and my java.library.path are both going to get more complex. I am certainly *not* going to repeat my non-trivial classpath into my .emacs file thus forcing myself to change something difficult to get correct in the first place in at least two places. On windows it appears that java correctly using the path env. variable to load jni libs. On Mac, it doesn't. One huge improvement would be that any binary libs, be they jni libs *or* dlls that java finds next to jars in the classpath are eligible for loading on both systems. Thus I don't have to setup my java loading system using two completely unrelated environment variables. Using JOGL and clojure on windows and mac has brought at lot of the pain of java right to the forefront in my case. Chris On Feb 5, 11:21 am, Tom Emerson wrote: > On Wed, Feb 4, 2009 at 4:36 PM, chris wrote: > > [snip] > > > My slime setup currently fails completely on windows, however. The > > slime repl never starts; is there a way to get slime to dump all of > > its communication (both ways, not just sending) to a file? > > Ditto, I'm still busted on Windows with the latest snaps of > everything, just as I was a couple of weeks ago. Haven't tried > installing on my Ubuntu box yet to see if this is indeed windows > specific. > > -tree > > -- > Tom Emerson > tremer...@gmail.comhttp://treerex.blogspot.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 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: New York Hadoop User Group, Feb. 10
Do you have slides for those of us who cannot attend? On Feb 5, 12:33 pm, Stuart Sierra wrote: > Hello, New York! If you're interested, I'm presenting at the New York > Hadoop User Group [1] next Tuesday, February 10, at 6:30. > > I'll talk about using Clojure with Hadoop, among other things. > > [1]http://www.meetup.com/Hadoop-NYC/ > > -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
A protocol is a level of abstraction above an interface. Java (and c++) virtual dispatch is one implementation of a meta-object protocol, where dispatch is dynamic upon the first argument to the function and object derivation means a certain order of function overriding, etc. Most likely mikel is trying to implement other types of protocols, each protocol has the option to at least implement its own dispatch mechanism. The underlying data object can then perhaps then be represented and manipulated in several different protocols. The article he linked to is somewhat clear on this. Also check out: http://en.wikipedia.org/wiki/Metaobject http://en.wikipedia.org/wiki/Common_Lisp_Object_System Chris On Feb 5, 5:36 am, Laurent PETIT wrote: > Hello, > > Please accept my apologizes if the following remarks/questions sound stupid > or silly to you, but I can't resist ask/remark in order to gain a better > understanding of what you meant when writing the following : > > 2009/2/5 mikel > > > > > On Feb 1, 7:22 pm, David Nolen wrote: > > > > (time (dotimes [x 100] > > > (make-instance rect :height 100 :width 150))) > > > > > ~280ms > > > > (defstruct rect-struct :tag :position :width :height) > > > (time (dotimes [x 100] > > > (struct-map rect-struct :tag ::rect :position [50 50] :width 100 :height > > > 190))) > > > > > ~800ms > > > > Also, it is now available under an MIT license, feel free to fork, send > > > patches at will etc. > > > I'm still quite interested in this project, and I'm tempted to try > > rewriting a subsystem in my own main project with it, but in the > > course of developing some behavior that I needed, I went off in a > > slightly different quasi-object-like direction. If I were going to add > > something to Spinoza, it would be eql specializers. > > > I'm not going to add anything to Spinoza, though, at least not right > > now; instead, I'm going to keep working on my own model/protocol/thing > > subsystem. Similar to Spinoza, it uses maps to represent objects; > > objects are called 'things'. A thing has a 'model' and a 'protocol'. > > The model determines what fields the thing has, and whether there are > > any type restrictions on the values; the protocol determines what > > operations (that is, what multifunctions) work on the thing. > > Doesn't that sound like multifunctions whose dispatching is tied to the > type ('model') of a 'thing' ? > And if this is correct, in what does it differ from the concept of interface > in Java ? > > I don't argue that this model is better than what you're doing with > > > Spinoza, but for years (see > >http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html > > from 1994) I've wanted an object model that explicitly separates > > structure from protocol, and since I partially built one in order to > > satisfy a need I had in a larger project, I think I'll push ahead with > > it a bit to see whether it's worthwhile. > > Once again, does'nt this correspond to the introduction of the interface > concept in java ? > Or, asked differently, compared to what you're thinking about, what does the > java 'interface' concept lack ? > > > If I were going to add one thing to my own model/protocol/thing > > subsystem--or add one thing to Clojure to support it--it would be > > predicate dispatch. Who knows? Maybe I will, if I decide that I want > > it badly enough. > > -- > Cordialement, > > Laurent PETIT --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Denver/Boulder Clojure users
Are there any existing clojure users in the Denver/Boulder area (other than me)?. Chris --~--~-~--~~~---~--~~ 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 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: Denver/Boulder Clojure users
I live in southeast Denver and have been doing some Clojure on my own for a few months now. On Thu, Feb 5, 2009 at 12:39 PM, chris wrote: > > Are there any existing clojure users in the Denver/Boulder area (other > than me)?. > > Chris > > > --~--~-~--~~~---~--~~ 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 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: Macro defining Macros issue.
Yup, that solves it. A while back the blah# didn't support working in nested back ticks. I hadn't realized they fixed it. Or for that matter added condp :) Thanks! On Feb 5, 1:42 pm, Meikel Brandmeyer wrote: > Hi, > > first things first: what you want to do is available as condp in > the core library of Clojure. That said, here some things I > noticed in your macro. > > You should not capture variables in your macros. That's bad style and > might lead to clashes of names. Clojure provides the foo# notation > to generate new symbols via gensym. This makes a call to gensym > almost always unnecessary. > > Your pair-seq function may be written using the partition function > from the seq-library: (pair-seq the-seq) <=> (partition 2 the-seq). > > One may specify a map between the argument vector and the docstring > of functions and macros. This map becomes part of the metadata. > Here this may be used to get some nice argument names in the > doc output for the generated macro instead of the gensym names. > > Here we go: > > (defmacro def-casemacro [casename test] > "Defines a macro named casename that uses test to compair the > result of > form to each key/result pair" > `(defmacro ~casename > ~(format "Evaluates form and finds the first key/result pair > that %s is > true for, evaluates it and returns the result. Error if none is > found." > (print-str test)) > {:arglists '([~'form ~'key-result-pairs])} > [form# & key-result-pairs#] > (let [key-gen# (gensym "key__") > kr-pairs# (partition 2 key-result-pairs#)] > `(let [~key-gen# ~form#] > (cond > ~@(mapcat (fn [[key# result#]] > `((~'~test ~key-gen# ~key#) ~result#)) kr- > pairs#) > true > (throw (new Error (format ~(str "No %s for key: %s") > ~~(name casename) > (str ~key-gen#) > > This works for me at least for the case (def-casemacro case =). > > Hope this helps. > > Sincerely > Meikel > > smime.p7s > 5KViewDownload --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
assert-args private?
Is there a reason the assert-args macro is private to core? It seems like it would be generally useful. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Seattle Clojurians
I realize this comes a day late since the meeting just happened, but after seeing all these local group threads, I thought I'd mention that the Seattle Functional Group meets every month or so at various locations around Seattle: SeaFunc is Seattle. SeaFunc is functional. Functional language. Functional programming. We shall attempt to adjust your software, as there is something wrong. You're in a C funk. Get out of your C funk. [...] Anyone interested in the application, extension or construction of advanced programming languages - functional or not - is encouraged to come. We've been meeting every several weeks since June 2004. A typical showing is 6-10 people. If you think there must be more to life than C++, Java, and C#, please join us! We met last night. I was the only Clojure person there, (out of 8) but the folks there were pretty interested in it. Would be great to have some more people representing next time. http://tech.groups.yahoo.com/group/SeaFunc/ -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 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 -~--~~~~--~~--~--~---
Clojure Simulation Redux (more on Clojure Optimization)
For those who are interested in Clojure performance, I've updated my flocking example from earlier, which uses Roland's excellent Processing library. http://github.com/swannodette/clojure-stuff/blob/80035bb3b76c21d39d6f8011e9a27aa1116b/flocking.clj It is twice as fast as the previous version and purely functional, no reusing Java arrays or reusing PVector objects. 1. Use make-arrays wisely and it works well. 2. Do your math in Java (PVector in my case), Clojure's built in vectors just aren't designed for it, which is FINE. 3. Type-hint very very very very agressively. *warn-on-reflection* is a life saver, thanks Rich. It's still a bit slower (2X-3X) than the Processing version, but I prefer the fact that this one is functional over the original, no changing vector objects in place. This pretty much as far as I can see it going down this path, it is pretty much a direct translation of the Java version minus mutation, in the next version I hope to incorporate some of the suggestions in reply to my earlier post (FMM in particular). 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 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: Questions about a Clojure Datalog
Thanks for the pointer to Kodkod - it looks very interesting. I wonder if we aren't talking apples and oranges though. Datalog may be a basic reasoner, but it's a simple recursive query language for data. Can you even get all results out of a SAT solver or do they stop when satisfiable? It's for this query purpose that I envisioned primary use of Datalog, although I can certainly see the utility of more powerful reasoners too. Rich On Feb 5, 12:22 pm, John Fries wrote: > Yes. I can make a strong endorsement for Kodkod, a Java-based relational > model finder.http://alloy.mit.edu/kodkod/ > I used it fairly extensively last year to solve scheduling problems, and > I've corresponded with its creator. > > One problem with Datalog-style reasoners is that, because they want to > guarantee a certain execution time, they give up much of the expressiveness > of relational logic. Instead, Kodkod provides the correct interface to > relational logic, and relies on an underlying SAT solver (such as MiniSat) > to solve the problems in a reasonable amount of time. This has proven to be > a good approach, because SAT solvers have been improving at a tremendous > rate over the last 10 years, and are now blazingly fast. > > Another advantage of Kodkod over, say, FaCT++ or Pellet (which also provide > open-world semantics) is that you are not tied into all the assumptions of > the semantic web (OWL, RDF, XML, etc), which can get pretty clunky when all > you want is an in-memory reasoner. You only have to be reasonably > comfortable with relational logic (e.g. "for all x: Red x") to be able to > use Kodkod. > > The only deficiency I found in Kodkod was that, because the author wanted to > support an audience whose primary language was Java, the user must express > their queries using a Java class-based syntax. But this seems like a > perfect use of Clojure, which could provide a much more natural query > syntax. > > On Thu, Feb 5, 2009 at 4:29 AM, Rich Hickey wrote: > > > On Feb 4, 5:22 pm, John Fries wrote: > > > Guaranteed-termination is very desirable. However, you can have > > guaranteed > > > termination with an open-world assumption just as well. And I think an > > > open-world assumption does a better job of mimicking human reasoning. > > > Do you have a specific reasoner/algorithm in mind? > > > 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 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: My SLIME installation diary
http://bitbucket.org/shoover/clojure-box-swank-clojuremq/src/11bec919b978/hack-repl-hang This might fix it for your windows box. Check this thread: http://groups.google.com/group/clojure/browse_thread/thread/6c195c35ae9a7eb8/29dec28f8e8fafd5?lnk=gst&q=windows+slime+hang#29dec28f8e8fafd5 Chris On Feb 5, 12:07 pm, chris wrote: > I haven't seen a clear argument about the classpath variable one way > or another. I also haven't figured out an elegant way to deal with > it. > > I have no problem running a shell script from a terminal I want to > develop with to setup classpath to be exactly what I expect it to be > on a unix system. On windows, this is a little strange. > > One thing I am certain about is that as my java setup gets more > advanced and I start using more interesting jars and jnilibs, my > classpath and my java.library.path are both going to get more > complex. I am certainly *not* going to repeat my non-trivial > classpath into my .emacs file thus forcing myself to change something > difficult to get correct in the first place in at least two places. > > On windows it appears that java correctly using the path env. variable > to load jni libs. On Mac, it doesn't. One huge improvement would be > that any binary libs, be they jni libs *or* dlls that java finds next > to jars in the classpath are eligible for loading on both systems. > Thus I don't have to setup my java loading system using two completely > unrelated environment variables. Using JOGL and clojure on windows > and mac has brought at lot of the pain of java right to the forefront > in my case. > > Chris > > On Feb 5, 11:21 am, Tom Emerson wrote: > > > On Wed, Feb 4, 2009 at 4:36 PM, chris wrote: > > > [snip] > > > > My slime setup currently fails completely on windows, however. The > > > slime repl never starts; is there a way to get slime to dump all of > > > its communication (both ways, not just sending) to a file? > > > Ditto, I'm still busted on Windows with the latest snaps of > > everything, just as I was a couple of weeks ago. Haven't tried > > installing on my Ubuntu box yet to see if this is indeed windows > > specific. > > > -tree > > > -- > > Tom Emerson > > tremer...@gmail.comhttp://treerex.blogspot.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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
> > I don't argue that this model is better than what you're doing with > Spinoza, but for years (see > http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html > from 1994) I've wanted an object model that explicitly separates > structure from protocol, and since I partially built one in order to > satisfy a need I had in a larger project, I think I'll push ahead with > it a bit to see whether it's worthwhile. Yes this is a good thing, but you get this behavior for free with Clojure's multimethods. For example: (defprotocol clonable) ;; derives ::clonable from ::protocol (defmulti clone dispatch-fn) ;; dispatch-fn -> [::class ::protocol] (defmethod [::my-class ::clonable] ...) In fact, (defprotocol clonable [clone deep-clone ...]) could be a macro that automatically defines all of the base multifns. (protocols object) ;; returns a list of all the protocols an object implements via multimethod reflection This would be easy to add to Spinoza, if you want perhaps we could hash it out and we can add it. Or you can forge out on your own, but I think it's always fun to join forces. 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
(isa? [:spinoza-example-one/circle] [:spinoza/object]) ;; true Just to note, the above shows that protocols could have their own inheritance chain. This is insanely powerful and could be implemented very quickly. --~--~-~--~~~---~--~~ 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 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: Questions about a Clojure Datalog
There is no reason to have just one option. On Thu, Feb 5, 2009 at 3:59 PM, Rich Hickey wrote: > > Thanks for the pointer to Kodkod - it looks very interesting. > > I wonder if we aren't talking apples and oranges though. Datalog may > be a basic reasoner, but it's a simple recursive query language for > data. Can you even get all results out of a SAT solver or do they stop > when satisfiable? > > It's for this query purpose that I envisioned primary use of Datalog, > although I can certainly see the utility of more powerful reasoners > too. > > Rich > > On Feb 5, 12:22 pm, John Fries wrote: > > Yes. I can make a strong endorsement for Kodkod, a Java-based relational > > model finder.http://alloy.mit.edu/kodkod/ > > I used it fairly extensively last year to solve scheduling problems, and > > I've corresponded with its creator. > > > > One problem with Datalog-style reasoners is that, because they want to > > guarantee a certain execution time, they give up much of the > expressiveness > > of relational logic. Instead, Kodkod provides the correct interface to > > relational logic, and relies on an underlying SAT solver (such as > MiniSat) > > to solve the problems in a reasonable amount of time. This has proven to > be > > a good approach, because SAT solvers have been improving at a tremendous > > rate over the last 10 years, and are now blazingly fast. > > > > Another advantage of Kodkod over, say, FaCT++ or Pellet (which also > provide > > open-world semantics) is that you are not tied into all the assumptions > of > > the semantic web (OWL, RDF, XML, etc), which can get pretty clunky when > all > > you want is an in-memory reasoner. You only have to be reasonably > > comfortable with relational logic (e.g. "for all x: Red x") to be able to > > use Kodkod. > > > > The only deficiency I found in Kodkod was that, because the author wanted > to > > support an audience whose primary language was Java, the user must > express > > their queries using a Java class-based syntax. But this seems like a > > perfect use of Clojure, which could provide a much more natural query > > syntax. > > > > On Thu, Feb 5, 2009 at 4:29 AM, Rich Hickey > wrote: > > > > > On Feb 4, 5:22 pm, John Fries wrote: > > > > Guaranteed-termination is very desirable. However, you can have > > > guaranteed > > > > termination with an open-world assumption just as well. And I think > an > > > > open-world assumption does a better job of mimicking human reasoning. > > > > > Do you have a specific reasoner/algorithm in mind? > > > > > 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
On Feb 5, 6:36 am, Laurent PETIT wrote: > Doesn't that sound like multifunctions whose dispatching is tied to the > type ('model') of a 'thing' ? Yes, but see below. > Once again, does'nt this correspond to the introduction of the interface > concept in java ? No. I think the article I linked to clarifies the idea pretty well, but to respond more directly to your question: Java interfaces are a particular way to support protocols at the language level, and I like them, as far as they go. But in order to implement an interface, you must define a class. You don't need to define a class in order to implement a protocol in my scheme (and indeed, in my scheme there are no such things as classes): (make-thing {:models [::thing] :protocols [::thing ::idea] :inits {:name "test-thing1" :number 1}}) The above snippet creates a thing whose model is [::thing] and whose protocol is [::thing ::idea]. That means that this thing has all the data fields defined by the model ::thing, and it responds correctly to protocol functions (that is multifunctions) defined by the protocols ::thing and ::idea. Notice that no class is defined. You simply make a thing and say what models and protocols it implements. You can also update the models and protocols at runtime (more properly: you can create a copy of a thing with different models and protocols). This code does illustrate a fly in the ointment that is the reason I wish for predicate dispatch: suppose that ::thing and ::idea are unrelated protocols. Under the covers, my code creates a relationship between this thing and each of those protocols such that if you call some multimethod "frob" on the thing, Clojure will dispatch to the appropriate method. The fly in the ointment is: what happens if both protocols specialize frob? Then Clojure will complain that it can't tell which method to call. In order to resolve that problem, we must use prefer-method to declare that one protocol or the other is preferred. But what if I want to make another thing: (make-thing {:models [::thing] :protocols [::idea ::thing] :inits {:name "test-thing2" :number 2}}) ...where the order of the protocols expresses my wish to prefer ::idea over ::thing? At present, I can't do this; once prefer-method has said that dispatch prefers ::thing over ::idea, I cannot then create a thing for which dispatch prefers ::idea over ::thing (without also changing the preference for all other things whose protocols include both ::thing and ::idea). With predicate dispatch, I could build a solution to this problem; I haven't yet thought of a way to solve it in the existing Clojure. Apart from this wart, the scheme currently works as intended: you can create objects with arbitrary models and protocols, where the set of fields is determined by all the models, and the set behavior under multifunctions is determined by the set of protocols. Alert readers will notice that it's possible to create contradictory sets of models and protocols, and a complete implementation should implement policies for detecting and correcting that failing; dealing with those issues is on my to-do list. --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
On Feb 5, 3:01 pm, David Nolen wrote: > > I don't argue that this model is better than what you're doing with > > Spinoza, but for years (see > >http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html > > from 1994) I've wanted an object model that explicitly separates > > structure from protocol, and since I partially built one in order to > > satisfy a need I had in a larger project, I think I'll push ahead with > > it a bit to see whether it's worthwhile. > > Yes this is a good thing, but you get this behavior for free with Clojure's > multimethods. Not quite. Your points are well-taken, but don't describe what I'm doing. I'm not looking for a way to statically define protocols in which classes participate. Consider an example similar to the one I gave in my reply to Laurent: (make-thing {:models [::vehicle ::airborne] :protocols [::thing ::idea] :inits {:name "test-thing1" :number 1}}) make-thing returns an instance whose fields are a combination of those defined for ::vehicle and ::airborne, and which participates in the protocols ::thing and ::idea (that is, methods that speciaize on ::thing or on ::idea will operate on this thing). Note that no classes are involved. The thing in question is not an instance of any class (except incidentallly, by virtue of the fact that Clojure's runtime is built on the JVM). I never defined any classes, nor did I wish to. A class definition would have been just an obstacle, not directly relevant to my goal, which was to instantiate an object that reflects these models and participates in these protocols. Without further discussion, I don't know whether our goal are at cross purposes; if not, maybe we can work out a congenial collaboration. Note that I have not objection to classes in principle (and I'm a longtime fan of CLOS), but I have no need of classes, and don't wish to be compelled to use them. My models are analogous to CLOS classes, except that there is no inheritance involved, only accretion. In that respect, models resemble objects in T more than in CLOS. My protocols are roughly analogous to Haskell's typeclasses. A proper collaboration would not result in CLOS for Clojure; it might result in a type-definition and -extension facility that resembles CLOS classes, but with a facility for specifying sets of multimethods that looks a little more like Haskell typeclasses. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Pretty Printer
Is there a pretty printer out there for Clojure anywhere? I'm crying now without one. --~--~-~--~~~---~--~~ 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 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: android app development with clojure
I've managed to get to startup time down from 12 seconds to 7 on the emulator and hope get it below 4 seconds tomorrow. A lot of time is spend in LispReader when the core constants are initialized. I've altered the compiler to emit type specific code for the basic cases, thus bypassing LispReader. Need to learn more about GeneratorAdapter, and need sleep, before I can speedup the loading of, for instance, seq contants. My changes are available at github; http://github.com/remvee/clojure Remco On Wed, Feb 4, 2009 at 5:55 PM, Remco van 't Veer wrote: > Having a lisp to do android app development is definately worth some efford. > Kawa already has some android support in svn trunk but it doesn't seem in a > usable state; my experiments break because a lot of expressions do not seem > to compile AOT. The parts that do compile are very fast on the other hand. > > But if it comes down to app development I would of course prefer clojure > over kawa's schema and scheme over java.. > > I hope to do some tracing to find out what slowing down the startup later > this week and will keep the list in formed. If anybody has any suggestions > please yes pretty please. > > Remco > > On Feb 4, 2009 3:59 PM, "igorrumiha" wrote: > > On Feb 4, 10:12 am, "Remco van 't Veer" wrote: > > Caching Reflector.getMethods,... > > I would also be interested in running Clojure on the Android. I tried > running a "Hello world" application on the emulator but the startup > time od 15 seconds put me off. There is definitely room for > improvement. I don't have much experience in Java (zero would be the > best description) so I don't really know where to start with > profiling. > > I've run the application through the Instrumentation mechanism and the > trace shows me that much of the time is spent in a huge amount of > calls to some character compare methods (something like 20 calls) > (I don't have the trace with me right now so I don't have the exact > numbers and I don't know the exact method name). > > I find this curious when I know that all code is compiled ahead of > time. When I get the chance I will recreate that call graph an upload > it to the files section. > > -- > IgorR > > > --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
map-method
I often need to call a java method on each element in a collection. I didn't find anything on the group, so I wrote a macro. (defmacro map-method [method coll & args] "Calls the given method on each item in the collection." `(map (fn [x#] (. x# ~@(if args (concat (list method) args) (list method ~coll)) --~--~-~--~~~---~--~~ 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 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: Pretty Printer
I'm about half-way through creating one at http://github.com/tomfaulhaber/cl-format/tree/pprint It should be ready in a week or two, depending on how much work and family intrude on my hacking. Any particular features folks are interested in? Tom On Feb 5, 3:59 pm, Jeffrey Straszheim wrote: > Is there a pretty printer out there for Clojure anywhere? I'm crying > now without one. --~--~-~--~~~---~--~~ 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 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: Pretty Printer
I would like it if it could handle sets and hashes well, including nested sets of hashes (relations in Clojure speak). So we'd get something like: #{ { :name "Fred" :department :accounting } { :name "Sally" :department :engineering } { :name "Dinesh" :department :management } } (I hope the indention doesn't get messed up, but you get the idea) I hope you make an easy Jar, I've put off learning git. On Thu, Feb 5, 2009 at 7:38 PM, Tom Faulhaber wrote: > > I'm about half-way through creating one at > http://github.com/tomfaulhaber/cl-format/tree/pprint > > It should be ready in a week or two, depending on how much work and > family intrude on my hacking. > > Any particular features folks are interested in? > > Tom > > On Feb 5, 3:59 pm, Jeffrey Straszheim > wrote: > > Is there a pretty printer out there for Clojure anywhere? I'm crying > > now without one. > > > --~--~-~--~~~---~--~~ 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 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: Pretty Printer
Hello, Really naive questions concerning the features : Will it be able to work on large chunks of code, such as an entire file ? Will it have to run on the runtime of the pretty printed code, or will it be able to pretty print any code given as a String ? How would it handle the case of ncorrect code ? As you may have guess, my questions are related to the more synthetic one : will it make a good candidate for a "formatter" feature for an IDE - clojuredev for example - ? ;-) 2009/2/6 Tom Faulhaber > > I'm about half-way through creating one at > http://github.com/tomfaulhaber/cl-format/tree/pprint > > It should be ready in a week or two, depending on how much work and > family intrude on my hacking. > > Any particular features folks are interested in? > > Tom > > On Feb 5, 3:59 pm, Jeffrey Straszheim > wrote: > > Is there a pretty printer out there for Clojure anywhere? I'm crying > > now without one. > > > -- Cordialement, Laurent PETIT --~--~-~--~~~---~--~~ 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 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: map-method
Would memfn not work for you? http://clojure.org/java_interop On Thu, Feb 5, 2009 at 7:24 PM, kyle smith wrote: > > I often need to call a java method on each element in a collection. I > didn't find anything on the group, so I wrote a macro. > > (defmacro map-method [method coll & args] > "Calls the given method on each item in the collection." > `(map (fn [x#] (. x# ~@(if args > (concat (list method) args) > (list method ~coll)) > > > --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
> > I'm not looking for a way to statically define protocols in which > classes participate. Consider an example similar to the one I gave in > my reply to Laurent: Static defining of anything is just a matter of chose, especially in Clojure. For example in Spinoza you have pose-as which changes the class of an object. The primary purpose of Spinoza is structural inheritance and basic dispatch on type, but I've been thinking about runtime modification and your post gives me a lot of ideas. > (make-thing {:models [::vehicle ::airborne] >:protocols [::thing ::idea] > :inits {:name "test-thing1" :number 1}}) > Something like this would be quite simple to build on top of Spinoza. Also allowing protocols to be defined at class definition time and runtime would work the same way that pose-as works (adopt-protocol obj ::some-protocol ::another-protocol) > Note that no classes are involved. The thing in question is not an > instance of any class (except incidentallly, by virtue of the fact > that Clojure's runtime is built on the JVM). I never defined any > classes, nor did I wish to. A class definition would have been just an > obstacle, not directly relevant to my goal, which was to instantiate > an object that reflects these models and participates in these > protocols. As I'm alluding above, this direction seems prototypal, and I've been thinking about allowing for these kind of behaviors in Spinoza. Of course no collaboration beyond healthy discussion is expected. Thanks for bringing the topic up again :) --~--~-~--~~~---~--~~ 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 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: map-method
Or anonymous function literals? user=> (map #(.length %) ["mary" "had" "a" "little" "lamb"]) (4 3 1 6 4) user=> (map #(.indexOf % (int \a)) ["mary" "had" "a" "little" "lamb"]) (1 1 0 -1 1) On Feb 5, 5:05 pm, Jeffrey Straszheim wrote: > Would memfn not work for you? > > http://clojure.org/java_interop > > On Thu, Feb 5, 2009 at 7:24 PM, kyle smith wrote: > > > I often need to call a java method on each element in a collection. I > > didn't find anything on the group, so I wrote a macro. > > > (defmacro map-method [method coll & args] > > "Calls the given method on each item in the collection." > > `(map (fn [x#] (. x# ~@(if args > > (concat (list method) args) > > (list method ~coll)) --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
> > The fly in the ointment is: what happens if both > protocols specialize frob? Then Clojure will complain that it can't > tell which method to call. In order to resolve that problem, we must > use prefer-method to declare that one protocol or the other is > preferred. > > But what if I want to make another thing: > > (make-thing {:models [::thing] > :protocols [::idea ::thing] > :inits {:name "test-thing2" :number 2}}) > make-thing could tag your thing with a runtime tag and define a prefer on this runtime tag. --~--~-~--~~~---~--~~ 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 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: Pretty Printer
Yup, it will handle all Clojure data types in arbitrary nesting. It will be customizable if you don't like the defaults (though that might not be documented or finalized right away). With the cl-format stuff (and this is a branch of the same project since it shares a bunch of code and I didn't want 3 projects), I have started labeling and checking in labeled jar files for easy download. I will start doing the same with the pretty-print version when it stabilizes a little bit. My algorithm is basically the XP algorithm which is more or less linear on the size of the input. Therefore, it is suitable for pretty printing very large quantities of stuff. Pretty printing operates on structure not on strings. For the simple Clojure case, you'll be able to simply use "read" to pull in forms and then hand them to the pretty printer to format, but reacting to "unreadable" forms will be the enclosing program's problem. The pretty printer will be very useful for formatting code. My current that is to ship it with two built in configurations: one vanilla and one for Clojure code. The latter (which will probably be the default) will be aware of special forms and macros (like defn and defmacro) and macros with "& bodies" and will format them specially. These will be easy enough to extend (for html rendering or colorizing, for instance). The interesting thing in an IDE is that you may want to think more incrementally, though that might not be too hard. Hope that answers your questions! Tom On Feb 5, 4:48 pm, Laurent PETIT wrote: > Hello, > > Really naive questions concerning the features : > > Will it be able to work on large chunks of code, such as an entire file ? > Will it have to run on the runtime of the pretty printed code, or will it be > able to pretty print any code given as a String ? > How would it handle the case of ncorrect code ? > > As you may have guess, my questions are related to the more synthetic one : > will it make a good candidate for a "formatter" feature for an IDE - > clojuredev for example - ? ;-) > > 2009/2/6 Tom Faulhaber > > > > > > > I'm about half-way through creating one at > >http://github.com/tomfaulhaber/cl-format/tree/pprint > > > It should be ready in a week or two, depending on how much work and > > family intrude on my hacking. > > > Any particular features folks are interested in? > > > Tom > > > On Feb 5, 3:59 pm, Jeffrey Straszheim > > wrote: > > > Is there a pretty printer out there for Clojure anywhere? I'm crying > > > now without one. > > -- > Cordialement, > > Laurent PETIT --~--~-~--~~~---~--~~ 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 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: map-method
Of course those would work, but I got sick of typing them over and over. (map-method length ["mary" "had" "a" "little" "lamb"]) (map-method indexOf ["mary" "had" "a" "little" "lamb"] (int \a)) I find typing # and % repetitive, so this is just a little syntactic sugar. --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
On Feb 5, 7:12 pm, David Nolen wrote: > > I'm not looking for a way to statically define protocols in which > > classes participate. Consider an example similar to the one I gave in > > my reply to Laurent: > > Static defining of anything is just a matter of chose, especially in > Clojure. For example in Spinoza you have pose-as which changes the class of > an object. The primary purpose of Spinoza is structural inheritance and > basic dispatch on type, but I've been thinking about runtime modification > and your post gives me a lot of ideas. > > > (make-thing {:models [::vehicle ::airborne] > > :protocols [::thing ::idea] > > :inits {:name "test-thing1" :number 1}}) > > Something like this would be quite simple to build on top of Spinoza. Also > allowing protocols to be defined at class definition time and runtime would > work the same way that pose-as works > > (adopt-protocol obj ::some-protocol ::another-protocol) > > > Note that no classes are involved. The thing in question is not an > > instance of any class (except incidentallly, by virtue of the fact > > that Clojure's runtime is built on the JVM). I never defined any > > classes, nor did I wish to. A class definition would have been just an > > obstacle, not directly relevant to my goal, which was to instantiate > > an object that reflects these models and participates in these > > protocols. > > As I'm alluding above, this direction seems prototypal, and I've been > thinking about allowing for these kind of behaviors in Spinoza. > > Of course no collaboration beyond healthy discussion is expected. Thanks > for bringing the topic up again :) It's not quite the same as the usual prototype-based systems either. Generally, in a protoype-based system you have one of two inheritance schemes: 1. structure and behavior are copied (inherited) from one or more prototypes (or "parents"), as in Javascript or 2. structure is copied from one prototype (the "data parent"); behavior is copied from another (the "behavior parent") as in Self The model/protocol/thing stuff does not use parent objects at all. It collects field specifications from model objects, but no inheritance relationship is established. It uses the protocols to establish multimethod dispatch in the manner of derive, but no delegate object is used. Ruben Kleiman's SK8 system had a prototype-based object model that would have made it easy to implement all the features of the model/ protocol/thing subsystem, but his object system was not typical. It had more in common with frame systems like KEE than with typical class- or prototype-based object models. His object model included per- object configurable inheritance (and per-slot configurable accessors-- in fact, each slot of an object--slot, not value--could itself be an arbitrary object with arbitrary model and protocol). I'm not entirely sure I want to recapitulate the entire SK8 object model for this project, though. :-) There are a few more things I want to get working: 1. you should be able to pass a set of map literals as the models 2. you should be able to pass a set of dynamically computed protocol objects (whatever those turn out to be) as the protocols 3. Given a thing, you should be able to ask it what models it represents and what protocols it implements 4. Given a model and a thing, you should be able to ask whether the thing represents the model 5. Given a protocol and a thing, you should be able to ask whether the thing implements the protocol 6. It should be easy and natural to create models, protocols, and things dynamically and without any static declarations being required. Classes, if they exist at all, should be optional. It should be possible to dynamically create a thing from arbitrary sets of models, protocols, and initial map entries (subject to consistency checks). 7. It should be straightforward to serialize models, protocols, and things (this subsystem is not an end in itself, but a component of a larger project in which it's important that the data objects be amenable to serialization and deserialization, both for storage in nonvolatile repositories and for transmission over communication channels; getting deserialization right for 3,4, and 5 is a problem when 6 is supported) 8. mutually contradictory models or protocols should be detected when used 9. It should be possible to resolve ambiguous dispatch conditions per instance rather than globally (Clojure's derive and prefer-method do not support this, but predicate dispatch would make it easy to do) 10. It should be possible to specialize a multifunction per instance (the CLOS feature is called "eql specializers") Naturally, all these features should come at reasonable cost in terms of performance, complexity, and clarity. It's not clear to me at the moment that Spinoza would make the numbered items easier to do, but it it would, then I should be using it. --~--~-~--~~~
Re: CLJOS -> Spinoza, 3X faster than struct-map ;)
On Feb 5, 7:44 pm, David Nolen wrote: > > The fly in the ointment is: what happens if both > > protocols specialize frob? Then Clojure will complain that it can't > > tell which method to call. In order to resolve that problem, we must > > use prefer-method to declare that one protocol or the other is > > preferred. > > > But what if I want to make another thing: > > > (make-thing {:models [::thing] > > :protocols [::idea ::thing] > > :inits {:name "test-thing2" :number 2}}) > > make-thing could tag your thing with a runtime tag and define a prefer on > this runtime tag. It's not quite that simple. Prefer-method accepts three arguments: a multifunction and two dispatch values. It establishes that the method associated with the first dispatch value is to be preferred over the one associated with the second. When make-thing returns, no method is associated with the tag computed for the new thing; it's a brand new tag for which no defmethod exists. If make-thing calls prefer-method, what tags should it use as arguments? If it calls (prefer-method frob ::idea ::thing) that simply replaces the previous global definition: (prefer-method frob ::thing ::idea) ...clobbering the definition for any previously-existing objects. It could use the newly-computed tag for the thing: (prefer-method frob newly-computed-tag ::thing) ...but that accomplishes nothing. The result is the same as if prefer- method were never called, since no method is defined for the dispatch value of newly-computed-tag. Instead, make-thing would have to find the method that is currently defined for the tag value of ::idea and install it as the method for the tag value newly-computed-tag. Then, the subsytem would have to ensure that if the method on ::idea were ever changed, it also changed the method on newly-computed-tag, but only if no user code had subsequently defined a method for newly-computed-tag. Ick. --~--~-~--~~~---~--~~ 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 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: New York Hadoop User Group, Feb. 10
On Feb 5, 2:12 pm, Vincent Foley wrote: > Do you have slides for those of us who cannot attend? I'll post a link when I finish them. :) But my slides tend to be images, not outlines. I don't think this meetup is recorded. -Stuart Sierra --~--~-~--~~~---~--~~ 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 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: Pretty Printer
Please hurry :) But seriously, that sounds great! On Thu, Feb 5, 2009 at 8:48 PM, Tom Faulhaber wrote: > > Yup, it will handle all Clojure data types in arbitrary nesting. It > will be customizable if you don't like the defaults (though that might > not be documented or finalized right away). > > With the cl-format stuff (and this is a branch of the same project > since it shares a bunch of code and I didn't want 3 projects), I have > started labeling and checking in labeled jar files for easy download. > I will start doing the same with the pretty-print version when it > stabilizes a little bit. > > My algorithm is basically the XP algorithm which is more or less > linear on the size of the input. Therefore, it is suitable for pretty > printing very large quantities of stuff. > > Pretty printing operates on structure not on strings. For the simple > Clojure case, you'll be able to simply use "read" to pull in forms and > then hand them to the pretty printer to format, but reacting to > "unreadable" forms will be the enclosing program's problem. > > The pretty printer will be very useful for formatting code. My current > that is to ship it with two built in configurations: one vanilla and > one for Clojure code. The latter (which will probably be the default) > will be aware of special forms and macros (like defn and defmacro) and > macros with "& bodies" and will format them specially. > > These will be easy enough to extend (for html rendering or colorizing, > for instance). > > The interesting thing in an IDE is that you may want to think more > incrementally, though that might not be too hard. > > Hope that answers your questions! > > Tom > > > > On Feb 5, 4:48 pm, Laurent PETIT wrote: > > Hello, > > > > Really naive questions concerning the features : > > > > Will it be able to work on large chunks of code, such as an entire file ? > > Will it have to run on the runtime of the pretty printed code, or will it > be > > able to pretty print any code given as a String ? > > How would it handle the case of ncorrect code ? > > > > As you may have guess, my questions are related to the more synthetic one > : > > will it make a good candidate for a "formatter" feature for an IDE - > > clojuredev for example - ? ;-) > > > > 2009/2/6 Tom Faulhaber > > > > > > > > > > > > > I'm about half-way through creating one at > > >http://github.com/tomfaulhaber/cl-format/tree/pprint > > > > > It should be ready in a week or two, depending on how much work and > > > family intrude on my hacking. > > > > > Any particular features folks are interested in? > > > > > Tom > > > > > On Feb 5, 3:59 pm, Jeffrey Straszheim > > > wrote: > > > > Is there a pretty printer out there for Clojure anywhere? I'm crying > > > > now without one. > > > > -- > > Cordialement, > > > > Laurent PETIT > > > --~--~-~--~~~---~--~~ 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 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: map-method
Good point, and a good reason for a macro. On Thu, Feb 5, 2009 at 8:50 PM, kyle smith wrote: > > Of course those would work, but I got sick of typing them over and > over. > > (map-method length ["mary" "had" "a" "little" "lamb"]) > (map-method indexOf ["mary" "had" "a" "little" "lamb"] (int \a)) > > I find typing # and % repetitive, so this is just a little syntactic > sugar. > > > --~--~-~--~~~---~--~~ 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 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: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
Vlad, thanks for updating the guide. I've saved the new version. Tim, thanks for the ideas. I've tried both and both work well. It did get me thinking that it would be great to have a way to interrogate an open gui app from the command line, or perhaps, from a separate area in the app itself (say, a special "debugging" tab in the main window). Having a standard way to alter the app while it's running would be some kind of wonderful. If anyone has any ideas on that I'd love to hear them. Thanks again for your help guys. --~--~-~--~~~---~--~~ 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 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: A short guide on how to use NetBeans to create GUI and then use this GUI from clojure available
> It did get me thinking that it would be great to have a way to > interrogate an open gui app from the command line, or perhaps, from a > separate area in the app itself (say, a special "debugging" tab in the > main window). Having a standard way to alter the app while it's > running would be some kind of wonderful. If anyone has any ideas on > that I'd love to hear them. Indeed you can do all those things using a REPL.You can interactively do pretty much anything. You could even embed a REPL into your application with a socket back-door, connect to it and really have fun with your users. Here is a semi-practical example (copy these into your REPL one at a time): (defn add-button "Create a JButton and add it to a Container with an ActionListener" [#^java.awt.Container container, #^String button-label, function] (.add container (doto (javax.swing.JButton. button-label) (.addActionListener (proxy [java.awt.event.ActionListener] [] (actionPerformed [evt] (function evt))) (defn later [function] (java.awt.EventQueue/invokeLater function)) (def frame (javax.swing.JFrame. "inter-app")) (later #(.setVisible frame true)) (later #(add-button frame "greeter" (fn [evt] (println "hello" evt (later #(.pack frame)) (later #(.dispose frame)) Regards, Tim. --~--~-~--~~~---~--~~ 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 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: test-is: is called? [PATCH]
On Jan 6, 10:06 pm, Allen Rohner wrote: > I had to revisit my test stubbing/expectation code after the recent > changes to test-is. The good news is, because of the excellent change > to make "is" a multi-method, the expectation code easily fits into > test-is. The following patch adds a new assertion for is, (is > (called?)) > > ;; creates a stub function, binds it to an existing var and asserts > ;; the stub fn was called the correct number of times. > > (is (called? [[user/foo :times 2 :returns 42] > [user/bar :times 1 :returns 3]] > (user/foo x y z) > (user/bar z))) > > Inside of the called? block, user/foo and user/bar are rebound to stub > functions, and then asserts that each function is called the proper > number of times. Currently, the only two options an expectation takes > are :times and :returns. I expect that more will be needed. > > http://groups.google.com/group/clojure/web/test_is_called.patch > > Allen I noticed this hasn't been merged in. It's starting to cause some inconvenience to me because I have tests in my project that depend on the called? patch. If this still needs work before it's acceptable, let me know and I'll work on it. In the mean time, I'll create a fork on github that contains my patch. Allen --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
Newbie: Trying to defer evaluation of unbound variable arguments until needed with macros
I tried asking about this yesterday, but it seems like I expressed my problem poorly. Anyways, here's another shot. :) I have a little parser library. With its metafunctions, one can create rules that accept tokens and spit out a result or nil if the tokens it receives are invalid. For instance, literal creates a basic literal rule that matches only a token coll that starts with a certain literal token. conc takes many rule functions and creates a new rule function that slurps up the results of its subrules in order; if any of its subrules fail, it fails too. alt takes many rules and creates a new rule that tries each of its subrules; it returns the results of the first one that succeeds. This pattern has been going great for what I need for the past month, until I needed to create a parser for a language containing rules that referred to each other. Specifically, a language where a "value" can be 0, 1, or an "array"—and "arrays" can contain two values. Whenever I've tried to do this, I've always encountered unbound variable errors for the value variable. So therefore, I need a way to defer evaluation of conc and alt's arguments so that their arguments are not called until needed. I want to make the code below possible with as little API change as possible, and the only way I can think of is by changing conc and alt to macros. I'm not good with macros, so I have little idea how to do this as elegantly as possible. Here's the code below: (defn conc [& subrules] (fn [tokens] (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens), products []] (if (nil? subrule-queue) [products remaining-tokens] (let [[subrule-products subrule-remainder :as subrule-result] ((first subrule-queue) remaining-tokens)] (when-not (nil? subrule-result) (recur (rest subrule-queue) subrule-remainder (conj products subrule-products (defn alt [& subrules] (fn [tokens] (some #(% tokens) subrules))) (defn literal [literal-token] (fn [tokens] (let [first-token (first tokens), remainder (rest tokens)] (when (= first-token literal-token) [first-token remainder] ; Here's the language rules below, defined in terms of literal, conc, and alt. (def on (literal \1)) (def off (literal \0)) (def bit (alt on off)) ; (bit (seq "starst")) -> (bit (seq "1, 0")) -> [\1 (\, \space \0)] (def array-start (literal \[)) (def array-end (literal \])) (def array-sep (literal \,)) ; (array-start (seq "[1, 0]")) -> [\[ (\1 \, \0 \])] (declare value) (def array (conc array-start value array-sep value array-end)) (def value (alt array bit)) ; (array (seq "0")) -> nil ; (bit (seq "0")) -> [\0 nil] ; (value (seq "0")) -> [\0 nil] ; (array (seq "[0,0]")) -> [[\[ \0 \, \0 \]] nil] ; (bit (seq "[0,0]")) -> nil ; (value (seq "[0,0]")) -> [[\[ \0 \, \0 \]] nil] ; (array (seq "[0,[1,0]]")) -> [[\[ \0 \, [\[ \q \, \0 \]] \]] nil] ; (bit (seq "[0,[1,0]]")) -> nil ; (value (seq "[0,[1,0]]")) -> [[\[ \0 \, [\[ \q \, \0 \]] \]] nil] --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
> > (prefer-method frob ::idea ::thing) > (prefer-method [::runtime-tag1 ::idea] [::runtime-tag1 ::thing]) (prefer-method [::runtime-tag2 ::thing] [::runtime-tag2 ::idea]) Provide a dispatch fn that extracts the runtime tag. --~--~-~--~~~---~--~~ 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 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: CLJOS -> Spinoza, 3X faster than struct-map ;)
Have thoughts about this, will have to collect them, will reply soon. On Thu, Feb 5, 2009 at 9:06 PM, mikel wrote: > > > > On Feb 5, 7:12 pm, David Nolen wrote: > > > I'm not looking for a way to statically define protocols in which > > > classes participate. Consider an example similar to the one I gave in > > > my reply to Laurent: > > > > Static defining of anything is just a matter of chose, especially in > > Clojure. For example in Spinoza you have pose-as which changes the class > of > > an object. The primary purpose of Spinoza is structural inheritance and > > basic dispatch on type, but I've been thinking about runtime modification > > and your post gives me a lot of ideas. > > > > > (make-thing {:models [::vehicle ::airborne] > > >:protocols [::thing ::idea] > > > :inits {:name "test-thing1" :number 1}}) > > > > Something like this would be quite simple to build on top of Spinoza. > Also > > allowing protocols to be defined at class definition time and runtime > would > > work the same way that pose-as works > > > > (adopt-protocol obj ::some-protocol ::another-protocol) > > > > > Note that no classes are involved. The thing in question is not an > > > instance of any class (except incidentallly, by virtue of the fact > > > that Clojure's runtime is built on the JVM). I never defined any > > > classes, nor did I wish to. A class definition would have been just an > > > obstacle, not directly relevant to my goal, which was to instantiate > > > an object that reflects these models and participates in these > > > protocols. > > > > As I'm alluding above, this direction seems prototypal, and I've been > > thinking about allowing for these kind of behaviors in Spinoza. > > > > Of course no collaboration beyond healthy discussion is expected. Thanks > > for bringing the topic up again :) > > It's not quite the same as the usual prototype-based systems either. > Generally, in a protoype-based system you have one of two inheritance > schemes: > > 1. structure and behavior are copied (inherited) from one or more > prototypes (or "parents"), as in Javascript > > or > > 2. structure is copied from one prototype (the "data parent"); > behavior is copied from another (the "behavior parent") as in Self > > The model/protocol/thing stuff does not use parent objects at all. It > collects field specifications from model objects, but no inheritance > relationship is established. It uses the protocols to establish > multimethod dispatch in the manner of derive, but no delegate object > is used. > > Ruben Kleiman's SK8 system had a prototype-based object model that > would have made it easy to implement all the features of the model/ > protocol/thing subsystem, but his object system was not typical. It > had more in common with frame systems like KEE than with typical > class- or prototype-based object models. His object model included per- > object configurable inheritance (and per-slot configurable accessors-- > in fact, each slot of an object--slot, not value--could itself be an > arbitrary object with arbitrary model and protocol). I'm not entirely > sure I want to recapitulate the entire SK8 object model for this > project, though. :-) > > There are a few more things I want to get working: > > 1. you should be able to pass a set of map literals as the models > > 2. you should be able to pass a set of dynamically computed protocol > objects (whatever those turn out to be) as the protocols > > 3. Given a thing, you should be able to ask it what models it > represents and what protocols it implements > > 4. Given a model and a thing, you should be able to ask whether the > thing represents the model > > 5. Given a protocol and a thing, you should be able to ask whether the > thing implements the protocol > > 6. It should be easy and natural to create models, protocols, and > things dynamically and without any static declarations being required. > Classes, if they exist at all, should be optional. It should be > possible to dynamically create a thing from arbitrary sets of models, > protocols, and initial map entries (subject to consistency checks). > > 7. It should be straightforward to serialize models, protocols, and > things (this subsystem is not an end in itself, but a component of a > larger project in which it's important that the data objects be > amenable to serialization and deserialization, both for storage in > nonvolatile repositories and for transmission over communication > channels; getting deserialization right for 3,4, and 5 is a problem > when 6 is supported) > > 8. mutually contradictory models or protocols should be detected when > used > > 9. It should be possible to resolve ambiguous dispatch conditions per > instance rather than globally (Clojure's derive and prefer-method do > not support this, but predicate dispatch would make it easy to do) > > 10. It should be possible to specialize a multifunction per instance > (the CLOS feature is called
Question about clojure.lang.RT.load() code
Hello, Is there a reason for the test for (classURL==null) being one of the condition to try loading the class, in the code of RT.load() (see below the line with the comment at its end) ? I think the code will work because there is a catch clause in loadClassForName, but I can't see any reason to try to call loadClassForName() when we know we haven't found the class file as a resource ? Thanks in advance, -- Laurent static public void load(String scriptbase, boolean failIfNotFound) throws Exception{ String classfile = scriptbase + LOADER_SUFFIX + ".class"; String cljfile = scriptbase + ".clj"; URL classURL = baseLoader().getResource(classfile); URL cljURL = baseLoader().getResource(cljfile); boolean loaded = false; if((classURL != null && (cljURL == null || lastModified(classURL, classfile) > lastModified(cljURL, cljfile))) || classURL == null) // <<< Why enter the if clause if classURL is null ? { try { Var.pushThreadBindings( RT.map(CURRENT_NS, CURRENT_NS.get(), WARN_ON_REFLECTION, WARN_ON_REFLECTION.get())); loaded = (loadClassForName(scriptbase.replace('/','.') + LOADER_SUFFIX) != null); } finally { Var.popThreadBindings(); } } if(!loaded && cljURL != null) { if (booleanCast(Compiler.COMPILE_FILES.get())) compile(cljfile); else loadResourceScript(RT.class, cljfile); } else if(!loaded && failIfNotFound) throw new FileNotFoundException(String.format("Could not locate %s or %s on classpath: ", classfile, cljfile)); } --~--~-~--~~~---~--~~ 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 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: New York Hadoop User Group, Feb. 10
On Fri, Feb 6, 2009 at 03:05, Stuart Sierra wrote: > On Feb 5, 2:12 pm, Vincent Foley wrote: >> Do you have slides for those of us who cannot attend? > > I'll post a link when I finish them. :) But my slides tend to be > images, not outlines. I don't think this meetup is recorded. That's a shame. Do you have any links, docs, whatever to show what you have done with this, what can be done, how, etc.? Holger --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---