#clojure logs

2010-06-12

00:21timmorganIs there an IRC channel for VimClojure?
00:23quotemstr_How does the performance of Clojure (after the compiler and the JVM have had their way) compare with what SBCL outputs?
01:05quotemstrHrm.
01:06quotemstrIs there any way to get the size of clojure below 1.8 megs?
01:07KirinDave1.8megs?
01:07KirinDaveDang dog it is small for you.
01:07quotemstr-rw-r--r--@ 2 root admin 1.8M Jun 11 22:33 clojure.jar
01:08quotemstrI wish there were a tree-shaker. :-)
01:08KirinDavehttp://idisk.me.com/dfayram/Public/Pictures/Skitch/sizequeen-20100611-220709.png
01:08quotemstrKirinDave: I'm idly evaluating the feasibility of writing the next version of a project of mine in clojure with JamVM; I have a size budget of about 600k.
01:08KirinDaveGood luck with that.
01:08KirinDaveI doubt it's happening.
01:08quotemstrYeah, figured.
01:09quotemstrIt's a shame.
01:09KirinDaveYeah, but you have CL so..
01:09quotemstr?
01:09quotemstrWhat do you mean?
01:10KirinDaveI thought you said you were using a common lisp for the other version of your project.
01:10KirinDaveAnd those can get pretty dang small
01:11quotemstrNo, I'm using a custom Lisp-1 which is mostly a CL workalike.
01:11quotemstrIt has setq, setf, let* and friends, but like Clojure, supports destructuring everywhere.
01:12quotemstrECL is about the same size as Clojure.
01:12zakwilsonThere used to be a clojure-slim.jar that was something like 600k
01:14zakwilson520K clojure-slim.jar <-- this was pre-1.0, I think.
01:14quotemstrAh.
01:15quotemstrIt still seems like the right solution is a tree shaker though.
01:16quotemstrAmazing! There is no Java tree shaker available.
01:17zakwilsonSeems like there still ought to be a way to build a lighter clojure.jar.
01:20zakwilsonA tree shaker does sound like the right answer, but I haven't heard of those being used with anything but proprietary CL implementations. I think too few people care about size these days, though the popularity of mobile systems may change that.
01:30quotemstrAha.
01:30quotemstrApparently proguard is a Java tree shaker.
01:30quotemstrExcept that Clojure seems to always load all classes in a namespace, at least according to a mailing list message.
01:59vIkSiThey all
02:00vIkSiTwhat would be the best way to search a vector of maps?
02:00vIkSiT(for the value of a particular key)
02:21Twey,((first (filter (comp not nil?) (map 'e ['{a b c d} '{e f g h}])))
02:21clojurebotEOF while reading
02:21Twey,(first (filter (comp not nil?) (map 'e ['{a b c d} '{e f g h}])))
02:21clojurebotf
02:21TweyvIkSiT: ^ that's one way…
02:23vIkSiTTwey, ah thanks - that looks promising.
02:23vIkSiTwhat does the map 'e part doing here?
02:23TweyMaps 'e over the vector
02:23Twey,('e '{e f g h})
02:23clojurebotf
02:24vIkSiTaah
02:24vIkSiTgotcha
02:24vIkSiTi wonder if there's a way to do this for values
02:24vIkSiTlets say you wanted to check for d
02:24TweyWhen used as a function, it's a shortcut for ‘get’
02:25TweyWell, that's not really what maps are for
02:26Twey,(seq '{e f g h})
02:26clojurebot([e f] [g h])
02:27vIkSiTTwey, yes indeed. so the problem i'm trying to solve is - i've got a vector of maps right now - and was wondering what the best way to search for a value would be
02:27vIkSiTI could perhaps shift to a pair of some sort
02:27Twey,(filter (comp (partial (= 'h)) second) (seq '{e f g h}))
02:27clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$partial
02:27TweyAck
02:27vIkSiTpartial needs 2 args surely?
02:28Twey,(filter (comp (partial = 'h) second) (seq '{e f g h}))
02:28clojurebot([g h])
02:28vIkSiTahh
02:28TweyYeah, I was expecting sections ;)
02:28TweyBut that's a horrible thing to do
02:28vIkSiTindeed
02:28TweyI suspect you should be using a different data structure
02:28vIkSiTwhat do you recommend as a better data structure?
02:29TweyFirstly you should merge your vector of maps into a single map
02:29vIkSiTmaybe use pairs.. and map a second on that, and do a find on that
02:29vIkSiTTwey, there's a problem with that
02:29TweyThat's exactly what we've just done :þ
02:29vIkSiTTwey, haha yes, i just realized
02:30vIkSiTas i was saying..
02:30vIkSiTi need to have duplicate keys
02:30vIkSiTin the structure
02:30TweyYou could have lists as the keys
02:31vIkSiThmm
02:31Twey(seqs, sorry)
02:31Twey(vectors, in fact, most like)
02:32vIkSiThmm how exactly do you mean?
02:33Twey'[{k1 v1 k2 v2} {k1 v3 k3 v4}] becomes '{k1 [v1 v3] k2 [v2] k3 [v4]}
02:33TweyOr '[{k1 v1 k2 v2} {k1 v3 k3 v4}] becomes '{k1 [v1 v3] k2 [v2 nil] k3 [nil v4]} if you need to preserve ordering
02:34vIkSiT... was just going to say that
02:34vIkSiTordering yeap
02:34vIkSiThmm
02:36cgrandTwey & vIkSiT: for your 1st pb, (some 'e ['{a b c d} '{e f g h}]) is equivalent to (first (filter (comp not nil?) (map 'e ['{a b c d} '{e f g h}])))
02:37cgrand,(for [m ['{a b c d} '{e f g h}] [k v] m :when (= v 'd)] k)
02:37clojurebot(c)
02:37TweyAh, thanks
02:37vIkSiTcgrand, ah interesting
02:56jColeChangedHi, I'm just starting to try out incanter and ran into some trouble. I tried to load the modules using (use '(incanter core stats charts io)), but this failed. instead I had to use something more along the lines of (use `incanter.core). Any idea as to what I did wrong?
02:58jColeChanged; note those were not the exact commands, but just the general idea behind the commands..
03:33cgrandjColeChanged: try vectors instead of list
03:34cgrand(use '[incanter core stats charts io])
03:35jColeChangedThat gives me the same exception I had previously.
03:36jColeChangedIt can't find core__init.class or core.clj on the class path.
06:51MrHusHi is was wondering if anyone could give me some feedback on a Lib I've been working on.
06:51MrHushttp://github.com/MrHus/Hadouken
06:51MrHusIts a template system it allows you to create a file
06:52MrHuswith clojure code in it and
06:52MrHusget the same file back but with the expressions changed with their values.
09:41hiredmanping?
09:41clojurebotPONG!
10:00silveenif you have a program slip up in different files but all in the same ns, and most of them kinda depend on code in the other files - anyway you can circumvent/fix that?
10:00silveenwithout putting it all in one file again
10:13hoecksilveen: yes, use load
10:13hoeck,(doc load)
10:13clojurebot"([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."
10:21silveenyou mean I need to add and maintain that line in every single file?
10:21silveenjesus
10:21silveenno wait, just had to rearrange some
10:27technomancykeep each namespace in a single file
10:27hoecksilveen: no, put the loads your main file, where you have your ns deklaration
10:27silveenyeah I fixed it
11:19edbondwhere to find all possible versions of clojure for leiningen?
11:23TimMcedbond: Are you asking about what dependency lines are possible for project.clj files?
11:25edbondyes
11:26TimMcI'm still figuring that out myself, but I generally just go to clojars.org and search.
11:26TimMcI'm a beginner myself, though.
11:33edbondTimMc: try to search clojure and you get a lot of mismatches )
11:36edbondI have org.clojure/clojure "1.2.0-master-SNAPSHOT" and org.clojure/clojure-contrib "1.2.0-master-SNAPSHOT"
11:37edbondand get a nonsense error from lein deps
11:37technomancyedbond: there's no "-master" in the proper contrib version
11:38edbondthanks, how can I figure this out?
11:38technomancyedbond: they're listed here: http://build.clojure.org/snapshots/org/clojure/clojure-contrib/
11:38edbondwhere is 'gem search'-like functionality?
11:39raekthe versions avaiable can be found at http://build.clojure.org/releases/ and http://build.clojure.org/snapshots/
11:39technomancyfor everything but clojure and contrib you can search clojars.org
11:39technomancybut that search should be expanded to include clojure and contrib
11:40edbondthanks a lot
11:50technomancyedbond: see also the lein-search plugin: http://blog.licenser.net/2010/04/20/leiningen-the-clojure-build-tool
12:00edbondtechnomancy: cool, thanks.
12:21dmostechnomancy: Cheers. There's a bug in starter kit, when starting from a custom location (ie. not .emacs.d). In init.el the (require 'starter-kit-elpa) should come after the triple setq calls, because the require call downloads from elpa already and misplaces the downloads.
12:22dmostechnomancy: Do you want a patch for this? It's just a moved line
12:23dmostechnomancy: ie. from http://github.com/technomancy/emacs-starter-kit/blob/master/init.el#L29
12:23dmostechnomancy: to http://github.com/technomancy/emacs-starter-kit/blob/master/init.el#L36
12:36hamzaGuys, I have two types of objects living in two seperate namespaces problem is they both need to respond to a methon call such as draw when i define draw as multi method in one namespace i can not defmethod in the other space if I define defmulti multi multople times one shadows the other any idead how can i work around this?
12:47raekhamza: you need to use the the one namespace from the other
12:47raekor, factor out the defmulti definition to a separate file
12:47raekand let the implenetation namespaces use that one
12:48technomancydmos: cool; I'll take care of it.
12:49dmostechnomancy: actually, the bug seems to be more subtle. I think that also the call to (package-initialize) has to move down, but when I do this, then emacs -q -l init.el fails and says:
12:49raekexample: assuming you have to implementations in my-ns.foo.impl-a and my-ns.foo.impl-b
12:49raekmake a namespace my-ns.foo.common
12:49dmostechnomancy: File exists: yada yada elpa/idle-hightlight....
12:49raekthe common namespace would contain the defmulti
12:50raekand the implementation namespaces the defmethods
12:50raekthose need to (use) my-ns.foo.common as well
12:50dmostechnomancy: seems like it gets confused about the state of it's packages (they should be installed from a prior run).
12:50raekhope this answers the question... :)
12:51KirinDaveHum
12:51KirinDaveI got some shock from saying Clojure is, at its heart, an OO language in the same way that common lisp is an OO language.
12:51KirinDaveIs that conclusion so surprising?
12:51OForerohello
12:52OForeroI am trying to use a record in a let
12:52KirinDaveOForero: A defrecord or a record?
12:52OForeroand it fails with Illegalargument exception
12:52OForerodefrecord
12:53KirinDaveOForero: Could you show an abbreviated example of what you're trying to do?
12:53KirinDaveIn general, (defrecord ...) is a declarative expression that should appear at the root of your module and shouldn't be inside other forms save for conditional evaluation
12:53OForeroyes ... give me a sec
12:55OForerohttp://paste.pocoo.org/show/224575/
12:57KirinDaveOForero: http://idisk.me.com/dfayram/Public/Pictures/Skitch/Terminal_%E2%80%94_java_%E2%80%94_Homebrew_%E2%80%94_ttys000_%E2%80%94_80%C3%9724-20100612-095605.png
12:58KirinDaveOForero: Probably your testing code is what's failing.
13:02KirinDaveOForero: There is always a small chance your clojure snapshot is out of date. When using defrecord or deftype and experiencing weird behavior, try grabbing the latest 1.2 snapshot.
13:02OForeroI will do that
13:03OForeroI was suspecting something like that
13:03KirinDaveI had a thing where constructors for defrecord worked but deftype didn't :)
13:03OForerook
13:04danlarkinI asked a few days ago, but I think everyone was asleep,
13:05danlarkinis there anything besides being inside an uncommitted transaction that would prevent an agent from starting immediately on a function sent to it?
13:05rpdillonnot sure, what's the behavior of an agent if it encounters an exeception? Doesn't it have to clear the error state first?
13:06danlarkinit's not encountering an exception
13:06rpdillonok then =)
13:06rpdillonnothing else really comes to mind
13:06danlarkinif, instead of sending to an agent, I just run the form in a future, it executes immediately
13:06KirinDavedanlarkin: Is it a long delay?
13:06KirinDaveLike infinite?
13:07danlarkinso I don't think it's anything to do with the form
13:07KirinDaveor a small delay?
13:07hamzaraek: thx, got it.
13:07dmostechnomancy: mercifully, my internet connection seems to be reestablished *sigh*
13:07danlarkinKirinDave: well here's the thing... it's based on when an unrelated (should be unrelated, at least) state changes
13:08datkaI'm trying out leiningen again today, but whenever I try to do anything I get an error about clojure.java.io has anyone else encountered this?
13:08KirinDaveHuh. Id bring that before Rich or Stuart. That sounds funky.
13:08danlarkinalmost certainly it is programmer error, but I just can't seem to track it down
13:08datkaI just tried blowing away my ~/.m2, but no help
13:09dmostechnomancy: ok, the problem seems to be that in package.el is not only a defvar for package-user-dir but also for package-directory-list. Although it uses package-user-dir, it obviously does so on require, which is not really all that helpful...
13:10wdouglasI'm having issues importing a java class, I'm not terribly familiar with how jar structure should look but I'm able to import a sibling class in the same jar. The class I'm trying to import has a name.class and a name$VERSIONS.class file but I'm not sure what different that makes.
13:11jonasen(apply max (range 100000000)) fails with a OutOfMemoryError in the prim-branch. No problem on master-branch. Any ideas?
13:15OForerolein deps => should upgrade the snapshots? or not?
13:15datkaIt should, assuming it doesn't crash out before that point
13:18OForerodoes lein has a command to force the check for new snapshots?
13:20dnolenOForero: it checks build from hudson from what I understand. so yes it checks for the latest build as long you're saying 1.2.0-master-SNAPSHOT in your dependencies, 1.2.0-SNAPSHOT for contrib
13:20tomojbut it will only check every so often, I believe?
13:20OForerook
13:20OForeroclojure-1.2.0-master-20100607.150309-85.jar
13:20datkaIIRC it does it the same way as maven internally
13:21OForerois that the latest?
13:22OForerowrong repo
13:24datkais it possible that there's something wrong with the jar that lein self-install builds / downloads? it appears to be an uberjar, but I don't see anything for clojure.java
13:27tomojclojure.java?
13:27clojurebotant clean and rebuild contrib
13:39dnolendatka: did you install lein 1.1.0 ?
13:43datkadnolen: yeah, I grabbed the latest stable script from the readme
13:46dnolendatka: and when does that error occur on what command? what's your project.clj look like?
13:47datkadnolen: actually, I just wiped out my the command and my ~/.m2 and tried again and it seems to be working
13:47datkait's currently downloading the internet. (go maven)
13:47dnolenjonasen: I'm sure the heap memory profile has changed some what with statics. Plus that's a silly thing to do anyway, use (reduce max (range 10000000))
13:49tomojshould be the same thing
13:49tomojor nearly so
13:50tomoj(defn max ... ([x y & more] (reduce max (max x y) more)))
13:50tomojthough (reduce max (range 10000000)) works fine, strange
13:51tomojmaybe something is holding the head?
13:52dnolentomoj: look at the definition of apply.
13:55tomojoh, bizarre
13:55OForeroIs there a way to clean a REPL without having to restart the lein
13:55OForeroswank?
13:55clojurebotswank is try the readme. seriously.
13:55tomojapply hasn't always been this way, has it?
13:57tomojseems it's done that for quite a long time at least
13:58OForeroI think defrecord generate private functions?
14:04tomojafaik it only generates one function, which is public
14:05OForeroprobably changed ... that is why my test does not work
14:05OForerothe constructor is not available
14:06tomojoh, hmm
14:07tomojlooks like you're right
14:07tomojthe defn for the constructor fn is commented out
14:08tomojyou can use the class, though, (Foo. ..)
14:08tomojbut that means you have to import it, I guess?
14:37ihodesHas anyone found an ipad app/editor that handles clojure syntax highlighting? I'd love one... And a decent ssh app, too…
14:41tomojplan to edit blind, or to hook the ipad up to a remote clojure?
14:48quotemstrihodes: can you run Emacs on the iPad? :-P
14:49quotemstrtomoj: I thought jailbroken iGadgets could run Java programs via JamVM.
14:49quotemstr(Albeit very slowly.)
14:52tomojcool
14:53quotemstrHowever, for iPad users, I recommend a journey to Cupertino to unmake the iPAd in the fires of Mount Doom.
14:54quotemstrOn another note, can someone point me to an example project that makes good use of agents? I have a good sense of how they work, but I'd like to see how they're generally used in production.
14:57a_strange_guythere are many ways to use Agents
14:58a_strange_guyyou can look at the ants demo (ants.clj) to see them used like Actors
15:00a_strange_guybut most people use them for centralized write-only stuff like logging etc.
15:03LauJensenHey everybody
15:04LajlaLauJensen, hai
15:09quotemstra_strange_guy: Thanks.
15:10danlarkinGah! I figured it out! actions dispatched to agents from /inside/ another agent don't run until the first agent has finished?!
15:10danlarkinwhattttttttttt
15:10quotemstrSo io! is just do with an assert?
15:11Lajla,`(quotemstr ~@(0 1 2 3 4 5 6))
15:11clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
15:11LajlaAhh
15:11quotemstr?
15:11Lajla,`(qutoemstr ~@(range 0 10))
15:11clojurebot(sandbox/qutoemstr 0 1 2 3 4 5 6 7 8 9)
15:11LajlaIndeed
15:12quotemstrHuh?
15:12quotemstrIs that some kind of Zen answer to my question?
15:12Lajlaquotemstr, no, just wondering how splicing interprets it.
15:14a_strange_guyquotemstr: That IPad LotR reference is worthy of bash.org
15:15quotemstra_strange_guy: Heh. :)
15:16quotemstra_strange_guy: So ants is using agents in sort of a CPS setup -- (defun behave [] ... (dosync (when running (send-off *agent* #'behave))))
15:16a_strange_guyyeah
15:17a_strange_guynotice that it checks a variable to see if it should keep running
15:17LajlaI never got why CPS is upposedly some kind of ultra-advanced paradigm for the hardcore but gotoes are bad.
15:17quotemstra_strange_guy: Sure; it's not very actor-like though. From what I can tell, the ants all talk to a shared data structure instead of communicating with messages.
15:17quotemstrLajla: It really isn't. I don't like CPS myself.
15:17quotemstrLajla: Also, gotos aren't always bad.
15:18quotemstrLajla: With experience, you learn when to ignore rules of thumb.
15:18quotemstrLajla: In fact, I *loathe* Scheme because of the extensive use of call/cc, which makes my brain hurt.
15:18quotemstrNow, it's possible I'm just stupid, but it's more likely that call/cc just leads to spaghetti.
15:18a_strange_guyCPS is actually really simple
15:19a_strange_guyand has nothing to do with call/cc
15:19Lajlaquotemstr, call/cc is quite understandable.
15:19LajlaBut I guess it's best understood in terms of macros.
15:19LajlaWhich abstract its used for you.
15:19Lajlaa_strange_guy, 'nothing' is an overstatement, but I get your point.
15:20rpdillonquick question: does clojure have any serializable data structures that *don't* have non-serializable components that prevent them from being sent over the wire?
15:21a_strange_guysorted maps and sets are Serializable
15:21rpdillonvectors, lists and sets all are effectively not serializable. I have been able to use maps, though, but that doesn't fit my current need.
15:21quotemstra_strange_guy: I was making a larger point about how powerful techniques often lead to obfuscated programs.
15:21quotemstra_strange_guy: But that the solution is to use them with moderation, not ban power outright.
15:22quotemstra_strange_guy: As for CPS --- sure, it's simple in itself. But IME, it leads to programs being broken into small chunks, and it's not always immediately obvious how control flows to and from a given chunk.
15:22a_strange_guyquotemstr: the funny thing is that I am now using CPS to solve a normally very difficult problem
15:22quotemstra_strange_guy: Do tell.
15:23a_strange_guyactors in Scala, and the question from a Student was "How can I build a Updatable actor"
15:24a_strange_guythe answer is to let it execute a function that never returns
15:24a_strange_guya continuation
15:26a_strange_guyso the actor must recieve an 'update message, which contains a function that the actor will execute
15:27a_strange_guyCPS is just a technique, not a language feature
15:28quotemstra_strange_guy: Well, you need first class functions. :-)
15:29a_strange_guyyeah, I refuse to respect languages that dont have them ;-)
15:35anonymouse89I'm trying to translate some common lisp to clojure (but don't know lisp). I'm getting a little tripped up by what this statement is doing: (defmethod initialize-instance :after ((foo class-name) &rest args) ...
15:36anonymouse89^^(in common lisp btw)
15:37quotemstrLisp as she is spoke!
15:37quotemstr,g english as she is spoke
15:37clojurebotjava.lang.Exception: Unable to resolve symbol: g in this context
15:37quotemstranonymouse89: You really have to understand CLOS to understand what defmethod does, especially with a non-default combinator.
15:39a_strange_guythis adds the code that comes inside this defmethod form as post-initialialization for all subclasses of class-name
15:39a_strange_guysemantically speaking
15:40a_strange_guyi dont think that you can translate this to any language except Commpn Lisp
15:40a_strange_guyCLOS is just too powerfull
15:40anonymouse89I guess I'm wondering before I dive into CLOS and all that what the clojure way to do this would be
15:40mebaran151anybody here know about JTextPane and styling its contents
15:40quotemstranonymouse89: What package are you trying to port?
15:41mebaran151I want to build a little proof of concept text editor for fun
15:41a_strange_guyyou just don't do this in clojure
15:41quotemstranonymouse89: Maybe there's a Java library that already exists that you can use instead.
15:41quotemstra_strange_guy: What, write an editor? If you can write an editor in elisp, you can write one in Clojure. :)
15:41mebaran151maybe something that would even edit clojure code, like crippled dr. scheme
15:42a_strange_guyit was adressed to the statement about CLOS
15:42quotemstrmebaran151: Questions that begin with "anyone" usually aren't worth the time it takes to transmit them. Ask your real question.
15:42quotemstra_strange_guy: Ah, okay.
15:42anonymouse89I'm translating a quantum gate simulator
15:42quotemstrScratch that then.
15:42a_strange_guyyeah
15:43mebaran151basically, I'd like to know if there's a good write up the various Java Swing Text Components, particular how you'd write a little editor with Syntax Highlighting
15:43a_strange_guytoo much of a paradigm shift
15:43anonymouse89not as scary as it sounds (if it sounded scary)...mainly a lot of matrix operations
15:43mebaran151anonymouse89: if it's a bunch of matrix stuff, you might want to check out Incanter
15:43quotemstranonymouse89: In order to port CLOS-heavy code, you need to know CLOS. The gist of what that does is define a constructor.
15:44quotemstrmebaran151: Nifty.
15:44quotemstrmebaran151: Not quite* as nifty as, say, CGAL, but nifty. :)
15:45a_strange_guyanonymouse89: actually it extends all constuctors of things that subclass 'class-name'
15:45anonymouse89a_strange_guy: hmm.. In this case it might be overkill then. I don't think that class is ever subclassed
15:46quotemstranonymouse89: In general, CLOS is usually overkill. :-P
15:46mebaran151quotemstr: what's CGAL?
15:47anonymouse89so that class could become a struct that I define default initialization values for?
15:47quotemstrmebaran151: A C++ template library for computational geometry.
15:47mebaran151ah, that sounds pretty neat
15:47quotemstrmebaran151: Damn fast too, because the library is instantiated using exactly the correct data types.
15:47anonymouse89quotemstr: that could be used in clojure or you were suggesting I use c++?
15:48mebaran151the little intensive math coding I did for a trading shop was all C and asm, so I missed out on all the good stuff
15:48quotemstranonymouse89: Neither -- just commenting about geometry libraries in general.
15:48mebaran151and Incanter is far better than R in my opinion
15:48mebaran151which was the previous mainstay I had to fight
15:49anonymouse89Incanter will help me out a lot
15:50mebaran151CLOS code can be pretty hard to read
15:50mebaran151Incanter has very good math support, though it could be a little faster I've heard
15:50mebaran151the $= macro is actually quite handy when typing in really long expressions too
15:51quotemstrmebaran151: What does that do exactly?
15:51mebaran151let's you type ($= 3 + 4 + 5) instead of (+ 5 (+ 3 4))
15:52anonymouse89mebaran151: I should add that to my little bag of macros. as a non-lisper the prefix notation really throws me off for arithmetic exprs
15:53mebaran151and a couple other things to make writing long math expressions a little easier
15:53chouser(+ 3 4 5)
15:53clojurebot*suffusion of yellow*
15:53mebaran151heh, yeah you could do that, but stuff like exponentiation and matrix products get a little trickier
15:54anonymouse89right, I was thinking of polynomials
15:54mebaran151yeah it gives you slightly nicer syntax for polynomials
15:54mebaran151I think I read a blogpost it can pretty print them now to into latex
15:54mebaran151and even graph them using Java Swing
15:58anonymouse89mebaran151: processing support seems kind of nice too
15:59anonymouse89I've done a few interactive visualization things that were very verbose in java
16:02quotemstrIt'd be nice to just take TeX math formulae as input.
16:02quotemstrA smart editor could format the TeX.
16:02quotemstr:-)
16:28TimMcThis _Programming_Clojure_ book is good.
16:28TimMcI think I'm gonna buy it. :-)
16:33LauJensenGreat bookreview TimMc , thanks :)
16:33LauJensen(just kidding =))
16:33mebaran151I'm looking for a good description of StyleEditorKit for Swing; basically I'm my overall goal is to write a little syntax highlighting text component in Java Swing (just to learn Swing better) What's the best resource for this?
16:34LauJensenmebaran151: If you dont get an answer here, perhaps ##java
16:34mebaran151I'm there too, though it's suprisingly dead
16:35LauJensenjava, or the channel? :)
16:35mebaran151ha ha ha
16:35mebaran151I'm doing some Android dev right now, and Java isn't as bad as I remembered it
16:35mebaran151I think Clojure taught me to structure programs better in any language
16:35LauJensenIt has it upsides
16:35mebaran151esp, working Interfaces instead of Inheritances
16:36mebaran151Clojure encourages you not to overdetermine your design
16:38LauJensenYea Ive really come to appreciate Clojures oppinionated design
16:38LauJensenthought I still miss reader-macros occasionally
16:39mebaran151I'd like to dev Android with Clojure too (even if just for fun), but I'm not sure if AOT'ing my Java classes is sufficient
16:39mebaran151if you AOT your clojure code, does it ever run the compiler?
16:39LauJensenmebaran151: I think it is, but at least with the common android versions, Clojure is just too slow in terms of GC and allocation
16:39a_strange_guyonly if you use eval
16:40mebaran151even fancy stuff like defrecord?
16:40mebaran151and extend?
16:40a_strange_guyhmm
16:40a_strange_guyextend could pose a problem
16:40LauJensenmebaran151: I think all of that it compiled up front, but I'd have to check to be sure
16:40mebaran151because technically it does create a new interface
16:40a_strange_guyi think extend uses eval
16:41a_strange_guyno defprotocol creates a new interface
16:41vIkSiThmm, are there any projects on that look at improving clojure speeds compared to pure java?
16:41a_strange_guyand this interface gets created AOT
16:41LauJensena_strange_guy: I dont think its calling eval
16:42a_strange_guyvIkSiT: look at the new prim branch
16:42vIkSiTah you mean the primitive supports feature rich is working on..
16:42a_strange_guyyes
16:43dnolenvIkSiT: deftype and statics will get you very *close* to Java perf.
16:43vIkSiTdnolen, right.. i think i read on cgrand's blog about <5% perf differences
16:43a_strange_guyactually it gets you not close, but to java
16:43vIkSiTso I guess thats good
16:43LauJensenvIkSiT: What kind of projects do you mean ?
16:43vIkSiTa_strange_guy, as in?
16:44vIkSiTLauJensen, oh I always keep hearing about how certain things in clojure are too slow for [insert reason here] - for instance, the android comment above
16:44vIkSiTwas just wondering whats being done to resolve that..
16:44a_strange_guynothing on the clojure side i think
16:44a_strange_guyclojure relies on a good JIT
16:45LauJensenvIkSiT: An android comment only has to do with the android JVM - There is a custom built JVM for Android which is 4x faster than Googles
16:45LauJensena_strange_guy: yes actually, its the persistent datastructures thats high on allocation
16:45vIkSiTso you're saying that the JVM is the main issue rather than the language itself?
16:45LauJensenAnd thats why JAva has no problem
16:45hircusLauJensen: is this compared to Android 2.1 or 2.2? 2.2 finally has a JIT
16:45LauJensenvIkSiT: Its a combo
16:45LauJensenhircus: 2.1
16:45hircusit surprised me, but Android 2.1 and below actually has no JIT at all
16:45vIkSiTI see. and the contribution of JVM vs language specifics to this point - the JVM has a greater role to play, do you think?
16:46LauJensenvIkSiT: If you saw my Fluid Sim that was my best swing at fast math in Clojure, dunno how a Java version would roll
16:46hircusbut I'm still not sure how good the garbage collector is. probably not very. Google's performance-tuning tips still recommend against using features such as iterators
16:46vIkSiTLauJensen, indeed, I did..
16:46LauJensenhircus: Thats definitely a hint, that the time is not for functional programming on mobile devices
16:46LauJensenAnd it makes sense, its only in recent years its started making sense for industry use, imo
16:47hircusI agree. still, it's just a matter of time. my smartphone is already faster than my desktop from 10 years ago
16:47LauJensenIndeed
16:47quotemstrmebaran151: Yeah, Java seems much better these days. The last time I used Java itself in anger, there were still no generics.
16:47LauJensenAnd Clojure is picking up speed
16:48a_strange_guythe problem is not speed, but memory
16:48LauJensena_strange_guy: ?
16:48a_strange_guymost mobile devices have very tight memory constraints
16:48quotemstra_strange_guy: Right; CPU cycles are cheap. RAM is still dog-slow.
16:49LauJensena_strange_guy: The problem with FP generally, is that making a new struct takes longer than shifting a bit - With Clojure the challenge is, that path-copying, still takes a little longer than shifting a bit
16:49LauJensenOn desktops, the trade-off is good, on mobiles, no so much
16:49hircusquotemstr: java generics are horrrible, though. I wish they bite the bullet and change the bytecode language
16:49a_strange_guyit's hard to build a fast GC that can work in memorythight situations
16:49quotemstrOn that note, what are the complexity guarantees for Clojure's map structure?
16:50LauJensena_strange_guy: I think its just a matter of making Cliff Clicks morning coffee a little stronger
16:50a_strange_guyxD
16:50LauJensenquotemstr: Chousuke actually compiled a good list of all the datatypes, lemme see if I can find it
16:50hircusquotemstr: most operations that are linear in a hashmap are log_32(n) instead of linear
16:50LauJensenhttp://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html
16:50quotemstrLauJensen: Nifty. Thanks.
16:51a_strange_guyand our maps can actually be faster than javas HashMap
16:51a_strange_guyon look up
16:51quotemstrSurprise, surprise, Opera barfs on that table.
16:52a_strange_guythey have perfect hashing AFAIK
16:52LauJensenquotemstr: try conkeror
16:52quotemstrLauJensen: I've been meaning to get around to it.
16:52quotemstrWhy would nth on a vector be near-constant instead of constant?
16:52a_strange_guyyes
16:53LauJensenquotemstr: No I think lookups are constant
16:53vIkSiT... was just about to ask quotemstr's question :)
16:53a_strange_guynear-constant == log32(n)
16:53LauJensenyep
16:53dnolenquotemstr: because vectors in clojure are trees, near-constant
16:53quotemstra_strange_guy: O(log32(n)) is still O(log(N)), which is not constant.
16:53vIkSiTand I guess the reason is because they're trees
16:53quotemstrSo how is a vector different from a sorted-map with integer keys?
16:53hircusquotemstr: it's not in theory, but in most real-life use cases, it practically is
16:53vIkSiThmm
16:54a_strange_guyclojures hashmaps have a better worst case behaviour
16:54quotemstrErr, nevermind.
16:54quotemstrI should read the legend. :)
16:54hircusI believe that internally, they're not that different, as you hinted at
16:54a_strange_guyquotemstr: not much difference
16:55hircusThere was a recent push in Python to get a BTree-based list/vector/set/dict implementation similar to Clojure's (though not immutable)
16:55a_strange_guyvectors & maps have the same basic structure
16:55hircusit sadly failed to get adopted as the standard, but is available for download. quite nice
16:55quotemstrnon-persistent vectors should be truly linear, right?
16:56quotemstrOr, rather, they *could* be.
16:56a_strange_guyactually it would make them slower
16:56a_strange_guybecause transient => persistent is constant time
16:56hircusif they're based on a btree, yes, they'd be slower. but much easier to copy
16:57a_strange_guymutable B-trees are a pain in the ass to get threadsafe
16:57a_strange_guythis is maybe the reason, why they aren't in python
16:58hircusprobably not a major problem for Python, since "multithreading" there is not very effective anyway
16:58LauJensen...and officially discouraged
16:58hircusI think the argument for having it in Python is mostly that for large lists, a Btree implementation has benefits, even when it's still mutable
16:59a_strange_guycopying them is a lot faster
16:59a_strange_guybecause you can do COW
16:59quotemstrBah, multithreading in the conventional sense ought to be discouraged anyway.
17:00quotemstrMixing preemptive concurrency and shared memory is a Bad Thing
17:00quotemstr.
17:00quotemstrSTM or message-passing is the way to go.
17:00a_strange_guyand HAMTs are generally faster on big keysets for dictionaries
17:00hircuscould be worse. PyPy in stackless mode is properly multithreaded, I believe? so there are Python implementations that support real multithreading (Jython too). whereas Ocaml is still not there because the people using it for theorem proving like the implementation they have
17:00a_strange_guyquotemstr: you forgot CSP
17:01hircustrue; the programmer should not have to think explicitly about threads and locks. but still, the underlying implementation is still threads anyway, if you go down far enough
17:01LauJensenOCalm really blew me away on the Wide Finder II challenge though
17:01a_strange_guyLauJensen: not surprinsing
17:01LauJensen2 threads as I recall, one reader and one thinker
17:01quotemstra_strange_guy: Isn't CSP just message-passing?
17:02quotemstrhircus: Cooperative threads are often *much* more efficient.
17:02hircusquotemstr: if you have one CPU core, yes. but since we can't speed up single cores much anymore, surely we need a scalable solution?
17:02a_strange_guyquotemstr: maybe, but pretty different from Actors
17:03quotemstrhircus: I believe scalability is best achieved at a much coarser granularity.
17:03a_strange_guyLauJensen: OCaml has really good IO
17:03hircusLauJensen: yup. and JoCaml too -- JoCaml actually has an interesting concurrency model.
17:03quotemstra_strange_guy: Hrm, I'll have to read up on it.
17:03LauJensena_strange_guy: indeed. if I remember correctly the raw IO time for that job, was 5 minutes as best, just for slurping the file. And the total runtime of OCalm was 5:14
17:03LauJensenClojure was 8:14, Java 12, Scala 13, IIRC
17:04LauJensenSingle threaded C was something like 10 or 11 minutes, which also blew me away
17:04a_strange_guyOCaml is the C of FP
17:04quotemstrhircus: People use threads for two different purposes: managing multiple simultaneous blocking calls, and for taking advantage of hardware SMP. There's no reason to conflate the two.
17:04hircusquotemstr: right. but look at a language like Clojure. once you have persistent data structures, then multithreading is a really nice solution. with multiprocessing you'd have to either deal with explicit shared memory areas or lose the benefit of COW sharing
17:05quotemstrhircus: Sure, but multithreading in Clojure would be *even faster* if it didn't have to deal with atomic operations and mutexes for synchronization.
17:06hircusdoes Clojure use mutex much, though, in practice?
17:06a_strange_guymultiprocessing nowadays is a synonym for "We just use the DB for synchronization" IMHO
17:06LauJensenhircus: Cells are based on mutexes AFAIK
17:06hircusLauJensen: ah, ok
17:06a_strange_guyor on threadlocals
17:07LauJensen?
17:07a_strange_guygot that wrong
17:07quotemstrthread-locals aren't free either.
17:07a_strange_guynot based , but behave thread local
17:08a_strange_guychecking the current thread is basically free
17:08quotemstrIt's better to just use a single process for everything and juggle execution contexts explicitly; then, to take advantage of SMP, split off another whole process and divide the work.
17:08quotemstrI don't know how feasible that would be in the JVM though. :)
17:08mebaran151quotemstr: I'm sure forking is always the best idea for code genning programs like the JVM
17:09tomojLauJensen: but there's a 3:11 result
17:09LauJensentomoj: who?
17:09mebaran151forking is cheap for C, where the program flow is usually pretty static, but for something like the JVM that is often rewriting itself, forking creates a lot of unnecessary duplication
17:09quotemstrmebaran151: Well, let's say a "fiber" is a Clojure thread of control, and that in a given "fiber group", fibers schedule cooperatively.
17:09a_strange_guyquotemstr: you can run two different Apps in the Same JVM process
17:10a_strange_guyso no need for forking
17:10quotemstrmebaran151: You could use one JVM-level thread for each "fiber group". Instead of forking, just create another real thread in the same JVM and a new "fiber group" for it.
17:10quotemstra_strange_guy: Ah, that's pretty much what I had in mind.
17:10tomojLauJensen: C http://wikis.sun.com/display/WideFinder/Results
17:10mebaran151quotemstr: you're just looking for green threads
17:10quotemstrmebaran151: More like an N:M model actually.
17:10mebaran151I thought there was a JSR to implement them
17:10tomojor aren't you talking about elapsed times?
17:10LauJensentomoj: I was - Am Im very disappointed to see Scala is now faster than Clojure again
17:11LauJensen(and OCalm)
17:11mebaran151usually, though the fastest programs aren't written in real Scala style
17:11LauJensenmebaran151: same for Clojure
17:11mebaran151really fast Scala is basically Java with some type inference :)
17:11tomojwonder why clojure isn't on there
17:12LauJensenWould be ideal if (reduce make-stats (slurp "apache.log")) would run in 3 minutes flat
17:12LauJensentomoj: Yea I dont know why tbray didnt add it
17:12mebaran151I think the inflection of fast clojure is closer to real clojure than the inflection of fast Scala is to real clojure
17:12mebaran151*real Scala
17:12LauJensenmebaran151: impossible
17:12mebaran151impossible?
17:12a_strange_guyit's the other way around
17:12LauJensenScala is Java with added features, so Scala code formed exactly like Java is still idiomatic Scala
17:13mebaran151to write fast Scala, you basically have to forgo all its cool features
17:13mebaran151my understanding is fast Clojure is pretty macro heavy
17:13LauJensenmebaran151: for primitive math, yes
17:13dnolenmebaran151: not anymore
17:13LauJensendnolen: calm down, its still a branch
17:14dnolenLauJensen: heh. a suprisingly fast branch
17:14LauJensendnolen: no doubt about it
17:14LauJensenBut the reality is still, that Clojure cannot pass primitives between functions
17:14LauJensenthats true for 1.1 the last stable release, and 1.2 SNAPSHOTS
17:15a_strange_guyI don't think you can actually compare a program in a statically typed language with one written in a dynamic language
17:15LauJensena_strange_guy: sure you can :)
17:15dnolenmebaran151: even no so you don't need the prim branch. deftype + definterface will give you Java perf at the cost of losing first class functions. prim branch solves that.
17:15a_strange_guythe program in a ST lang is cast in cement
17:16a_strange_guyone in a DT lang can be updated at runtime
17:16danlarkinHow do people deal with the need for a BlockingQueue in clojure? I know of clojure.lang.PersistentQueue, but it doesn't block so in a tight loop it rockets the CPU
17:16a_strange_guydanlarkin: you wrap it
17:17a_strange_guya LBQ is basically a pipe
17:17danlarkina_strange_guy: wrap a j.u.c.BlockingQueue you mean? it's not persistent though, so it isn't very useful in a transaction
17:18a_strange_guyyou shouldn't use a blocking anything in a transaction
17:19danlarkinHm
17:19Chousukemaybe you could use an agent somehow?
17:19codemonstacan anyone expound on Scala's shortcomings?
17:20mebaran151it's a little overengineered and schizophreni
17:20a_strange_guycodemonsta: i program a lot in it
17:20danlarkina_strange_guy: I suppose you're right about that
17:20a_strange_guyand I can tell you my pet peeve
17:20mebaran151I got frustrated with implicits
17:20a_strange_guyyeah, implicits are a really, REALLY evil idea
17:21quotemstrImplicits?
17:21a_strange_guyin Scala
17:21quotemstrI don't know Scala. I suppose I'll RTFM. :)
17:21mebaran151extensions methods in C# are saner
17:21mebaran151if less Type Friendly
17:21a_strange_guyType-friendly?
17:22codemonstaI can't tell what programming model scala is trying to present. OO? Functional? Some mixture?
17:22mebaran151somehow, implicits are a purer way to handle type conversions and extensions if you're a type theorist
17:22a_strange_guystatic-polymorphism just fucks up my understanding of code
17:22Chousukecodemonsta: it's "multiparadigm"
17:23mebaran151the problem as I see it is OO is all about state, while functional programming is all about getting rid of state
17:23a_strange_guyIMHO a type system should not change the semantics of my code
17:23mebaran151I agree
17:23codemonstaChousuke, so how do I pick a paradigm?
17:23Chousukecodemonsta: but I think they like to advertise as a fusion of functional and OO programming or something
17:24a_strange_guyIMHO, OO is not about state and FP about statelessness
17:24quotemstrImplicits look like C++ one-argument constructors from hell.
17:24codemonstai would think a programming language should have one primary programming model
17:24Chousukecodemonsta: hmmh
17:24a_strange_guyFP is the style of programming, where you pass around behaviour
17:24Chousukecodemonsta: common lisp doesn't, and it's fine
17:24codemonstafor example, C++ is multi-paradigm, but primaily OO
17:24a_strange_guyC++ is not OO
17:25quotemstra_strange_guy: But you can write OO code in C++.
17:25codemonstait quite is
17:25codemonstaor at least tried to be
17:25ChousukeActually CL is probably the only "true" multi-paradigm language I can think of
17:25a_strange_guywell if you redefine OO first
17:25codemonstaI guess I'm talking more abount 'intentions'
17:25quotemstra_strange_guy: What definition of OO can you construct that excludes C++?
17:25Chousukequotemstr: message passing OO :P
17:26codemonstaI'll grant that CL is effectively multi-paradigm
17:26codemonstaso is scala trying to be like CL?
17:26Chousukecodemonsta: I'll assert that it's the only one that's *effectively* multi-paradigm :)
17:26mebaran151I don't think you see that many multiparadigm CL programs though
17:27mebaran151if you take out the CLOS, you use the CLOS through and through
17:27a_strange_guyquotemstr: runtime types, and polymorphism on them
17:27mebaran151you might do some functional things, but your basic building block is objects
17:28mebaran151what do you mean by runtime types?
17:29codemonstahere's a key question, how difficult is it to do pure FP in scala?
17:29a_strange_guywhat is the runtime-type of, say.. int?
17:30mebaran151a_strange_guy: by that definition I could argue that Haskell is OO
17:30mebaran151it's polymorphic, and everything gets a type (which is verified beforehand)
17:30a_strange_guymebaran151: haskell has no runtime polymorphism
17:30mebaran151well it has no casting
17:31mebaran151so there's no real polymorphism to be had at runtime
17:31a_strange_guybecause you cannot get the types at runtime
17:32a_strange_guyit's basically as OO as C
17:32mebaran151gobject would say those are fightin' words
17:32mebaran151:)
17:33codemonstaas OO as C if C had C++ templates
17:33a_strange_guygobject is a OO DSL on top of C
17:33quotemstrYou can trivially construct an object system in C out of structs and function pointers.
17:34a_strange_guybut it is not the same as Lisp without CLOS
17:34quotemstrSame goes for Lisp and defstruct.
17:34mebaran151btw have you seen valhalla? it's the way I write C these days when I have to
17:34mebaran151it's like C# without all the extra noise
17:34quotemstrI've seen Valhalla but I haven't used it. Isn't it tied to gobject?
17:34a_strange_guylisp was already OO in the 60ies
17:35mebaran151sorry vala
17:35quotemstrErr, I'm thinking Vala.
17:35mebaran151yeah I used it for two little tiny patches
17:35mebaran151it was actually pretty nice
17:36a_strange_guyVala is like Java/C# without the VM
17:36quotemstrHow does it manage memory?
17:37mebaran151it doesn't
17:37quotemstrReference counting? GC?
17:37quotemstrmebaran151: Does it require a runtime library, or does the compiler translate straight to C?
17:37a_strange_guy Reference counting
17:37quotemstra_strange_guy: No cycle collector, I imagine?
17:37a_strange_guyRuntime Library == GObject
17:38a_strange_guydunno
17:38mebaran151it's basically straight C with ref counting
17:38quotemstrNope, no cycle collector.
17:38mebaran151like Objective-C super light
17:44quotemstrYuck. Vala uses checked exceptions.
17:44mebaran151it's better than raw C
17:44mebaran151kind of like it over Objective C too
17:44mebaran151I never did get used to [] for method invocation
17:44quotemstrYeah, Objective C is one of the ugliest languages I've ever seen.
17:45a_strange_guythe []'s werent so bad
17:45a_strange_guyi actually liked them
17:45mebaran151it's like all the problems of Ruby and all the problems C in one language
17:45codemonstawhat really pisses me off about scala is the braces
17:45mebaran151I'm ambivalent to braces
17:45a_strange_guywhat i didn't like were the + and - as modifiers
17:46mebaran151I think I've hardwired my brain to map [] to collections
17:46codemonstajava programmers place them completely wrong
17:46codemonstapython does it right
17:46codemonstano braces because they're redundant with proper formatting
17:46mebaran151a_strange_guy: yeah the + and - protection was a little bit annoying
17:47codemonstasimilar to obj-c?
17:47mebaran151I often thought of writing an editior mode where the parens were invisible and it was all done based on proper highlighting
17:47mebaran151*proper formatting
17:47codemonstathat would be cool
17:47mebaran151I wrote made myself a draft of what it would parse
17:47mebaran151and I didn't like it
17:47mebaran151I missed my parens
17:48codemonstadid you include the : to put a newline on the same line?
17:48codemonstapython uses : really well
17:48mebaran151nope, just invisible parens
17:48mebaran151though if you called something inside a line you could see it
17:49codemonstaI really do like the idea of meta expressions
17:49mebaran151lines looked like map #(inc %1) col
17:50codemonstasexpr is great, but it seems like it should be optional rather than the default
17:50mebaran151you'll miss them :)
17:50mebaran151(f 23) really makes it easy to track funcalls once you get use to it
17:50codemonstawell, everything should compile down to sexprs
17:51mebaran151f 23 was a little harder to follow
17:51tomojwhat is (f 23) ?
17:51codemonstawith mexprs it'd just be f(23)
17:51codemonsta42
17:51tomojoh, the syntax of it you mean?
17:52codemonstabut I guess noone figured out what a proper mexprs system would look like on top of lisp
17:52tomojthat's because "a proper mexprs system on top of lisp" doesn't have a referent
17:52tomoj:P
17:53codemonstano such thing, you mean?
17:53tomojyeah
17:53mebaran151you'd have an artificial difference between your data structures and your program
17:53mebaran151(f 23) is really just a list
17:53mebaran151f(23) is syntax
17:54tomojI'd heard that "we should get rid of all these damn parentheses" was common, but had never actually observed it in the wild
17:54codemonstasure, but f(23) could easily compile down to (f 23), faik
17:54mebaran151I'm not sure how macros would look to an mexpression engine; it would probably just make them into sexps
17:54codemonsta*afaik
17:54codemonstapresumably you'd have a mode where you can write sexprs directly
17:55codemonstajust have to denote it
17:55codemonstai dunnp
17:55codemonsta:)
17:56codemonstai just prefer a python level of syntax
17:56mebaran151f(32) actually seems like syntactic sugar for (cons f '(23))
17:56mebaran151to the macro engine that is
17:58codemonstahehe
17:58codemonstashould be 'software is just degrees of broken'
18:01Chousukeor you could say that pure math is black and white, while software is the shades of gray :P
18:45hsjunnessonSo I have a map, something like {:class Composite}, which I read and eval from a file. In my *ns* Composite maps to an imported java class, but when I eval the map form Composite is a symbol.
18:46Chousukewhat is written in the file?
18:46hsjunnessonMy problem is that I have functions which work on these maps which can either be generated programmatically, or read from files. I need to dynamically instance objects from the classes pointed out in my maps, and it seems redundant to have to check (if (symbol? symbol) (resolve symbol))...
18:46hsjunnessonIt's a hierarchical datastructure which I read in and instance objects trees from.
18:46hsjunnessonJust standard clojure expressions.
18:46Chousukeis it "{:class Composite}" or {:class 'Composite} that's written in the file?
18:47hsjunnesson{:class Composite)
18:47hsjunnesson} rather
18:47hsjunnessonI figured that since I make sure to have imported the proper Composite, that should still work.
18:47ChousukeOkay, so reading that will give you a map with a symbol, but evaling the read result should give you the Class instance.
18:48Chousukeif that's not happening, then something weird is going on
18:48hsjunnessonRight now I just (read) it, but I'll try evaling.
18:49Chousukeeval is somewhat dangerous though
18:49Chousukedo it only if you trust the data
18:49Chousukeif you accept untrusted input, someone could send you {:class (take-over)} :P
18:50hsjunnessonAbsolutely, I'm not a fan of that.
18:50hsjunnessonI know there are sandbox libraries out there though. I might have to take a look at them.
18:50Chousukeso in any case the safest choice is to work with the data structure without evaling them
18:50Chousukeand just resolving the symbols manually
18:51hsjunnessonEvaling the read forms worked though. But it's only when it comes to dynamically instancing the objects I really need to force a resolution.
18:51Chousukeyou might want to have your own customised "eval" that takes the read form, checks it for validity and produces a suitable "evaluated" form
18:53hsjunnessonMaybe what I need to do is just to check whether (:class m) is a symbol or a class, then doing a (resolve) on it if it's a symbol...
18:53Chousukewell that'll work too
18:54hsjunnessonAlthough I want to, eventually, make these files into a DSL, so I guess I'll have to eval them...
18:55hsjunnessonThanks for your help Chousuke
20:03duck1123In many frameworks (Rails) you can set which set of configuration options you use (database info) by setting an environment variable. (RAILS_ENV) Are people doing that sort of thing for their Clojure (with Compojure in particular) or is there a better way to be setting which environment you're using
20:04duck1123I probably also mention I'm giving lein another shot as well
20:05vIkSiThi all
20:07vIkSiTanyone awake? :)
20:07vIkSiTI had a quick protocols question. If I have 2 protocols - A and B, and each have a function of the same name, say myfn []..
20:08vIkSiTthe REPL shows me a warning of the type: protocol #'ns/A is overwriting method myfn of protocol B
20:09vIkSiTdoes this mean that these 2 functions are *not* different anymore, when used with different kinds of records?
20:11dakroneyou could separate their namespaces
20:12vIkSiTdakrone, hmm, within the same file?
20:13dakroneif you want them in the same file you can use (in-ns)
20:14vIkSiTdakrone, hmm I see. so basically each ns can only have on function of the same name, even within different protocols?
20:15dakroneyes, assuming you're using 1.2, it's last-var-wins (unless it's changed since I've checked)
20:16vIkSiTyes, 1.2
20:16tomojotherwise, suppose you had protocols A and B and you gave implementations for both for Foo
20:16tomojhow would it know which to use?
20:16vIkSiThmm true, but only if I gave both for foo, right?
20:16vIkSiTwhat if i ensured that i was using foo1 and foo2
20:17tomojI think that could be done
20:17tomojoverriding a protocol fn would just merge the dispatch map
20:17tomojbut it seems silly
20:18vIkSiThmm, yeah. I'm just loathe to have multiple files with different namespaces
20:18vIkSiTfor a few protocols
20:18dakronereally? why?
20:18tomojit's no different than having to have multiple files with different namespaces when you want two different functions with the same name...
20:19tomojjust for a couple functions you have to do this
20:20vIkSiTwell, I've got 5 protocols so far, and will only be implementing a few methods from each to start working on something. Having 5 different files for each and then the :require/:use seems a bit clunky
20:21technomancyLeiningen 1.2.0 RC1: http://groups.google.com/group/leiningen/browse_thread/thread/376cd07e274130d7
20:22technomancygive it a try! 95%suckage reduction in the repl task.
20:22dakronetechnomancy: hurray, awesome!
20:23duck1123nice. I just got my app working with lein today
20:31technomancycool
20:32vIkSiTsigh ok. I think I need to move out from single files to multiple clj files :)
20:32vIkSiTwhat would you guys recommend as the best way to manage (and build) a multi file clojure project?
20:32vIkSiTlein?
20:32clojurebotthe leiningen screencast is on full disclojure: http://vimeo.com/8934942
20:36dakroneyea, lein is a good tool
20:38dakronetechnomancy: the link you sent out for wget to the mailing list doesn't work, needs to be http://github.com/technomancy/leiningen/raw/1.2.0-RC1/bin/lein
20:39technomancyoh, of course... that just gets the html
20:39technomancythanks
20:39dakronenp
20:41vIkSiThmm. I remember some conversations about clojure-swank-project being removed?
20:41vIkSiThow would I get a REPL to a lein project directory, btw?
20:48technomancyvIkSiT: just "lein repl". works best in the latest RC rather than 1.1.0 though
20:48technomancyor lein swank followed by M-x slime-connect; see the swank-clojure readme
20:49vIkSiTtechnomancy, indeed, I tried the second option with the latest lein (using lein upgrade), and SLIME 20091016
20:49vIkSiTget some errors. trying again
20:49vIkSiT(I ran lein swank in the project / directory, and tried to use slime-connect on 127.0.0.1 and 4005
20:50technomancytry upgrading slime; the 2009 version might not work with the latest swank
20:50vIkSiTah
20:50vIkSiTis there an easy way to do this upgrade btw?
20:52vIkSiTtechnomancy, does elpa automatically "upgrade" a package?
21:00dnolentechnomancy: nice, 1.2.0 repl!
21:20vIkSiTtechnomancy, around?
21:21vIkSiTI was just installing swank-clojure from elpa, but it doesn't end up installing - and instead, refers to a message that says: let: File exists: /Users/viksit/.emacs.d/elpa/clojure-mode-1.7.1/clojure-mode.el
21:21TimMcrhickey: I'm curious as to why 'true (and 'false and 'nil) is read as a boolean, not a symbol -- is that to make it easier to write data structure literals like '(foo 3 true)?
21:22TimMc(well, 'nil is read as nil -- mis-spliced some thoughts)
21:28vIkSiThmmm. has anyone actually done the latest slime/swank install on emacs?
21:35vIkSiTgah.
21:43dnolenvIkSiT: it might be simpler to just delete ~/.emacs.d/elpa and start fresh
21:43vIkSiTdnolen, I'm seeing inconsistencies even with a new install
21:44vIkSiTfor instance, the version references for slime in swank-clojure are to 200910.. not 201004..
21:44vIkSiT(inside archive-contenst in elpa)
21:45dnolenjust erase your elpa folder and reinstall elpa package.el from scratch
21:45vIkSiT(I did)
21:47dnolenvIkSiT: what is listed when you package-list-packages, 201004 ?
21:47vIkSiTyes
21:47dnolenerase slime in your elpa dir, and try installing 201004
21:47vIkSiThmm
21:48vIkSiTI've tried that. I installed slime 201004, slime-repl same version
21:48vIkSiTat that point installing swank-clojure just keeps telling me that "file clojure-mode" already exists
21:49vIkSiTok, so i've deleted everything (including elpa)
21:49vIkSiTis there an order in whicih the packages should be installed?
21:50vIkSiTdnolen, for instance, slime before clojure-swank, etc?
21:50vIkSiTor can I just select all I want?
21:58dnolenvIkSiT: try just installing swank-clojure.
22:03vIkSiTdnolen, nope no luck
22:03vIkSiTmy problems seem like this thread: http://www.mail-archive.com/clojure@googlegroups.com/msg22598.html
22:04vIkSiTbut thats windows specific, and i'm on OS X
22:04vIkSiThttp://paste.lisp.org/display/111384#1
22:04vIkSiTthose are the errors I get
22:05vIkSiTon a) removing elpa. b) installing elpa by evaling the script, and c) selecting swank-clojure, and d) installing it.
22:11dnolenvIkSiT: those just look like warnings - what version of Emacs are you on? what happens when when you run M-x slime ?
22:12vIkSiTI'm on emacs 23.11
22:12vIkSiTI can't even run m-x slime
22:12vIkSiTits not a valid option
22:12vIkSiTafter doing all of that, I can't even start emacs properly.
22:13vIkSiTif you look at that lisppaste
22:13vIkSiTthe error message is poasted right above the warnings you saw
22:13vIkSiThttp://paste.lisp.org/+2DY0
22:15vIkSiTsigh. all this was fine when I was using slime200910
22:16dnolenvIkSiT: in your .emacs package.el writes some crap
22:16dnolenerase that, erase your .emacs.d/elpa
22:16dnolentry again
22:17dnolenI ran into this problem as well
22:17dnolenit's important to only install swank-clojure, it installs clojure mode and slime, slime-repl
22:18vIkSiThmm
22:18dnolenvery unfriendly, but it seems like the elpa maintainer is fairly unresponsive.
22:18technomancyvIkSiT: there is a bug in package.el that can prevent packages from being installed if older versions of its dependencies are present.
22:18vIkSiTok, removed .emacs*
22:18technomancyI've fixed it in my fork of package.el, but it hasn't been integrated upstream yet. i_i
22:19vIkSiThmm :)
22:19technomancyluckily it sounds like the fixed version will probably be integrated into the Emacs 24 codebase very soon.
22:19vIkSiTwhew for that
22:19vIkSiThmm ok
22:19vIkSiTso on deleting .emacs* (moving it anyway)
22:19vIkSiTloading elpa and then selecting only swank-clojure
22:20vIkSiThttp://paste.lisp.org/display/111384#2
22:20technomancyvIkSiT: those are just warnings; it should work correctly.
22:20vIkSiThmm the last line too?
22:20vIkSiTswank-clojure.el:47:1:Error: Cannot open load file: slime
22:21technomancyyeah, it just means it won't get byte-compiled. it'll work fine in interpreted mode.
22:21technomancythe slime developers are really sloppy. =\
22:21vIkSiTohh.
22:21vIkSiTgood lord
22:21technomancyyeah.... lots of room for improvement there.
22:21vIkSiTbtw, does swank-clojure support color-theming on the REPL now?
22:22technomancyhmm... someone submitted a patch for that which has been applied
22:22vIkSiTyes I used to apply that patch manually
22:22technomancybut I haven't tried enabling it yet, and I don't think they submitted docs for it.
22:22vIkSiTdoesn't look it works though
22:22vIkSiToh enabling it.
22:23vIkSiTtechnomancy, is that clojure-font-lock-setup?
22:24technomancyprobably
22:24technomancyI am not actually a dev on the slime project; otherwise I would look at cleaning up those nasty compilation warnings.
22:25technomancythey're crusty old CL'ers that aren't always too friendly towards upstart "hype-ridden" lisps though. =)
22:26vIkSiThehe
22:29dnolenI'm surprised at the animosity towards Clojure from the Lisp/Scheme community sometimes. If anything it's getting more people interested in Lisp in general again.
22:30wdouglasThey're just mean in general
22:30wdouglasI've watched the slime-dev list for years
22:31wdouglasTobias is nicer than Helmut at least, but they know what they are doing, just are set in their ways
22:31dnolenThese days I'm looking at beautifully syntax highlighted Lisp code on sites/blogs with designs that don't look like they were created in 1993.
22:33dnolencertainly wasn't the case 2 years ago.
22:33vIkSiTugh is there a way to get rid of those warnings in the namespaces, when loading clojure?
22:34dnolenvIkSiT: what warnings?
22:35dnolenthis is pretty cool: http://data-sorcery.org/2010/06/12/incanter-executables/
22:35vIkSiTon running m-x slime, I always get : WARNING: group-by already refers to: #'clojure.core/group-by in namespace: swank.util, being replaced by: #'swank.util/group-b
22:36vIkSiTlots of these messages
22:36vIkSiTand slime is now taking ages to startup!
22:40technomancyvIkSiT: swank 1.2.1 doesn't give any warnings, but possibly one of your other dependencies still does