#clojure log - Jun 12 2010

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:21 timmorgan: Is there an IRC channel for VimClojure?

0:23 quotemstr_: How does the performance of Clojure (after the compiler and the JVM have had their way) compare with what SBCL outputs?

1:05 quotemstr: Hrm.

1:06 Is there any way to get the size of clojure below 1.8 megs?

1:07 KirinDave: 1.8megs?

1:07 Dang dog it is small for you.

1:07 quotemstr: -rw-r--r--@ 2 root admin 1.8M Jun 11 22:33 clojure.jar

1:08 I wish there were a tree-shaker. :-)

1:08 KirinDave: http://idisk.me.com/dfayram/Public/Pictures/Skitch/sizequeen-20100611-220709.png

1:08 quotemstr: KirinDave: 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.

1:08 KirinDave: Good luck with that.

1:08 I doubt it's happening.

1:08 quotemstr: Yeah, figured.

1:09 It's a shame.

1:09 KirinDave: Yeah, but you have CL so..

1:09 quotemstr: ?

1:09 What do you mean?

1:10 KirinDave: I thought you said you were using a common lisp for the other version of your project.

1:10 And those can get pretty dang small

1:11 quotemstr: No, I'm using a custom Lisp-1 which is mostly a CL workalike.

1:11 It has setq, setf, let* and friends, but like Clojure, supports destructuring everywhere.

1:12 ECL is about the same size as Clojure.

1:12 zakwilson: There used to be a clojure-slim.jar that was something like 600k

1:14 520K clojure-slim.jar <-- this was pre-1.0, I think.

1:14 quotemstr: Ah.

1:15 It still seems like the right solution is a tree shaker though.

1:16 Amazing! There is no Java tree shaker available.

1:17 zakwilson: Seems like there still ought to be a way to build a lighter clojure.jar.

1:20 A 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.

1:30 quotemstr: Aha.

1:30 Apparently proguard is a Java tree shaker.

1:30 Except that Clojure seems to always load all classes in a namespace, at least according to a mailing list message.

1:59 vIkSiT: hey all

2:00 what would be the best way to search a vector of maps?

2:00 (for the value of a particular key)

2:21 Twey: ,((first (filter (comp not nil?) (map 'e ['{a b c d} '{e f g h}])))

2:21 clojurebot: EOF while reading

2:21 Twey: ,(first (filter (comp not nil?) (map 'e ['{a b c d} '{e f g h}])))

2:21 clojurebot: f

2:21 Twey: vIkSiT: ^ that's one way…

2:23 vIkSiT: Twey, ah thanks - that looks promising.

2:23 what does the map 'e part doing here?

2:23 Twey: Maps 'e over the vector

2:23 ,('e '{e f g h})

2:23 clojurebot: f

2:24 vIkSiT: aah

2:24 gotcha

2:24 i wonder if there's a way to do this for values

2:24 lets say you wanted to check for d

2:24 Twey: When used as a function, it's a shortcut for ‘get’

2:25 Well, that's not really what maps are for

2:26 ,(seq '{e f g h})

2:26 clojurebot: ([e f] [g h])

2:27 vIkSiT: Twey, 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

2:27 I could perhaps shift to a pair of some sort

2:27 Twey: ,(filter (comp (partial (= 'h)) second) (seq '{e f g h}))

2:27 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$partial

2:27 Twey: Ack

2:27 vIkSiT: partial needs 2 args surely?

2:28 Twey: ,(filter (comp (partial = 'h) second) (seq '{e f g h}))

2:28 clojurebot: ([g h])

2:28 vIkSiT: ahh

2:28 Twey: Yeah, I was expecting sections ;)

2:28 But that's a horrible thing to do

2:28 vIkSiT: indeed

2:28 Twey: I suspect you should be using a different data structure

2:28 vIkSiT: what do you recommend as a better data structure?

2:29 Twey: Firstly you should merge your vector of maps into a single map

2:29 vIkSiT: maybe use pairs.. and map a second on that, and do a find on that

2:29 Twey, there's a problem with that

2:29 Twey: That's exactly what we've just done :þ

2:29 vIkSiT: Twey, haha yes, i just realized

2:30 as i was saying..

2:30 i need to have duplicate keys

2:30 in the structure

2:30 Twey: You could have lists as the keys

2:31 vIkSiT: hmm

2:31 Twey: (seqs, sorry)

2:31 (vectors, in fact, most like)

2:32 vIkSiT: hmm how exactly do you mean?

2:33 Twey: '[{k1 v1 k2 v2} {k1 v3 k3 v4}] becomes '{k1 [v1 v3] k2 [v2] k3 [v4]}

2:33 Or '[{k1 v1 k2 v2} {k1 v3 k3 v4}] becomes '{k1 [v1 v3] k2 [v2 nil] k3 [nil v4]} if you need to preserve ordering

2:34 vIkSiT: ... was just going to say that

2:34 ordering yeap

2:34 hmm

2:36 cgrand: Twey & 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}])))

2:37 ,(for [m ['{a b c d} '{e f g h}] [k v] m :when (= v 'd)] k)

2:37 clojurebot: (c)

2:37 Twey: Ah, thanks

2:37 vIkSiT: cgrand, ah interesting

2:56 jColeChanged: Hi, 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?

2:58 ; note those were not the exact commands, but just the general idea behind the commands..

3:33 cgrand: jColeChanged: try vectors instead of list

3:34 (use '[incanter core stats charts io])

3:35 jColeChanged: That gives me the same exception I had previously.

3:36 It can't find core__init.class or core.clj on the class path.

6:51 MrHus: Hi is was wondering if anyone could give me some feedback on a Lib I've been working on.

6:51 http://github.com/MrHus/Hadouken

6:51 Its a template system it allows you to create a file

6:52 with clojure code in it and

6:52 get the same file back but with the expressions changed with their values.

9:41 hiredman: ping?

9:41 clojurebot: PONG!

10:00 silveen: if 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:00 without putting it all in one file again

10:13 hoeck: silveen: yes, use load

10:13 ,(doc load)

10:13 clojurebot: "([& 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:21 silveen: you mean I need to add and maintain that line in every single file?

10:21 jesus

10:21 no wait, just had to rearrange some

10:27 technomancy: keep each namespace in a single file

10:27 hoeck: silveen: no, put the loads your main file, where you have your ns deklaration

10:27 silveen: yeah I fixed it

11:19 edbond: where to find all possible versions of clojure for leiningen?

11:23 TimMc: edbond: Are you asking about what dependency lines are possible for project.clj files?

11:25 edbond: yes

11:26 TimMc: I'm still figuring that out myself, but I generally just go to clojars.org and search.

11:26 I'm a beginner myself, though.

11:33 edbond: TimMc: try to search clojure and you get a lot of mismatches )

11:36 I have org.clojure/clojure "1.2.0-master-SNAPSHOT" and org.clojure/clojure-contrib "1.2.0-master-SNAPSHOT"

11:37 and get a nonsense error from lein deps

11:37 technomancy: edbond: there's no "-master" in the proper contrib version

11:38 edbond: thanks, how can I figure this out?

11:38 technomancy: edbond: they're listed here: http://build.clojure.org/snapshots/org/clojure/clojure-contrib/

11:38 edbond: where is 'gem search'-like functionality?

11:39 raek: the versions avaiable can be found at http://build.clojure.org/releases/ and http://build.clojure.org/snapshots/

11:39 technomancy: for everything but clojure and contrib you can search clojars.org

11:39 but that search should be expanded to include clojure and contrib

11:40 edbond: thanks a lot

11:50 technomancy: edbond: see also the lein-search plugin: http://blog.licenser.net/2010/04/20/leiningen-the-clojure-build-tool

12:00 edbond: technomancy: cool, thanks.

12:21 dmos: technomancy: 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:22 technomancy: Do you want a patch for this? It's just a moved line

12:23 technomancy: ie. from http://github.com/technomancy/emacs-starter-kit/blob/master/init.el#L29

12:23 technomancy: to http://github.com/technomancy/emacs-starter-kit/blob/master/init.el#L36

12:36 hamza: Guys, 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:47 raek: hamza: you need to use the the one namespace from the other

12:47 or, factor out the defmulti definition to a separate file

12:47 and let the implenetation namespaces use that one

12:48 technomancy: dmos: cool; I'll take care of it.

12:49 dmos: technomancy: 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:49 raek: example: assuming you have to implementations in my-ns.foo.impl-a and my-ns.foo.impl-b

12:49 make a namespace my-ns.foo.common

12:49 dmos: technomancy: File exists: yada yada elpa/idle-hightlight....

12:49 raek: the common namespace would contain the defmulti

12:50 and the implementation namespaces the defmethods

12:50 those need to (use) my-ns.foo.common as well

12:50 dmos: technomancy: seems like it gets confused about the state of it's packages (they should be installed from a prior run).

12:50 raek: hope this answers the question... :)

12:51 KirinDave: Hum

12:51 I 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:51 Is that conclusion so surprising?

12:51 OForero: hello

12:52 I am trying to use a record in a let

12:52 KirinDave: OForero: A defrecord or a record?

12:52 OForero: and it fails with Illegalargument exception

12:52 defrecord

12:53 KirinDave: OForero: Could you show an abbreviated example of what you're trying to do?

12:53 In 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:53 OForero: yes ... give me a sec

12:55 http://paste.pocoo.org/show/224575/

12:57 KirinDave: OForero: 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:58 OForero: Probably your testing code is what's failing.

13:02 OForero: 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:02 OForero: I will do that

13:03 I was suspecting something like that

13:03 KirinDave: I had a thing where constructors for defrecord worked but deftype didn't :)

13:03 OForero: ok

13:04 danlarkin: I asked a few days ago, but I think everyone was asleep,

13:05 is there anything besides being inside an uncommitted transaction that would prevent an agent from starting immediately on a function sent to it?

13:05 rpdillon: not sure, what's the behavior of an agent if it encounters an exeception? Doesn't it have to clear the error state first?

13:06 danlarkin: it's not encountering an exception

13:06 rpdillon: ok then =)

13:06 nothing else really comes to mind

13:06 danlarkin: if, instead of sending to an agent, I just run the form in a future, it executes immediately

13:06 KirinDave: danlarkin: Is it a long delay?

13:06 Like infinite?

13:07 danlarkin: so I don't think it's anything to do with the form

13:07 KirinDave: or a small delay?

13:07 hamza: raek: thx, got it.

13:07 dmos: technomancy: mercifully, my internet connection seems to be reestablished *sigh*

13:07 danlarkin: KirinDave: well here's the thing... it's based on when an unrelated (should be unrelated, at least) state changes

13:08 datka: I'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:08 KirinDave: Huh. Id bring that before Rich or Stuart. That sounds funky.

13:08 danlarkin: almost certainly it is programmer error, but I just can't seem to track it down

13:08 datka: I just tried blowing away my ~/.m2, but no help

13:09 dmos: technomancy: 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:10 wdouglas: I'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:11 jonasen: (apply max (range 100000000)) fails with a OutOfMemoryError in the prim-branch. No problem on master-branch. Any ideas?

13:15 OForero: lein deps => should upgrade the snapshots? or not?

13:15 datka: It should, assuming it doesn't crash out before that point

13:18 OForero: does lein has a command to force the check for new snapshots?

13:20 dnolen: OForero: 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:20 tomoj: but it will only check every so often, I believe?

13:20 OForero: ok

13:20 clojure-1.2.0-master-20100607.150309-85.jar

13:20 datka: IIRC it does it the same way as maven internally

13:21 OForero: is that the latest?

13:22 wrong repo

13:24 datka: is 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:27 tomoj: clojure.java?

13:27 clojurebot: ant clean and rebuild contrib

13:39 dnolen: datka: did you install lein 1.1.0 ?

13:43 datka: dnolen: yeah, I grabbed the latest stable script from the readme

13:46 dnolen: datka: and when does that error occur on what command? what's your project.clj look like?

13:47 datka: dnolen: actually, I just wiped out my the command and my ~/.m2 and tried again and it seems to be working

13:47 it's currently downloading the internet. (go maven)

13:47 dnolen: jonasen: 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:49 tomoj: should be the same thing

13:49 or nearly so

13:50 (defn max ... ([x y & more] (reduce max (max x y) more)))

13:50 though (reduce max (range 10000000)) works fine, strange

13:51 maybe something is holding the head?

13:52 dnolen: tomoj: look at the definition of apply.

13:55 tomoj: oh, bizarre

13:55 OForero: Is there a way to clean a REPL without having to restart the lein

13:55 swank?

13:55 clojurebot: swank is try the readme. seriously.

13:55 tomoj: apply hasn't always been this way, has it?

13:57 seems it's done that for quite a long time at least

13:58 OForero: I think defrecord generate private functions?

14:04 tomoj: afaik it only generates one function, which is public

14:05 OForero: probably changed ... that is why my test does not work

14:05 the constructor is not available

14:06 tomoj: oh, hmm

14:07 looks like you're right

14:07 the defn for the constructor fn is commented out

14:08 you can use the class, though, (Foo. ..)

14:08 but that means you have to import it, I guess?

14:37 ihodes: Has anyone found an ipad app/editor that handles clojure syntax highlighting? I'd love one... And a decent ssh app, too…

14:41 tomoj: plan to edit blind, or to hook the ipad up to a remote clojure?

14:48 quotemstr: ihodes: can you run Emacs on the iPad? :-P

14:49 tomoj: I thought jailbroken iGadgets could run Java programs via JamVM.

14:49 (Albeit very slowly.)

14:52 tomoj: cool

14:53 quotemstr: However, for iPad users, I recommend a journey to Cupertino to unmake the iPAd in the fires of Mount Doom.

14:54 On 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:57 a_strange_guy: there are many ways to use Agents

14:58 you can look at the ants demo (ants.clj) to see them used like Actors

15:00 but most people use them for centralized write-only stuff like logging etc.

15:03 LauJensen: Hey everybody

15:04 Lajla: LauJensen, hai

15:09 quotemstr: a_strange_guy: Thanks.

15:10 danlarkin: Gah! I figured it out! actions dispatched to agents from /inside/ another agent don't run until the first agent has finished?!

15:10 whattttttttttt

15:10 quotemstr: So io! is just do with an assert?

15:11 Lajla: ,`(quotemstr ~@(0 1 2 3 4 5 6))

15:11 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

15:11 Lajla: Ahh

15:11 quotemstr: ?

15:11 Lajla: ,`(qutoemstr ~@(range 0 10))

15:11 clojurebot: (sandbox/qutoemstr 0 1 2 3 4 5 6 7 8 9)

15:11 Lajla: Indeed

15:12 quotemstr: Huh?

15:12 Is that some kind of Zen answer to my question?

15:12 Lajla: quotemstr, no, just wondering how splicing interprets it.

15:14 a_strange_guy: quotemstr: That IPad LotR reference is worthy of bash.org

15:15 quotemstr: a_strange_guy: Heh. :)

15:16 a_strange_guy: So ants is using agents in sort of a CPS setup -- (defun behave [] ... (dosync (when running (send-off *agent* #'behave))))

15:16 a_strange_guy: yeah

15:17 notice that it checks a variable to see if it should keep running

15:17 Lajla: I never got why CPS is upposedly some kind of ultra-advanced paradigm for the hardcore but gotoes are bad.

15:17 quotemstr: a_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:17 Lajla: It really isn't. I don't like CPS myself.

15:17 Lajla: Also, gotos aren't always bad.

15:18 Lajla: With experience, you learn when to ignore rules of thumb.

15:18 Lajla: In fact, I *loathe* Scheme because of the extensive use of call/cc, which makes my brain hurt.

15:18 Now, it's possible I'm just stupid, but it's more likely that call/cc just leads to spaghetti.

15:18 a_strange_guy: CPS is actually really simple

15:19 and has nothing to do with call/cc

15:19 Lajla: quotemstr, call/cc is quite understandable.

15:19 But I guess it's best understood in terms of macros.

15:19 Which abstract its used for you.

15:19 a_strange_guy, 'nothing' is an overstatement, but I get your point.

15:20 rpdillon: quick 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:21 a_strange_guy: sorted maps and sets are Serializable

15:21 rpdillon: vectors, 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:21 quotemstr: a_strange_guy: I was making a larger point about how powerful techniques often lead to obfuscated programs.

15:21 a_strange_guy: But that the solution is to use them with moderation, not ban power outright.

15:22 a_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:22 a_strange_guy: quotemstr: the funny thing is that I am now using CPS to solve a normally very difficult problem

15:22 quotemstr: a_strange_guy: Do tell.

15:23 a_strange_guy: actors in Scala, and the question from a Student was "How can I build a Updatable actor"

15:24 the answer is to let it execute a function that never returns

15:24 a continuation

15:26 so the actor must recieve an 'update message, which contains a function that the actor will execute

15:27 CPS is just a technique, not a language feature

15:28 quotemstr: a_strange_guy: Well, you need first class functions. :-)

15:29 a_strange_guy: yeah, I refuse to respect languages that dont have them ;-)

15:35 anonymouse89: I'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:36 ^^(in common lisp btw)

15:37 quotemstr: Lisp as she is spoke!

15:37 ,g english as she is spoke

15:37 clojurebot: java.lang.Exception: Unable to resolve symbol: g in this context

15:37 quotemstr: anonymouse89: You really have to understand CLOS to understand what defmethod does, especially with a non-default combinator.

15:39 a_strange_guy: this adds the code that comes inside this defmethod form as post-initialialization for all subclasses of class-name

15:39 semantically speaking

15:40 i dont think that you can translate this to any language except Commpn Lisp

15:40 CLOS is just too powerfull

15:40 anonymouse89: I guess I'm wondering before I dive into CLOS and all that what the clojure way to do this would be

15:40 mebaran151: anybody here know about JTextPane and styling its contents

15:40 quotemstr: anonymouse89: What package are you trying to port?

15:41 mebaran151: I want to build a little proof of concept text editor for fun

15:41 a_strange_guy: you just don't do this in clojure

15:41 quotemstr: anonymouse89: Maybe there's a Java library that already exists that you can use instead.

15:41 a_strange_guy: What, write an editor? If you can write an editor in elisp, you can write one in Clojure. :)

15:41 mebaran151: maybe something that would even edit clojure code, like crippled dr. scheme

15:42 a_strange_guy: it was adressed to the statement about CLOS

15:42 quotemstr: mebaran151: Questions that begin with "anyone" usually aren't worth the time it takes to transmit them. Ask your real question.

15:42 a_strange_guy: Ah, okay.

15:42 anonymouse89: I'm translating a quantum gate simulator

15:42 quotemstr: Scratch that then.

15:42 a_strange_guy: yeah

15:43 mebaran151: basically, 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:43 a_strange_guy: too much of a paradigm shift

15:43 anonymouse89: not as scary as it sounds (if it sounded scary)...mainly a lot of matrix operations

15:43 mebaran151: anonymouse89: if it's a bunch of matrix stuff, you might want to check out Incanter

15:43 quotemstr: anonymouse89: In order to port CLOS-heavy code, you need to know CLOS. The gist of what that does is define a constructor.

15:44 mebaran151: Nifty.

15:44 mebaran151: Not quite* as nifty as, say, CGAL, but nifty. :)

15:45 a_strange_guy: anonymouse89: actually it extends all constuctors of things that subclass 'class-name'

15:45 anonymouse89: a_strange_guy: hmm.. In this case it might be overkill then. I don't think that class is ever subclassed

15:46 quotemstr: anonymouse89: In general, CLOS is usually overkill. :-P

15:46 mebaran151: quotemstr: what's CGAL?

15:47 anonymouse89: so that class could become a struct that I define default initialization values for?

15:47 quotemstr: mebaran151: A C++ template library for computational geometry.

15:47 mebaran151: ah, that sounds pretty neat

15:47 quotemstr: mebaran151: Damn fast too, because the library is instantiated using exactly the correct data types.

15:47 anonymouse89: quotemstr: that could be used in clojure or you were suggesting I use c++?

15:48 mebaran151: the 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:48 quotemstr: anonymouse89: Neither -- just commenting about geometry libraries in general.

15:48 mebaran151: and Incanter is far better than R in my opinion

15:48 which was the previous mainstay I had to fight

15:49 anonymouse89: Incanter will help me out a lot

15:50 mebaran151: CLOS code can be pretty hard to read

15:50 Incanter has very good math support, though it could be a little faster I've heard

15:50 the $= macro is actually quite handy when typing in really long expressions too

15:51 quotemstr: mebaran151: What does that do exactly?

15:51 mebaran151: let's you type ($= 3 + 4 + 5) instead of (+ 5 (+ 3 4))

15:52 anonymouse89: mebaran151: 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:53 mebaran151: and a couple other things to make writing long math expressions a little easier

15:53 chouser: (+ 3 4 5)

15:53 clojurebot: *suffusion of yellow*

15:53 mebaran151: heh, yeah you could do that, but stuff like exponentiation and matrix products get a little trickier

15:54 anonymouse89: right, I was thinking of polynomials

15:54 mebaran151: yeah it gives you slightly nicer syntax for polynomials

15:54 I think I read a blogpost it can pretty print them now to into latex

15:54 and even graph them using Java Swing

15:58 anonymouse89: mebaran151: processing support seems kind of nice too

15:59 I've done a few interactive visualization things that were very verbose in java

16:02 quotemstr: It'd be nice to just take TeX math formulae as input.

16:02 A smart editor could format the TeX.

16:02 :-)

16:28 TimMc: This _Programming_Clojure_ book is good.

16:28 I think I'm gonna buy it. :-)

16:33 LauJensen: Great bookreview TimMc , thanks :)

16:33 (just kidding =))

16:33 mebaran151: I'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:34 LauJensen: mebaran151: If you dont get an answer here, perhaps ##java

16:34 mebaran151: I'm there too, though it's suprisingly dead

16:35 LauJensen: java, or the channel? :)

16:35 mebaran151: ha ha ha

16:35 I'm doing some Android dev right now, and Java isn't as bad as I remembered it

16:35 I think Clojure taught me to structure programs better in any language

16:35 LauJensen: It has it upsides

16:35 mebaran151: esp, working Interfaces instead of Inheritances

16:36 Clojure encourages you not to overdetermine your design

16:38 LauJensen: Yea Ive really come to appreciate Clojures oppinionated design

16:38 thought I still miss reader-macros occasionally

16:39 mebaran151: I'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:39 if you AOT your clojure code, does it ever run the compiler?

16:39 LauJensen: mebaran151: I think it is, but at least with the common android versions, Clojure is just too slow in terms of GC and allocation

16:39 a_strange_guy: only if you use eval

16:40 mebaran151: even fancy stuff like defrecord?

16:40 and extend?

16:40 a_strange_guy: hmm

16:40 extend could pose a problem

16:40 LauJensen: mebaran151: I think all of that it compiled up front, but I'd have to check to be sure

16:40 mebaran151: because technically it does create a new interface

16:40 a_strange_guy: i think extend uses eval

16:41 no defprotocol creates a new interface

16:41 vIkSiT: hmm, are there any projects on that look at improving clojure speeds compared to pure java?

16:41 a_strange_guy: and this interface gets created AOT

16:41 LauJensen: a_strange_guy: I dont think its calling eval

16:42 a_strange_guy: vIkSiT: look at the new prim branch

16:42 vIkSiT: ah you mean the primitive supports feature rich is working on..

16:42 a_strange_guy: yes

16:43 dnolen: vIkSiT: deftype and statics will get you very *close* to Java perf.

16:43 vIkSiT: dnolen, right.. i think i read on cgrand's blog about <5% perf differences

16:43 a_strange_guy: actually it gets you not close, but to java

16:43 vIkSiT: so I guess thats good

16:43 LauJensen: vIkSiT: What kind of projects do you mean ?

16:43 vIkSiT: a_strange_guy, as in?

16:44 LauJensen, 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:44 was just wondering whats being done to resolve that..

16:44 a_strange_guy: nothing on the clojure side i think

16:44 clojure relies on a good JIT

16:45 LauJensen: vIkSiT: 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:45 a_strange_guy: yes actually, its the persistent datastructures thats high on allocation

16:45 vIkSiT: so you're saying that the JVM is the main issue rather than the language itself?

16:45 LauJensen: And thats why JAva has no problem

16:45 hircus: LauJensen: is this compared to Android 2.1 or 2.2? 2.2 finally has a JIT

16:45 LauJensen: vIkSiT: Its a combo

16:45 hircus: 2.1

16:45 hircus: it surprised me, but Android 2.1 and below actually has no JIT at all

16:45 vIkSiT: I see. and the contribution of JVM vs language specifics to this point - the JVM has a greater role to play, do you think?

16:46 LauJensen: vIkSiT: If you saw my Fluid Sim that was my best swing at fast math in Clojure, dunno how a Java version would roll

16:46 hircus: but 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:46 vIkSiT: LauJensen, indeed, I did..

16:46 LauJensen: hircus: Thats definitely a hint, that the time is not for functional programming on mobile devices

16:46 And it makes sense, its only in recent years its started making sense for industry use, imo

16:47 hircus: I agree. still, it's just a matter of time. my smartphone is already faster than my desktop from 10 years ago

16:47 LauJensen: Indeed

16:47 quotemstr: mebaran151: Yeah, Java seems much better these days. The last time I used Java itself in anger, there were still no generics.

16:47 LauJensen: And Clojure is picking up speed

16:48 a_strange_guy: the problem is not speed, but memory

16:48 LauJensen: a_strange_guy: ?

16:48 a_strange_guy: most mobile devices have very tight memory constraints

16:48 quotemstr: a_strange_guy: Right; CPU cycles are cheap. RAM is still dog-slow.

16:49 LauJensen: a_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:49 On desktops, the trade-off is good, on mobiles, no so much

16:49 hircus: quotemstr: java generics are horrrible, though. I wish they bite the bullet and change the bytecode language

16:49 a_strange_guy: it's hard to build a fast GC that can work in memorythight situations

16:49 quotemstr: On that note, what are the complexity guarantees for Clojure's map structure?

16:50 LauJensen: a_strange_guy: I think its just a matter of making Cliff Clicks morning coffee a little stronger

16:50 a_strange_guy: xD

16:50 LauJensen: quotemstr: Chousuke actually compiled a good list of all the datatypes, lemme see if I can find it

16:50 hircus: quotemstr: most operations that are linear in a hashmap are log_32(n) instead of linear

16:50 LauJensen: http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html

16:50 quotemstr: LauJensen: Nifty. Thanks.

16:51 a_strange_guy: and our maps can actually be faster than javas HashMap

16:51 on look up

16:51 quotemstr: Surprise, surprise, Opera barfs on that table.

16:52 a_strange_guy: they have perfect hashing AFAIK

16:52 LauJensen: quotemstr: try conkeror

16:52 quotemstr: LauJensen: I've been meaning to get around to it.

16:52 Why would nth on a vector be near-constant instead of constant?

16:52 a_strange_guy: yes

16:53 LauJensen: quotemstr: No I think lookups are constant

16:53 vIkSiT: ... was just about to ask quotemstr's question :)

16:53 a_strange_guy: near-constant == log32(n)

16:53 LauJensen: yep

16:53 dnolen: quotemstr: because vectors in clojure are trees, near-constant

16:53 quotemstr: a_strange_guy: O(log32(n)) is still O(log(N)), which is not constant.

16:53 vIkSiT: and I guess the reason is because they're trees

16:53 quotemstr: So how is a vector different from a sorted-map with integer keys?

16:53 hircus: quotemstr: it's not in theory, but in most real-life use cases, it practically is

16:53 vIkSiT: hmm

16:54 a_strange_guy: clojures hashmaps have a better worst case behaviour

16:54 quotemstr: Err, nevermind.

16:54 I should read the legend. :)

16:54 hircus: I believe that internally, they're not that different, as you hinted at

16:54 a_strange_guy: quotemstr: not much difference

16:55 hircus: There was a recent push in Python to get a BTree-based list/vector/set/dict implementation similar to Clojure's (though not immutable)

16:55 a_strange_guy: vectors & maps have the same basic structure

16:55 hircus: it sadly failed to get adopted as the standard, but is available for download. quite nice

16:55 quotemstr: non-persistent vectors should be truly linear, right?

16:56 Or, rather, they *could* be.

16:56 a_strange_guy: actually it would make them slower

16:56 because transient => persistent is constant time

16:56 hircus: if they're based on a btree, yes, they'd be slower. but much easier to copy

16:57 a_strange_guy: mutable B-trees are a pain in the ass to get threadsafe

16:57 this is maybe the reason, why they aren't in python

16:58 hircus: probably not a major problem for Python, since "multithreading" there is not very effective anyway

16:58 LauJensen: ...and officially discouraged

16:58 hircus: I 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:59 a_strange_guy: copying them is a lot faster

16:59 because you can do COW

16:59 quotemstr: Bah, multithreading in the conventional sense ought to be discouraged anyway.

17:00 Mixing preemptive concurrency and shared memory is a Bad Thing

17:00 .

17:00 STM or message-passing is the way to go.

17:00 a_strange_guy: and HAMTs are generally faster on big keysets for dictionaries

17:00 hircus: could 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:00 a_strange_guy: quotemstr: you forgot CSP

17:01 hircus: true; 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:01 LauJensen: OCalm really blew me away on the Wide Finder II challenge though

17:01 a_strange_guy: LauJensen: not surprinsing

17:01 LauJensen: 2 threads as I recall, one reader and one thinker

17:01 quotemstr: a_strange_guy: Isn't CSP just message-passing?

17:02 hircus: Cooperative threads are often *much* more efficient.

17:02 hircus: quotemstr: 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:02 a_strange_guy: quotemstr: maybe, but pretty different from Actors

17:03 quotemstr: hircus: I believe scalability is best achieved at a much coarser granularity.

17:03 a_strange_guy: LauJensen: OCaml has really good IO

17:03 hircus: LauJensen: yup. and JoCaml too -- JoCaml actually has an interesting concurrency model.

17:03 quotemstr: a_strange_guy: Hrm, I'll have to read up on it.

17:03 LauJensen: a_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:03 Clojure was 8:14, Java 12, Scala 13, IIRC

17:04 Single threaded C was something like 10 or 11 minutes, which also blew me away

17:04 a_strange_guy: OCaml is the C of FP

17:04 quotemstr: hircus: 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:04 hircus: quotemstr: 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:05 quotemstr: hircus: Sure, but multithreading in Clojure would be *even faster* if it didn't have to deal with atomic operations and mutexes for synchronization.

17:06 hircus: does Clojure use mutex much, though, in practice?

17:06 a_strange_guy: multiprocessing nowadays is a synonym for "We just use the DB for synchronization" IMHO

17:06 LauJensen: hircus: Cells are based on mutexes AFAIK

17:06 hircus: LauJensen: ah, ok

17:06 a_strange_guy: or on threadlocals

17:07 LauJensen: ?

17:07 a_strange_guy: got that wrong

17:07 quotemstr: thread-locals aren't free either.

17:07 a_strange_guy: not based , but behave thread local

17:08 checking the current thread is basically free

17:08 quotemstr: It'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:08 I don't know how feasible that would be in the JVM though. :)

17:08 mebaran151: quotemstr: I'm sure forking is always the best idea for code genning programs like the JVM

17:09 tomoj: LauJensen: but there's a 3:11 result

17:09 LauJensen: tomoj: who?

17:09 mebaran151: forking 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:09 quotemstr: mebaran151: Well, let's say a "fiber" is a Clojure thread of control, and that in a given "fiber group", fibers schedule cooperatively.

17:09 a_strange_guy: quotemstr: you can run two different Apps in the Same JVM process

17:10 so no need for forking

17:10 quotemstr: mebaran151: 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:10 a_strange_guy: Ah, that's pretty much what I had in mind.

17:10 tomoj: LauJensen: C http://wikis.sun.com/display/WideFinder/Results

17:10 mebaran151: quotemstr: you're just looking for green threads

17:10 quotemstr: mebaran151: More like an N:M model actually.

17:10 mebaran151: I thought there was a JSR to implement them

17:10 tomoj: or aren't you talking about elapsed times?

17:10 LauJensen: tomoj: I was - Am Im very disappointed to see Scala is now faster than Clojure again

17:11 (and OCalm)

17:11 mebaran151: usually, though the fastest programs aren't written in real Scala style

17:11 LauJensen: mebaran151: same for Clojure

17:11 mebaran151: really fast Scala is basically Java with some type inference :)

17:11 tomoj: wonder why clojure isn't on there

17:12 LauJensen: Would be ideal if (reduce make-stats (slurp "apache.log")) would run in 3 minutes flat

17:12 tomoj: Yea I dont know why tbray didnt add it

17:12 mebaran151: I think the inflection of fast clojure is closer to real clojure than the inflection of fast Scala is to real clojure

17:12 *real Scala

17:12 LauJensen: mebaran151: impossible

17:12 mebaran151: impossible?

17:12 a_strange_guy: it's the other way around

17:12 LauJensen: Scala is Java with added features, so Scala code formed exactly like Java is still idiomatic Scala

17:13 mebaran151: to write fast Scala, you basically have to forgo all its cool features

17:13 my understanding is fast Clojure is pretty macro heavy

17:13 LauJensen: mebaran151: for primitive math, yes

17:13 dnolen: mebaran151: not anymore

17:13 LauJensen: dnolen: calm down, its still a branch

17:14 dnolen: LauJensen: heh. a suprisingly fast branch

17:14 LauJensen: dnolen: no doubt about it

17:14 But the reality is still, that Clojure cannot pass primitives between functions

17:14 thats true for 1.1 the last stable release, and 1.2 SNAPSHOTS

17:15 a_strange_guy: I don't think you can actually compare a program in a statically typed language with one written in a dynamic language

17:15 LauJensen: a_strange_guy: sure you can :)

17:15 dnolen: mebaran151: 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:15 a_strange_guy: the program in a ST lang is cast in cement

17:16 one in a DT lang can be updated at runtime

17:16 danlarkin: How 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:16 a_strange_guy: danlarkin: you wrap it

17:17 a LBQ is basically a pipe

17:17 danlarkin: a_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:18 a_strange_guy: you shouldn't use a blocking anything in a transaction

17:19 danlarkin: Hm

17:19 Chousuke: maybe you could use an agent somehow?

17:19 codemonsta: can anyone expound on Scala's shortcomings?

17:20 mebaran151: it's a little overengineered and schizophreni

17:20 a_strange_guy: codemonsta: i program a lot in it

17:20 danlarkin: a_strange_guy: I suppose you're right about that

17:20 a_strange_guy: and I can tell you my pet peeve

17:20 mebaran151: I got frustrated with implicits

17:20 a_strange_guy: yeah, implicits are a really, REALLY evil idea

17:21 quotemstr: Implicits?

17:21 a_strange_guy: in Scala

17:21 quotemstr: I don't know Scala. I suppose I'll RTFM. :)

17:21 mebaran151: extensions methods in C# are saner

17:21 if less Type Friendly

17:21 a_strange_guy: Type-friendly?

17:22 codemonsta: I can't tell what programming model scala is trying to present. OO? Functional? Some mixture?

17:22 mebaran151: somehow, implicits are a purer way to handle type conversions and extensions if you're a type theorist

17:22 a_strange_guy: static-polymorphism just fucks up my understanding of code

17:22 Chousuke: codemonsta: it's "multiparadigm"

17:23 mebaran151: the problem as I see it is OO is all about state, while functional programming is all about getting rid of state

17:23 a_strange_guy: IMHO a type system should not change the semantics of my code

17:23 mebaran151: I agree

17:23 codemonsta: Chousuke, so how do I pick a paradigm?

17:23 Chousuke: codemonsta: but I think they like to advertise as a fusion of functional and OO programming or something

17:24 a_strange_guy: IMHO, OO is not about state and FP about statelessness

17:24 quotemstr: Implicits look like C++ one-argument constructors from hell.

17:24 codemonsta: i would think a programming language should have one primary programming model

17:24 Chousuke: codemonsta: hmmh

17:24 a_strange_guy: FP is the style of programming, where you pass around behaviour

17:24 Chousuke: codemonsta: common lisp doesn't, and it's fine

17:24 codemonsta: for example, C++ is multi-paradigm, but primaily OO

17:24 a_strange_guy: C++ is not OO

17:25 quotemstr: a_strange_guy: But you can write OO code in C++.

17:25 codemonsta: it quite is

17:25 or at least tried to be

17:25 Chousuke: Actually CL is probably the only "true" multi-paradigm language I can think of

17:25 a_strange_guy: well if you redefine OO first

17:25 codemonsta: I guess I'm talking more abount 'intentions'

17:25 quotemstr: a_strange_guy: What definition of OO can you construct that excludes C++?

17:25 Chousuke: quotemstr: message passing OO :P

17:26 codemonsta: I'll grant that CL is effectively multi-paradigm

17:26 so is scala trying to be like CL?

17:26 Chousuke: codemonsta: I'll assert that it's the only one that's *effectively* multi-paradigm :)

17:26 mebaran151: I don't think you see that many multiparadigm CL programs though

17:27 if you take out the CLOS, you use the CLOS through and through

17:27 a_strange_guy: quotemstr: runtime types, and polymorphism on them

17:27 mebaran151: you might do some functional things, but your basic building block is objects

17:28 what do you mean by runtime types?

17:29 codemonsta: here's a key question, how difficult is it to do pure FP in scala?

17:29 a_strange_guy: what is the runtime-type of, say.. int?

17:30 mebaran151: a_strange_guy: by that definition I could argue that Haskell is OO

17:30 it's polymorphic, and everything gets a type (which is verified beforehand)

17:30 a_strange_guy: mebaran151: haskell has no runtime polymorphism

17:30 mebaran151: well it has no casting

17:31 so there's no real polymorphism to be had at runtime

17:31 a_strange_guy: because you cannot get the types at runtime

17:32 it's basically as OO as C

17:32 mebaran151: gobject would say those are fightin' words

17:32 :)

17:33 codemonsta: as OO as C if C had C++ templates

17:33 a_strange_guy: gobject is a OO DSL on top of C

17:33 quotemstr: You can trivially construct an object system in C out of structs and function pointers.

17:34 a_strange_guy: but it is not the same as Lisp without CLOS

17:34 quotemstr: Same goes for Lisp and defstruct.

17:34 mebaran151: btw have you seen valhalla? it's the way I write C these days when I have to

17:34 it's like C# without all the extra noise

17:34 quotemstr: I've seen Valhalla but I haven't used it. Isn't it tied to gobject?

17:34 a_strange_guy: lisp was already OO in the 60ies

17:35 mebaran151: sorry vala

17:35 quotemstr: Err, I'm thinking Vala.

17:35 mebaran151: yeah I used it for two little tiny patches

17:35 it was actually pretty nice

17:36 a_strange_guy: Vala is like Java/C# without the VM

17:36 quotemstr: How does it manage memory?

17:37 mebaran151: it doesn't

17:37 quotemstr: Reference counting? GC?

17:37 mebaran151: Does it require a runtime library, or does the compiler translate straight to C?

17:37 a_strange_guy: Reference counting

17:37 quotemstr: a_strange_guy: No cycle collector, I imagine?

17:37 a_strange_guy: Runtime Library == GObject

17:38 dunno

17:38 mebaran151: it's basically straight C with ref counting

17:38 quotemstr: Nope, no cycle collector.

17:38 mebaran151: like Objective-C super light

17:44 quotemstr: Yuck. Vala uses checked exceptions.

17:44 mebaran151: it's better than raw C

17:44 kind of like it over Objective C too

17:44 I never did get used to [] for method invocation

17:44 quotemstr: Yeah, Objective C is one of the ugliest languages I've ever seen.

17:45 a_strange_guy: the []'s werent so bad

17:45 i actually liked them

17:45 mebaran151: it's like all the problems of Ruby and all the problems C in one language

17:45 codemonsta: what really pisses me off about scala is the braces

17:45 mebaran151: I'm ambivalent to braces

17:45 a_strange_guy: what i didn't like were the + and - as modifiers

17:46 mebaran151: I think I've hardwired my brain to map [] to collections

17:46 codemonsta: java programmers place them completely wrong

17:46 python does it right

17:46 no braces because they're redundant with proper formatting

17:46 mebaran151: a_strange_guy: yeah the + and - protection was a little bit annoying

17:47 codemonsta: similar to obj-c?

17:47 mebaran151: I often thought of writing an editior mode where the parens were invisible and it was all done based on proper highlighting

17:47 *proper formatting

17:47 codemonsta: that would be cool

17:47 mebaran151: I wrote made myself a draft of what it would parse

17:47 and I didn't like it

17:47 I missed my parens

17:48 codemonsta: did you include the : to put a newline on the same line?

17:48 python uses : really well

17:48 mebaran151: nope, just invisible parens

17:48 though if you called something inside a line you could see it

17:49 codemonsta: I really do like the idea of meta expressions

17:49 mebaran151: lines looked like map #(inc %1) col

17:50 codemonsta: sexpr is great, but it seems like it should be optional rather than the default

17:50 mebaran151: you'll miss them :)

17:50 (f 23) really makes it easy to track funcalls once you get use to it

17:50 codemonsta: well, everything should compile down to sexprs

17:51 mebaran151: f 23 was a little harder to follow

17:51 tomoj: what is (f 23) ?

17:51 codemonsta: with mexprs it'd just be f(23)

17:51 42

17:51 tomoj: oh, the syntax of it you mean?

17:52 codemonsta: but I guess noone figured out what a proper mexprs system would look like on top of lisp

17:52 tomoj: that's because "a proper mexprs system on top of lisp" doesn't have a referent

17:52 :P

17:53 codemonsta: no such thing, you mean?

17:53 tomoj: yeah

17:53 mebaran151: you'd have an artificial difference between your data structures and your program

17:53 (f 23) is really just a list

17:53 f(23) is syntax

17:54 tomoj: I'd heard that "we should get rid of all these damn parentheses" was common, but had never actually observed it in the wild

17:54 codemonsta: sure, but f(23) could easily compile down to (f 23), faik

17:54 mebaran151: I'm not sure how macros would look to an mexpression engine; it would probably just make them into sexps

17:54 codemonsta: *afaik

17:54 presumably you'd have a mode where you can write sexprs directly

17:55 just have to denote it

17:55 i dunnp

17:55 :)

17:56 i just prefer a python level of syntax

17:56 mebaran151: f(32) actually seems like syntactic sugar for (cons f '(23))

17:56 to the macro engine that is

17:58 codemonsta: hehe

17:58 should be 'software is just degrees of broken'

18:01 Chousuke: or you could say that pure math is black and white, while software is the shades of gray :P

18:45 hsjunnesson: So 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:46 Chousuke: what is written in the file?

18:46 hsjunnesson: My 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:46 It's a hierarchical datastructure which I read in and instance objects trees from.

18:46 Just standard clojure expressions.

18:46 Chousuke: is it "{:class Composite}" or {:class 'Composite} that's written in the file?

18:47 hsjunnesson: {:class Composite)

18:47 } rather

18:47 I figured that since I make sure to have imported the proper Composite, that should still work.

18:47 Chousuke: Okay, so reading that will give you a map with a symbol, but evaling the read result should give you the Class instance.

18:48 if that's not happening, then something weird is going on

18:48 hsjunnesson: Right now I just (read) it, but I'll try evaling.

18:49 Chousuke: eval is somewhat dangerous though

18:49 do it only if you trust the data

18:49 if you accept untrusted input, someone could send you {:class (take-over)} :P

18:50 hsjunnesson: Absolutely, I'm not a fan of that.

18:50 I know there are sandbox libraries out there though. I might have to take a look at them.

18:50 Chousuke: so in any case the safest choice is to work with the data structure without evaling them

18:50 and just resolving the symbols manually

18:51 hsjunnesson: Evaling 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:51 Chousuke: you might want to have your own customised "eval" that takes the read form, checks it for validity and produces a suitable "evaluated" form

18:53 hsjunnesson: Maybe 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:53 Chousuke: well that'll work too

18:54 hsjunnesson: Although I want to, eventually, make these files into a DSL, so I guess I'll have to eval them...

18:55 Thanks for your help Chousuke

20:03 duck1123: In 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:04 I probably also mention I'm giving lein another shot as well

20:05 vIkSiT: hi all

20:07 anyone awake? :)

20:07 I 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:08 the REPL shows me a warning of the type: protocol #'ns/A is overwriting method myfn of protocol B

20:09 does this mean that these 2 functions are *not* different anymore, when used with different kinds of records?

20:11 dakrone: you could separate their namespaces

20:12 vIkSiT: dakrone, hmm, within the same file?

20:13 dakrone: if you want them in the same file you can use (in-ns)

20:14 vIkSiT: dakrone, hmm I see. so basically each ns can only have on function of the same name, even within different protocols?

20:15 dakrone: yes, assuming you're using 1.2, it's last-var-wins (unless it's changed since I've checked)

20:16 vIkSiT: yes, 1.2

20:16 tomoj: otherwise, suppose you had protocols A and B and you gave implementations for both for Foo

20:16 how would it know which to use?

20:16 vIkSiT: hmm true, but only if I gave both for foo, right?

20:16 what if i ensured that i was using foo1 and foo2

20:17 tomoj: I think that could be done

20:17 overriding a protocol fn would just merge the dispatch map

20:17 but it seems silly

20:18 vIkSiT: hmm, yeah. I'm just loathe to have multiple files with different namespaces

20:18 for a few protocols

20:18 dakrone: really? why?

20:18 tomoj: it's no different than having to have multiple files with different namespaces when you want two different functions with the same name...

20:19 just for a couple functions you have to do this

20:20 vIkSiT: well, 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:21 technomancy: Leiningen 1.2.0 RC1: http://groups.google.com/group/leiningen/browse_thread/thread/376cd07e274130d7

20:22 give it a try! 95%suckage reduction in the repl task.

20:22 dakrone: technomancy: hurray, awesome!

20:23 duck1123: nice. I just got my app working with lein today

20:31 technomancy: cool

20:32 vIkSiT: sigh ok. I think I need to move out from single files to multiple clj files :)

20:32 what would you guys recommend as the best way to manage (and build) a multi file clojure project?

20:32 lein?

20:32 clojurebot: the leiningen screencast is on full disclojure: http://vimeo.com/8934942

20:36 dakrone: yea, lein is a good tool

20:38 technomancy: 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:39 technomancy: oh, of course... that just gets the html

20:39 thanks

20:39 dakrone: np

20:41 vIkSiT: hmm. I remember some conversations about clojure-swank-project being removed?

20:41 how would I get a REPL to a lein project directory, btw?

20:48 technomancy: vIkSiT: just "lein repl". works best in the latest RC rather than 1.1.0 though

20:48 or lein swank followed by M-x slime-connect; see the swank-clojure readme

20:49 vIkSiT: technomancy, indeed, I tried the second option with the latest lein (using lein upgrade), and SLIME 20091016

20:49 get some errors. trying again

20:49 (I ran lein swank in the project / directory, and tried to use slime-connect on and 4005

20:50 technomancy: try upgrading slime; the 2009 version might not work with the latest swank

20:50 vIkSiT: ah

20:50 is there an easy way to do this upgrade btw?

20:50 * vIkSiT checks elpa

20:52 vIkSiT: technomancy, does elpa automatically "upgrade" a package?

21:00 dnolen: technomancy: nice, 1.2.0 repl!

21:20 vIkSiT: technomancy, around?

21:21 I 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:21 TimMc: rhickey: 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:22 (well, 'nil is read as nil -- mis-spliced some thoughts)

21:28 vIkSiT: hmmm. has anyone actually done the latest slime/swank install on emacs?

21:35 gah.

21:43 dnolen: vIkSiT: it might be simpler to just delete ~/.emacs.d/elpa and start fresh

21:43 vIkSiT: dnolen, I'm seeing inconsistencies even with a new install

21:44 for instance, the version references for slime in swank-clojure are to 200910.. not 201004..

21:44 (inside archive-contenst in elpa)

21:45 dnolen: just erase your elpa folder and reinstall elpa package.el from scratch

21:45 vIkSiT: (I did)

21:47 dnolen: vIkSiT: what is listed when you package-list-packages, 201004 ?

21:47 vIkSiT: yes

21:47 dnolen: erase slime in your elpa dir, and try installing 201004

21:47 vIkSiT: hmm

21:48 I've tried that. I installed slime 201004, slime-repl same version

21:48 at that point installing swank-clojure just keeps telling me that "file clojure-mode" already exists

21:49 ok, so i've deleted everything (including elpa)

21:49 is there an order in whicih the packages should be installed?

21:50 dnolen, for instance, slime before clojure-swank, etc?

21:50 or can I just select all I want?

21:58 dnolen: vIkSiT: try just installing swank-clojure.

22:03 vIkSiT: dnolen, nope no luck

22:03 my problems seem like this thread: http://www.mail-archive.com/clojure@googlegroups.com/msg22598.html

22:04 but thats windows specific, and i'm on OS X

22:04 http://paste.lisp.org/display/111384#1

22:04 those are the errors I get

22:05 on a) removing elpa. b) installing elpa by evaling the script, and c) selecting swank-clojure, and d) installing it.

22:11 dnolen: vIkSiT: those just look like warnings - what version of Emacs are you on? what happens when when you run M-x slime ?

22:12 vIkSiT: I'm on emacs 23.11

22:12 I can't even run m-x slime

22:12 its not a valid option

22:12 after doing all of that, I can't even start emacs properly.

22:13 if you look at that lisppaste

22:13 the error message is poasted right above the warnings you saw

22:13 http://paste.lisp.org/+2DY0

22:15 sigh. all this was fine when I was using slime200910

22:16 dnolen: vIkSiT: in your .emacs package.el writes some crap

22:16 erase that, erase your .emacs.d/elpa

22:16 try again

22:17 I ran into this problem as well

22:17 it's important to only install swank-clojure, it installs clojure mode and slime, slime-repl

22:18 vIkSiT: hmm

22:18 dnolen: very unfriendly, but it seems like the elpa maintainer is fairly unresponsive.

22:18 technomancy: vIkSiT: there is a bug in package.el that can prevent packages from being installed if older versions of its dependencies are present.

22:18 vIkSiT: ok, removed .emacs*

22:18 technomancy: I've fixed it in my fork of package.el, but it hasn't been integrated upstream yet. i_i

22:19 vIkSiT: hmm :)

22:19 technomancy: luckily it sounds like the fixed version will probably be integrated into the Emacs 24 codebase very soon.

22:19 vIkSiT: whew for that

22:19 hmm ok

22:19 so on deleting .emacs* (moving it anyway)

22:19 loading elpa and then selecting only swank-clojure

22:20 http://paste.lisp.org/display/111384#2

22:20 technomancy: vIkSiT: those are just warnings; it should work correctly.

22:20 vIkSiT: hmm the last line too?

22:20 swank-clojure.el:47:1:Error: Cannot open load file: slime

22:21 technomancy: yeah, it just means it won't get byte-compiled. it'll work fine in interpreted mode.

22:21 the slime developers are really sloppy. =\

22:21 vIkSiT: ohh.

22:21 good lord

22:21 technomancy: yeah.... lots of room for improvement there.

22:21 vIkSiT: btw, does swank-clojure support color-theming on the REPL now?

22:22 technomancy: hmm... someone submitted a patch for that which has been applied

22:22 vIkSiT: yes I used to apply that patch manually

22:22 technomancy: but I haven't tried enabling it yet, and I don't think they submitted docs for it.

22:22 vIkSiT: doesn't look it works though

22:22 oh enabling it.

22:23 technomancy, is that clojure-font-lock-setup?

22:24 technomancy: probably

22:24 I am not actually a dev on the slime project; otherwise I would look at cleaning up those nasty compilation warnings.

22:25 they're crusty old CL'ers that aren't always too friendly towards upstart "hype-ridden" lisps though. =)

22:26 vIkSiT: hehe

22:29 dnolen: I'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:30 wdouglas: They're just mean in general

22:30 I've watched the slime-dev list for years

22:31 Tobias is nicer than Helmut at least, but they know what they are doing, just are set in their ways

22:31 dnolen: These 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:33 certainly wasn't the case 2 years ago.

22:33 vIkSiT: ugh is there a way to get rid of those warnings in the namespaces, when loading clojure?

22:34 dnolen: vIkSiT: what warnings?

22:35 this is pretty cool: http://data-sorcery.org/2010/06/12/incanter-executables/

22:35 vIkSiT: on 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:36 lots of these messages

22:36 and slime is now taking ages to startup!

22:40 technomancy: vIkSiT: swank 1.2.1 doesn't give any warnings, but possibly one of your other dependencies still does

Logging service provided by n01se.net