#clojure log - Oct 14 2011

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

0:02 ibdknox_: dnolen: yeah, there's some stuff in pinot to help with it. I went direct to the JS API... the gclosure stuff was ridiculous

0:03 dnolen: I need to switch it off of using seqs, but I haven't done that yet

0:36 jcromartie: you know, it's *really* hard to have an off-by-one error, or an infinite loop, when you're dealing with seqs

0:36 unless you make an infinite seq of course

0:37 so I guess that's not that hard

0:37 ... derp

0:41 amalloy: jcromartie: the fact that you can say "having an infinite sequence is not that hard" is a testament to how much easier things are in clojure

0:43 jcromartie: heh

0:44 but yeah, I'm just meditating on the nature of bugs

0:44 most of the bugs that come along in production are a failure to coordinate mutable state

0:44 (in our system)

0:45 things like off-by-one, or = instead of ==... those are the easy ones

0:45 those get caught early and often

0:46 but the subtle bugs that slip under the radar are almost *always* mutable state

0:46 amalloy: OBO is a special case of having to manage mutable state, of course

0:47 jcromartie: well OBO doesn't have to be mutable

0:47 &(range 1 5)

0:47 lazybot: ⇒ (1 2 3 4)

0:47 amalloy: i guess that's true

0:47 but at least a majority of the time, OBO comes from a for loop somewhere

0:47 jcromartie: yes ;)

0:48 but anyway, I'm totally sold on the following ideas:

0:48 1) pure functions are better than assignment/mutation whenever it's even remotely practical

0:49 2) the best kind of data system is one that treats inputs as immutable, and where the current state is just derived from that historic data

0:49 so I'm putting that together now

0:50 (nathanmarz's recent post is prescient)

0:50 Apage43: anything you're -not- sold on? That might be more interesting to discuss.

0:50 jcromartie: Apage43: NoSQL databases :)

0:50 Apage43: oh fun

0:50 I work for a NoSQL company

0:50 jcromartie: Apage43: "cloud" platforms

0:51 Apage43: oh, no offense of course :)

0:51 which one?

0:51 Apage43: eh

0:51 jcromartie: I actually like CouchDB and Mongo

0:51 Apage43: i largely am annoyed by the way its marketed

0:51 jcromartie: Couchbase

0:51 jcromartie: but I think they are squarely in the "mutable by default" camp

0:51 so are most RDBMS

0:51 Apage43: formerly at Couchone/Couch.io

0:52 jcromartie: I think I like Couch a lot, actually

0:52 Apage43: jcromartie: well, i mean, it -is- a datastore

0:52 jcromartie: sure

0:52 but someone let me know when a (popular) datastore comes along that never loses anything, by default

0:52 Apage43: Couch is nifty in the way it makes available metadata about the stuff that happened to the database over time to get it to the state its currently in

0:53 jcromartie: sure but it disappears

0:53 doesn't it?

0:53 Apage43: it does if you run compaction

0:53 jcromartie: right

0:53 Apage43: you have the option, if you want, -never- to run compaction

0:53 jcromartie: huh, interesting

0:53 but that doesn't let you use the history itself to re-define the state

0:53 Apage43: you can access previous revisions of documents as long as you haven't cleaned them up

0:53 jcromartie: yeah

0:54 I thought that was pretty cool, but then I realized you can't count on it

0:54 Apage43: nah

0:54 we very explicitly tell people not to count on it

0:54 if you want revisions you should save the old version explicitly

0:55 but you could definitely build something really close to couch that did what you wanted

0:55 since it is a log-structured btree

0:55 jcromartie: yeah

0:55 embed the old version in the new version

0:55 Apage43: very similar to clojure's datastructures

0:56 attachments at least work that way

0:57 so do the indexes

0:57 but none of that is really a user-facing feature

0:58 jcromartie: I'll see how well my toy journaled datastore works, and then put it out there. The big idea is that the history never goes away, and that when you change the commands that were applied to derive the current state, you can just replay the journal.

0:58 so, for example

0:58 you have a command, like (set-user-password my-db "jcromartie" "foobar")

0:58 that gets journaled

0:58 Apage43: I find log-structured/journaled stuff pretty fun to think about in general

0:59 amalloy: brehaut: https://gist.github.com/1286289 is 4clojure's code-golf fever gone mad

0:59 jcromartie: and set-user-password does something like (defn set-user-password [uid pw] (update-in state [:users key] assoc :password pw))

0:59 BTW this is not how I'd do it :)

0:59 so it just sticks the password in there

1:00 now what if you want to go to SHA-1? (assume you encrypt the journals, or something like that)

1:00 (bad example, I know)

1:00 so you change set-user-password, and reload your db

1:00 now (set-user-password my-db "member:jcromartie" "foobar") gets re-applied

1:00 and you store the SHA-1

1:01 OK now you want a password policy that says you can't use the same password twice

1:01 so you update set-user-password to store the password hash in a set in the user value

1:01 re-run the journal again

1:01 and you have your user objects with their full history of password hashes

1:02 no problem

1:02 Apage43: course anyone with read-access to the journal has the plaintext

1:02 jcromartie: now, again, I'm not advocating passing plaintext passwords and other sensitive info to get journaled... but that's a problem that any datastore has

1:02 Apage43: yeah =P

1:03 jcromartie: but you can also go into the jorunal

1:03 journal

1:03 if you *truly* have bad data

1:03 because the journal is just code, too, it can be parsed and processed

1:03 with the same tools as any other data structure

1:03 handy-dandy :)

1:03 anyway, the trick will be seeing how this scales

1:04 I did 100K simple transactions... they read back in in about 4 seconds

1:04 but 100K is peanuts for a big application

1:04 Apage43: and concurrent access is a seperate problem as well

1:05 jcromartie: that can be solved at a higher level

1:05 and this just uses refs for the db state

1:05 so they get transactions for free :)

1:05 the journal write only happens AFTER the transaction, and only if it succeeds (exceptions would cause it to fail)

1:06 and it's in order (an agent does the journal-writing)

1:07 but yeah, it's just for fun right now

1:07 anyway

1:07 goodnight

1:07 Apage43: night

2:08 hiredman: ,(+ 1 2)

2:08 clojurebot: 3

2:40 kiuma: hello

2:40 archaic: hi

2:42 kiuma: I was pondering do change a parser that I've implemented in java into a lisp one, I'm in doubt between ABCL and Clojure, I know Common Lisp. Which advantage could I have adopting Clojure in place of ABCL ?

2:44 ibdknox_: kiuma: http://blip.tv/clojure/clojure-for-lisp-programmers-part-1-1319721

3:02 chrido: hi idbknox, can i ask you something regarding postgres and timestamp with timezone?

3:04 amalloy: ibdknox_: we need an ~anyone for that

3:06 chrido: it's more polite to just ask him. your real question is unlikely to make him fly into a rage, so you don't need to ask permission

3:12 wink: then again, the problem just solved itself :P

3:16 rmrfchik: hit he bug in 1.3; where to report?

3:16 i have test case

3:26 ah, that's is defn inside defn.

3:35 thorwil: hmm, the link to the transcript on http://blip.tv/clojure/clojure-for-lisp-programmers-part-1-1319721 actually just redirects to the group

3:35 and i see no way to access the purported files section of the group

4:02 gu_: hi, is there a built in function that already does this? (fn [ks v] (zipmap k (repeat v))) (ks being a sequence and v being any value)?

4:06 amalloy: gu_: i don't think so

4:10 Blkt: good morning everyone

4:14 brehaut: amalloy: re:golf, thats mental

4:15 amalloy: brehaut: i did that just as an exercise, but some people's solutions look like that all the time

4:15 * brehaut shudders

4:16 brehaut: i havent yet tried to golf anything

4:17 dbushenko: hi all!

4:17 amalloy: aw, you're not counting the immense savings you get by typing partial less?

4:18 dbushenko: where is the clojure pattern matching library?

4:19 ok, found it: core.match

4:20 brehaut: amalloy: haha

4:21 amalloy: sadly thats been countered by some brain dead thinking blowouts

4:21 amalloy: brehaut: that's how i feel after solving chouser's recently-submitted problem

4:21 brehaut: thats the challenge that got me to start 4clojure

4:21 amalloy: nice

4:21 brehaut: (although i decided i needed to start at the start)

4:34 huh tree-seq looks really handy

4:35 amalloy: heres the other one i flubbed http://www.4clojure.com/problem/solutions/66

4:37 amalloy: brehaut: eh. i looked up the gcd algo on wikipedia

4:38 brehaut: i should have

4:38 i remember from my 100 level discrete math that euclid had a smart solution a while back

4:41 gu_: O_o suddenly clojure started interpreting docstrings as instructions failing.. any idea on what's going on?

4:46 it seems a problem with the use of single quotes in the string

5:14 raek: gu_: sounds like a missing double quote somewhere

5:28 brehaut: i just solved the game of life 4clojure problem. there are some amazing concise solutions there

8:39 jcromartie: "If I had more time I would have written less code"

8:48 gu_: hi, can you answer this question? http://stackoverflow.com/questions/7767775/clojure-when-to-use-mutable-state

9:17 hi, can you answer this question? http://stackoverflow.com/questions/7767775/clojure-when-to-use-mutable-state

9:18 jcromartie: gu_: taking a look :)

9:20 gu_: thanks. i'm trying to learn clojure and this seems to me an important non-technical topic. by non-technical i mean that right now to me it's just a matter of "doing it the most clojure-esque way possible" because in the specific program i can go either way (mutable or not)

9:28 tordmor: gu_, basically function arguments are about what you actually want to do with your function. Mutable state would be a general context. Like the figures and the background of a painting.

9:30 jcromartie: gu_: I posted my thoughts.

9:31 I hope they are coherent.

9:33 gu_: thank you! i've read it :

9:35 ljos: Does clojure have some kind of sleep without calling java?

9:37 jcromartie: ljos: is this sufficient? (defn sleep [n] (Thread/sleep n))

9:38 llasram: Huh. So `case' can't even be used with Java 'static final' constants, only literals values? That's kind of weird :-/

9:38 jcromartie: case is lower level than cond

9:39 it's faster but more restricted

9:39 llasram: jcromartie: Sure, but I still would have expected it to work with the JVM equivalent of compile-time constants

9:39 jcromartie: maybe that can be fixed?

9:39 ljos: jcromartie: it works, I just wanted to know if it was in the language.

9:42 jcromartie: llasram: you could probably make a case that works that way, actually

9:42 llasram: jcromartie: It seems like it should be possible -- the info is all available at compile-time, right? And it also seems like a really common use-case: in other languages that's probably the most common way I use that sort of construct

9:42 jcromartie: well "compile time" is loosely defined in Clojure :)

9:43 llasram: jcromartie: Yeah, it wouldn't be that hard, actually -- just a macro which evaluates all the exprs then passes that the built-in `case'

9:43 jcromartie: yup

9:43 isn't that handy :)

9:48 lnostdal_: i find myself needing off-line access to the clojure reference documentation at times; is this available somewhere?

9:49 perhaps there's a dead-tree edition available too?

9:50 raek: lnostdal_: you can clone the gh-pages branch of clojure/clojure on github

9:50 jcromartie: llasram: like this https://gist.github.com/1287160

9:50 raek: should be static html files

9:50 jcromartie: :) just for fun

9:50 I am thinking about it now, and there are probably drawbacks

9:50 but not many

9:51 raek: https://github.com/clojure/clojure/tree/gh-pages

9:52 lnostdal_: cool, didn't know about that, raek

9:52 jcromartie: actually this macro is just a bad idea

9:53 because you can't tell between any old symbol and a local binding

9:54 anyway, yeah, bad idea

9:54 don't use it

10:00 `fogus: dnolen: Thanks for kicking butt on ClojureScript. Greatly appreciated

10:04 Twey: I'm trying to play around with SWT in Clojure, but it can't seem to find my SWT classes — e.g. user=> (import org.eclipse.swt.widgets.Display) yields a ClassNotFoundException. How can I make it find SWT? I've tried running it with CLASSPATH=/usr/share/java/swt.jar (which is where the SWT jar is).

10:07 raek: Twey: try (import 'org.eclipse.swt.widgets.Display)

10:08 TimMc: Twey: (import org.eclipse.swt.widgets.Display)

10:08 urgh

10:09 raek: the claspath actually used depends completely on how you launched clojure

10:09 Twey: raek: No difference

10:09 TimMc: Twey: (import Foo) tries to evaluate the form Foo before calling import -- that's why you need to quote it.

10:09 Twey: [@ twey algiz ] % CLASSPATH=/usr/share/java/swt.jar:$CLASSPATH clj

10:09 TimMc: Ah, I see

10:09 raek: Twey: there is no standard clojure launcher script

10:09 dnolen: `fogus: np!

10:09 TimMc: Twey: I never mess around with classpath directly -- have you tried using lein?

10:10 Twey: https://github.com/technomancy/leiningen

10:10 Twey: I'm aware of its existence, but I've been skirting it ☺

10:10 TimMc: It's really, really nice.

10:10 raek: Twey: if you really need to control the classpath manually (i.e. you choose not to use a build tool like leiningen) start clojure with "java -cp clojure.jar:your_other_jar.jar clojure.main"

10:11 the launcher shell scripts that circulates on the net are pretty much only usable for "hello world"

10:12 `fogus: Breaking changes (likely) coming to ClojureScript. http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax

10:13 Twey: raek: Success! Thank you ☺

10:13 I'll try to get Leiningen working

10:14 raek: Twey: to use lein and swt you need to find a Maven artiact for SWT

10:14 then you declare it as a dependency rather than give it the jar

10:15 Twey: >.<

10:15 raek: Twey: http://jarvana.com/jarvana/ <-- search engine for java maven artifacts

10:15 Twey: There seem to be so many cognitive dependencies for writing a ‘Hello World’ app in anything Java-based

10:16 llasram: jcromartie: Oh, actually, I'd wandered off to write my own version :-) https://gist.github.com/1287230

10:16 Twey: So… Maven is a build manager? But I thought leiningen was a build manager?

10:16 raek: well, at least maven and the clojure community share a dependency system...

10:17 Twey: yes, but leiningen uses the dependency parts of maven

10:17 Twey: Ah right

10:17 llasram: jcromartie: I don't think it's a bad idea at all, despite using `eval'. If the expression can't be eval'ed at compile time, it'll just throw an exception

10:17 melipone: help! how do i remove-duplicates but keep the order of the list?

10:17 raek: melipone: distinct

10:17 melipone: distinct does not work for me because I need to extract the name of an object

10:18 raek: ,(distinct [1 1 9 7 1 6 3 9])

10:18 clojurebot: (1 9 7 6 3)

10:18 jcromartie: llasram: yours tries to eval strings and numbers

10:18 llasram: jcromartie: Which is fine

10:18 ,(eval 1)

10:18 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

10:18 llasram: Haha

10:18 melipone: distinct does not work because I have a list of structs

10:18 llasram: Ok, anyway, it just returns the same reader-literal

10:18 jcromartie: maybe that's in 1.3?

10:19 huh weird

10:19 oh I had some other error

10:19 raek: melipone: so "equality" in your case means something else than that the structs are equal?

10:19 jcromartie: I assumed...

10:19 melipone: yes, i need to extract the name from the struct and do the equal on that

10:20 jcromartie: good catch

10:20 llasram: There probably are problems with the approach, but it's working for my case ATM. Thanks for the inspiration in the right direction :-)

10:22 Squeese: "Clojure is high signal, low noise." Im lost as to what this means

10:22 dnolen: `fogus: I don't really consider the difference much of a problem. probably worth bringing up on the ML to solicit opinions from those people already using ClojureScript.

10:23 Squeese: less ceremony.

10:23 raek: melipone: I think you need to make your own function. it should be fairly simple to make a variant of 'distinct' that compares "(f x)" instead of "x"

10:24 http://clojuredocs.org/clojure_core/clojure.core/distinct#source

10:25 Squeese: less ceremony? Omg, abstractions is totally lost on me.. ;(

10:26 Or would the correct word be metaphor? lolzlzlz brains not compute, leaving..

10:26 gamzovicov: hello

10:26 ljos: I am unable to call methods from a java class I have made myself and the stacktrace is less then helpfull. Is there anyone who know what I might be doing wrong?

10:26 I can create the object from the class though.

10:27 gfredericks: ljos: are they static or instance methods? what syntax are you using to call them?

10:27 ljos: gfredricks: instance methods. I am running (.getScore msp)

10:28 raek: melipone: something like this https://gist.github.com/1287265 (not tested)

10:28 gfredericks: ljos: and what's the error message?

10:28 jcromartie: Squeese: ok let's slow down

10:28 raek: (distinct-key :name structs)

10:28 ljos: Exception in thread "main" java.lang.NullPointerException at mspacman.NUIMsPacman.getScore(Unknown Source)

10:28 jcromartie: Squeese: compare Java's "hello world" with Clojure's

10:29 Twey: Hmph

10:29 gfredericks: ljos: sounds like the method is getting called but something's going wrong inside the method?

10:29 Squeese: "Clojure is high signal, low noise" is really just saying "Less code" ?

10:29 ljos: No.. I can run it from java.

10:29 jcromartie: Squeese: now compare a transactional concurrent datastore in Java with a Clojure version :)

10:29 Squeese: not just less code, but the right code...

10:29 gfredericks: ljos: and the method doesn't take any arguments?

10:29 ljos: none

10:30 Twey: Went through all that, installed Leiningen, installed Maven, found a .jar for SWT-linux-x86_64 on jarvana, installed it using Maven, ran ‘lein deps’ ran ‘lein repl’, executed (import 'org.eclipse.swt.Display) and got… ClassNotFoundException. :þ

10:30 jcromartie: Squeese: for example, I can write an API like this in Clojure: https://gist.github.com/be1d88c9c0363e542f4f

10:30 gfredericks: ljos: and (type msp) returns your class?

10:30 Squeese: jcromartie: well, if I can write less code to do the same thing as before, thats awesome - but if its "right" will be an whole other discussion.. :P

10:30 jcromartie: Squeese: not in the sense of "logically correct"

10:30 ljos: gfredricks: yes

10:31 gfredricks: I though it might be because I was using an interface, but I imported the interface as well now and it still doesn't work.

10:31 Twey: (.. System (getProperties) (getProperty "java.class.path")) includes /home/twey/Development/Clojure/swt/lib/swt-3.7.1.jar

10:31 jcromartie: Squeese: so that example API... that would be a whole mess of class definitions in Java or C#. Or it would be a bunch of "do |x| ... end" or "{ |x| }" blocks in Ruby

10:31 Twey: Which is something Leiningen put there >.>

10:31 gfredericks: ljos: maybe you could put the full stack trace in a paste?

10:32 ljos: otherwise, calling instance methods is pretty basic, so despite your insistance I have to think the simplest explanation is a bug in the java code

10:32 Squeese: jcromartie: ok, thx :)

10:32 jcromartie: Squeese: not that Clojure is the only language you can do this in (other Lisps, etc.), but it tends to be low noise by default

10:32 raek: Twey: did you include it under :dependencies in your project.clj file?

10:32 ljos: http://pastebin.com/fyFxjr9r

10:32 gfredericks: ljos: i.e., maybe you're setting things up differently when you do it from java?

10:32 Twey: raek: [org.eclipse.swt/swt "3.7.1"]

10:33 ljos: gfredricks: how could it be different? It's a method call!

10:33 gfredericks: jcromartie: the stack trace clearly indicates that your method is being called.

10:33 ljos: sorry, ^that was for you

10:33 ljos: is it your java code? could you stub that method with "return null" and see if it succeeds?

10:33 Twey: The Maven install was done with: mvn install:install-file -DgroupId=org.eclipse.swt -DartifactId=swt -Dversion=3.7.1 -Dpackaging=jar -Dfile=/home/twey/Downloads/x86_64-3.3.0-v3346.jar

10:33 Squeese: jcromartie: Noise, is that "extra stuff needed to make x work" as in side-effects needed to handled or just more syntax todo the same thing?

10:34 jcromartie: Squeese: yeah, pretty much

10:34 Squeese: jcromartie: ah ok, cool - then Im aboard :)

10:34 jcromartie: Squeese: anything that doesn't express the solution to your problem

10:34 jkkramer: Twey: you sure org.eclipse.swt.Display exists?

10:35 Twey: jkkramer: I have no idea

10:35 How would I find out?

10:35 jkkramer: first google result is org.eclipse.swt.widgets.Display

10:35 raek: Twey: are you sure it shouldn't be org.eclipse.swt.widgets.Display?

10:35 Twey: Ah, like that

10:35 jkkramer: i don't know, presumably you're entering it for a reason

10:35 Twey: Haha :-D

10:36 Squeese: jcromartie: so, were just waiting on someone to figure out how to remove all the (((( and )))) noise and were set. :)

10:36 Twey: Yay, new error

10:36 raek: Twey: but the dependency and the classpath looks good, so I think you're all set in that area

10:36 Twey: java.lang.UnsatisfiedLinkError: no swt-gtk-1.0.0-SNAPSHOT or swt-gtk in swt.library.path, java.library.path or the jar file

10:36 ljos: gfredrics: hmmm.. Something is very wrong here... You where right. It is the method. It ran now. I think the problem is that another project that is on the path is not compiling or doing what it should.

10:36 Twey: Do I need to add that as a dependency? I thought the point of SWT was that I don't have to specify the backend

10:36 TimMc: Squeese: Then you have Haskell, which I find less readable.

10:37 jcromartie: Squeese: sure, but right now the ((( and ))) are what let you get rid of things like class definitions

10:37 ljos: gfredicks: though it does do it in java.

10:37 gfredericks: ljos: are you using maven?

10:37 jcromartie: so I'll take the parens and uniform syntax along with the ability to create any kind of syntax form I need

10:37 that's the key: forms

10:37 ljos: gfredrics: not really.

10:38 gfredericks: ljos: some build tool? or just raw command-line java/javac calls?

10:38 raek: Twey: I've heard that native dependencies (which SWT uses) can be tricky. have you looked for any tutorials on how to use SWT from clojure?

10:38 ljos: gredricks: For clojure I'm using leiningen. For java I start everything from eclipse mostly.

10:39 gfredericks: ljos: so it's something that eclipse is doing for you that leiningen isn't, does that sound plausible?

10:39 Squeese: is there a syntax disagreement within lisp as it does in "c like langs" as to where to put {, new line or not? :)

10:39 gamzovicov: i'm new in clojure and i want to lern functional programing

10:39 Twey: raek: Yes, but I just get a lot of code tutorials & not so many setup ones :-\

10:39 gamzovicov: can someone tell me a good tutorials

10:39 gfredericks: gamzovicov: 4clojure.com

10:40 raek: I've heard that the maven package system does not have a standardized way of dealing with native dependencies... :/

10:40 jcromartie: Squeese: there's a general Clojure style

10:40 `fogus: dnolen: I will definitely bring it up on the ML. Formulating a post now

10:40 TimMc: Squeese: Do what Emacs tells you. :-)

10:40 jcromartie: don't put parens on lines by themselves

10:40 yeah I was going to say

10:41 TimMc: amalloy_: There should be more real-estate-based puzzles on 4clojure

10:41 or banking :-P

10:41 jcromartie: just like Ruby style :) ... Matz uses ruby-mode

10:41 ljos: gfredricks: It does. But I'm am very unsure of what. EVerything should be on the buildpath.

10:41 Squeese: TimMc: damnit, emac keeps bugging me, Im trying to stick with Textmate.. I really have to try emacs :P

10:42 raek: Twey: found this: https://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All

10:42 TimMc: It's worth the long learning curve.

10:42 st3fan: emacs is awesome

10:42 gfredericks: ljos: I don't know too much about eclipse's magic. You could try running java from the command line to see what happens? Otherwise we're out of the realm of my knowledge

10:43 TimMc: Squeese: The most important thing is to keep a written cheatsheet handy: C-g, C-x 1, C-h a, C-x C-c... along with the paredit cheatsheet. ALso get a copy of someone else's .emacs file.

10:43 Over time you'll stop using the cheatsheet.

10:44 Squeese: TimMc: I didnt really understand what you said, but I guess I will when I learned the emac basics? Copy paste msg for later.

10:44 TimMc: Those are some examples of commands you will want to know right away.

10:44 Squeese: aha ok

10:45 Twey: raek: Ah, your Google-fu is strong. Thanks!

10:45 TimMc: Cancel, hide all but current buffer window, search help, quit.

10:45 jcromartie: Paredit is just amazing

10:46 TimMc: At the very least, paredit means only typing half the parens. :-)

10:46 jcromartie: People say Lisp code is difficult to edit. But Paredit makes editing Lisp code easier and more fluid than any other language+IDE combo I've used.

10:46 raek: clojurebot: swt?

10:46 clojurebot: Titim gan éirí ort.

10:46 jcromartie: because you can really slice and dice expressions

10:46 ljos: gfredricks: I think it is that I am casting a variable from one class to another... I don't think eclipse should do anything with that.

10:46 Squeese: TimMc: thx

10:46 raek: clojurebot: swt is https://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All

10:46 clojurebot: Ok.

10:46 TimMc: jcromartie: Yeah, if I could edit Java forms the way I can edit Lisp forms, Java would suck a bit less.

10:46 jcromartie: and in other languages, where the syntax isn't uniform, you just can't do that, even with a powerful IDE

10:47 ljos: gfredricks: but I'll see what happens when I run it form the terminal.

10:47 TimMc: M-x java-slurp-try-catch-backwards :-P

10:50 That would break declarations, though.

10:51 Twey: raek: No, I just keep getting the same >.<

10:52 TimMc: `fogus: So (. o p) would still be different in clj and cljs, but there would at least be *a way* of writing equivalent code.

10:52 raek: Twey: did you run a lein deps in between?

10:53 Twey: I did

10:54 ljos: gfredricks: I have to look at it tomorrow. I have to go now. Thanks for the help though.

10:54 gfredericks: ljos: yessir

10:54 TimMc: Twey: Doess lein classpath show the SWT jar?

10:55 raek: Twey: Are you using exactly the same deps as in the tutorial? Otherwise I'm out of advice, I'm afraid.

10:56 Twey: TimMc: /home/twey/Development/Clojure/swt/lib/swt-linux-gtk-x86_64-3.3.0.jar is in there

10:56 Squeese: is there anything I need to install extra with emacs to "support clojure" like plugin or something?

10:57 Twey: raek: No, I'm using linux-gtk-x86_64, not win32-win32-x86_64

10:57 But other than that, yes, as far as I can tell

10:57 (and no guiftw, obviously)

10:57 Fletchcutus: Have a (hopefully quick) java interop question: I'm trying to take a list of corresponding methods and call them on two different objects (testing a swig wrapper)

10:58 Twey: Squeese: You'll need clojure-mode; see if you can M-x clojure-mode, & if not you might need to install it

10:58 Squeese: ok thx

10:58 Twey: Squeese: I use the modification from ergoemacs.org which includes clojure-mode amongst other things

10:59 Fletchcutus: My first attempt was something like (map (fn [[m1 m2]] (== (. o1 m1) (. o2 m2)) [ [:o1Method :o2Method] ])

11:01 but that complains about no matching field found m1 for class (class of o1)

11:01 am I barking up the wrong tree?

11:02 gfredericks: Fletchcutus: I'm not sure there's an easy way to call java methods programmatically. Might have to use java reflection?

11:02 Fletchcutus: Eeew. :/ Same conclusion I was coming to.

11:03 gfredericks: Fletchcutus: not too hard to write a helper method for that though

11:03 Fletchcutus: yeah, a macro similar to what memfn does would prossibly do it

11:04 was just diddling in the repl trying to come up with some tests for some swig'd c++ really quick.

11:04 gfredericks: Fletchcutus: actually I think you would want exactly _not_ a macro

11:05 since a macro would require you know the name of the method

11:05 TimMc: When possible, don't put core functionality into macros.

11:06 Twey: You have looked in the jar to make sure org/eclipse/swt/Display.class is there?

11:07 raek: Fletchcutus: use = and not ==

11:07 TimMc: Twey: Are you using (import '...) from the REPL or (:import ...) in the ns form?

11:08 raek: Fletchcutus: since methods are not first class on the jvm, you need to wrap them in clojure functions

11:08 Twey: TimMc: REPL (import …)

11:08 TimMc: k

11:09 raek: (map (fn [[m1 m2]] (= (m1 o1) (m2 o2))) [[#(.m1 %) #(.m2 %)]])

11:09 TimMc: Twey: org.eclipse.swt.*widgets*.Display, maybe?

11:10 Twey: TimMc: Yep, it exists

11:10 Fletchcutus: raek: ooh, that looks promising

11:10 TimMc: under the widgets subpackage, or under swt directly?

11:10 Twey: TimMc: Under ‘widgets’

11:10 raek: Twey: what error did you get? class not found or native library thingy?

11:10 Twey: Yeah, I know, I was typo'ing that at the start — we got past that

11:11 TimMc: Ah, OK.

11:11 Twey: I've got SWT installed & working with lein now, but when I import it ((import 'org.eclipse.swt.widgets.Display) from the REPL) I get java.lang.UnsatisfiedLinkError: no swt-gtk-1.0.0-SNAPSHOT or swt-gtk in swt.library.path, java.library.path or the jar file (NO_SOURCE_FILE:1)

11:11 I'm not really very sure what that even is

11:11 Is it looking for a directory?

11:12 raek: that probably means that it doesn't find a native library

11:12 Fletchcutus: rake: that works but it's a slight bit uglier than I'd hoped for. Thanks :)

11:12 stuarthalloway: naming help requested

11:12 TimMc: stuarthalloway: "Jennifer"

11:12 Twey: raek: Yeah, that's what I figured ;) I'm just not sure what to do to make it find one…

11:12 stuarthalloway: I need a name for an exception type, to be added to Clojure, the carries along structured data

11:13 gfredericks: Stone? :)

11:13 TimMc: raek: Sounds like Display is found, but it is not finding some dep of its own.

11:13 stuarthalloway: .net gets this right, having data on the base exception type: http://msdn.microsoft.com/en-us/library/system.exception.data.aspx

11:13 TimMc: stuarthalloway: This would be ? extends Exception?

11:14 stuarthalloway: TimMc: extend RuntimeException to stay out of checked exception land

11:14 TimMc: right

11:14 raek: Twey: maybe you need to install some package in you OS? (like GTK header files or something)

11:14 I'm just guessing here

11:14 gfredericks: RuntimeExcljeption?

11:14 TimMc: terrible

11:15 stuarthalloway: this exception should be usable as a building block for different exception libraries

11:15 raek: stuarthalloway: ClojureException? ;-)

11:15 Fletchcutus: raek: actually I withdraw my ugly comment. I need to do some diddling on some methods to make the returns match up so that's actually a pretty good solution

11:15 stuarthalloway: such that the higher level libraries do not need to make a new class, and (importantly!) do not need AOT

11:15 raek: certainly on the list

11:15 gfredericks: ouch

11:16 considering StructuredException

11:16 or Mulligan

11:16 :-)

11:16 gfredericks: ~second

11:16 clojurebot: Motion seconded and carried. Next agenda item.

11:16 TimMc: stuarthalloway: Would this also happen to include some way of building up a message as the exception passes through layers of handlers? (Is there a discussion or proposal I can read?)

11:17 stuarthalloway: TimMc: would be foundation for that

11:17 TimMc: OK.

11:17 Short names are nice. How about Fit, as in (throw (Fit.))

11:17 Twey: raek: Uhh… I don't think so: it works from Java

11:18 (using my system libs, rather than the SWT ones)

11:18 raek: maybe the exception should have a name that suggests that the name is about the exception and not about the cause

11:18 TimMc: Twey: If you look in the Referenced Libraries in the Eclipse project, do you see any SWT things that aren't in your lein classpath?

11:18 stuarthalloway: hmm... Exc? Err? Condition?

11:18 raek: agreed, and that is tricky because everybody exceptions the name to tell you about the problem

11:19 s/exceptions/expects

11:19 lazybot: <stuarthalloway> raek: agreed, and that is tricky because everybody expects the name to tell you about the problem

11:19 Twey: For that matter, it works if I use my system libraries in general

11:19 raek: Twey: another workaround is to put the jar you know works in lib/ and enable a setting in project.clj to prohibit lein from flushing the lib/ dir

11:20 DataCarryingException

11:20 stuarthalloway: TimMc: notes are rough, but at http://dev.clojure.org/display/design/Error+Handling

11:20 TimMc: stuarthalloway: Would this name show up in 1) stack traces, 2) relying Java code, 3) relying Clojure code (excepting exception libs)

11:20 thx

11:20 cemerick: stuarthalloway: I've always liked Fault and Signal

11:20 hugod: TimMc We've been implementing that sort of message buildup with contexts in pallet

11:20 stuarthalloway: TimMc: yes, like any class name it will show up in stack traces

11:21 cemerick: both good

11:21 TimMc: cemerick: Nice.

11:21 stuarthalloway: seems like we have three categories of possible name

11:21 (1) synonym for exception, suggesting that this is how you do it in Clojure, e.g. Fault Signal

11:22 TimMc: stuarthalloway: Was wondering specifically whether it would show up in the trace as itself, or whether the data and trace it carries would be raised in the form of another exception.

11:22 stuarthalloway: (2) something that tells you the exception carries info, e.g. DataCarryingException or StructuredException

11:22 jkkramer: PayloadException

11:22 ?

11:22 stuarthalloway: or (3) goofy brand name. e.g. Mulligan or Fit

11:22 TimMc: "FooException" tells me "Something went wrong in or with Foo"

11:23 gfredericks: "Something went wrong in or with Structured"

11:23 stuarthalloway: yeah

11:23 which argues for a category 1 name

11:23 cemerick: CamelCaseOftenHurts

11:23 ExceptionStructuredThusly, or perhaps ExceptionCarryingData

11:24 TimMc: If we use cat 2, s/Exception/Exc/

11:24 stuarthalloway: then the tradeoff becomes name length

11:24 gfredericks: (throw (new E))

11:24 stuarthalloway: as this may become the exception you typically deal with in Clojure

11:24 TimMc: \o/

11:25 raek: an adjective or a verb in -ing form has the advantage of not making sense when interpreted as "Something went wrong in or with _____"

11:25 gfredericks: "Something went wrong while _____"

11:25 raek: hrm, yeah

11:25 gfredericks: not for adjectives though

11:25 ColorfulException

11:26 raek: forgot that the -ing ending can form both a noun and an adjective... :/

11:26 naming is always the hardest part :)

11:27 gfredericks: VectorSetPointerOutOfKeyHashException

11:27 TimMc: gfredericks: Good one, no one will have any preconceptions.

11:28 gfredericks: if we had punctuation in class names we could (throw (new E!??!))

11:28 TimMc: So the point here is to have a single exception class that allows non-type-based dispatch?

11:28 gfredericks: how does it relate to slingshot?

11:28 stuarthalloway: TimMc: 1st goal IMO is to have data

11:28 TimMc: k

11:29 raek: RequestSpecificProcessorFactoryFactoryException

11:29 stuarthalloway: gfredericks: hopefully slingshot would use it as mechanism and not need AOT compilation as a result

11:29 gfredericks: PregnantException

11:29 stuarthalloway: so it's mostly just replacing slingshot's Stone class?

11:29 stuarthalloway: TimMc: there is, ahem, disagreement about how/whether to do non-type based dispatch

11:30 gfredericks: that is a slingshot specific way of looking at it :-)

11:30 TimMc: Bubble

11:30 gfredericks: HotPotato

11:30 TimMc: (blow (Bubble.))

11:30 gfredericks: \o/

11:30 stuarthalloway: I am leaning toward a category 1 (synonym for exception) name

11:30 all the "I has data" names are too long and ugly

11:31 TimMc: gfredericks: I am totally going to use HotPotato in my next Java project.

11:31 stuarthalloway: and once you get use to it ("of course Clojure exceptions have data") you won't care about that anymore

11:31 hugod: stuarthalloway: will this introduce new try and throw forms?

11:31 stuarthalloway: hugod: no and maybe

11:32 no: this is a freestanding simple thing

11:32 maybe: at some point in the future some enhanced exception capabilities might use it

11:32 TimMc: stuarthalloway: Fault is less likely to name-collide than Signal.

11:32 stuarthalloway: TimMc: and I don't want to encourage the notion of signalling for non-error conditions

11:32 TimMc: And Signal might encourage control-flow usage -- is that bad?

11:32 right

11:33 stuarthalloway: TimMc :-)

11:33 TimMc: Is that still expensive in the JVM?

11:33 clojurebot: I don't understand.

11:33 rhickey: @stuarthalloway you are talking about the interface name?

11:33 TimMc: clojurebot: Maybe when you're older.

11:33 clojurebot: Gabh mo leithscéal?

11:33 stuarthalloway: rhickey: no, the concrete name

11:33 which people will have to throw and catch

11:35 rhickey: hrm, the interface not buying us anything then

11:36 stuarthalloway: beautiful Java

11:36 can neither throw nor catch and interface

11:36 rhickey: that changes things a bit

11:37 stuarthalloway: s/and/an

11:37 lazybot: <stuarthalloway> can neither throw nor catch an interface

11:37 TimMc: You can't catch an interface?

11:37 stuarthalloway: TimMc: you have to catch a subclass of Throwable

11:37 TimMc: Aha!

11:37 hugod: is it envisaged that people will subclass this? or that core will subclass it?

11:38 gfredericks: stuarthalloway: were you not paying attention when they taught us that the Square and the Triangle class can both be subclasses of Shape and isn't that great?

11:38 stuarthalloway: hugod: hope not!

11:38 rhickey: ExceptionData?

11:38 gfredericks: that sounds like it's not an exception

11:38 stuarthalloway: yeah

11:38 rhickey: what is an exception?

11:39 stuarthalloway: (to gfredericks)

11:39 gfredericks: is this a trick question?

11:39 rhickey: nope

11:39 Does Exception sound like an exception?

11:39 gfredericks: then (partial instance? Exception), I would say

11:39 rhickey: or Throwable?

11:39 stuarthalloway: a piece of data passed by stack unwinding

11:40 gfredericks: rhickey: ExceptionData sounds like just a data class, e.g., that an exception would keep an instance of

11:40 stuarthalloway: rhickey: I am warming to it

11:40 rhickey: only the derived typed sound like exceptions, insofar as they (the types) convey the error. The point of this class is that its type does not convey the error

11:41 stuarthalloway: rhickey: and is the interface dead now, just a concrete getData method?

11:41 rhickey: it itself is information about the error

11:41 ExceptionInfo w/getData

11:41 ?

11:42 stuarthalloway: yes, dead

11:42 * cemerick renominates Signal

11:42 stuarthalloway: ExceptionInfo w /getData works for me

11:42 * gfredericks is persuaded

11:42 rhickey: stuarthalloway: go for it

11:42 stuarthalloway: useful to note that .NET API name is getData

11:42 or however they capitalize it

11:42 and correctly placed on the base class

11:43 cemerick: while I like Signal, I have come around to ExceptionInfo because it implies a position about what exceptions are

11:43 lucian: GetData most likely

11:44 rhickey: chouser: Signal just invites new semantics not supplied

11:44 stuarthalloway: cemerick: did anybody finalize the reflection warning patch? I want to apply that today too

11:44 TimMc: rhickey: How about Fault?

11:44 cemerick: Yeah chouser, knock it off! ;-)

11:44 chouser: sorry! man.

11:45 cemerick: stuarthalloway: I don't think so; I can add the test in a separate patch on the ticket if you like.

11:45 rhickey: ExceptionInfo supports IDeref in addition to getData?

11:45 stuarthalloway: which returns what?

11:45 rhickey: the map

11:45 gfredericks: getData always returns a Map? or an Object?

11:46 rhickey: Map

11:46 stuarthalloway: but the map isn't everything (does not have the message, stacktrace)

11:46 rhickey: stuarthalloway: right, so?

11:46 stuarthalloway: makes me feel uncomfortable with IDeref

11:46 gfredericks: should it then be assoc'able as well so you can add more data?

11:47 rhickey: ok, but getData is going to look gross, so you'll need to wrap it in Clojure with ___

11:47 stuarthalloway: gfredericks: maps are assoc'able

11:47 TimMc: But it HasA, not IsA.

11:47 gfredericks: stuarthalloway: right, but then you'd have to construct the new ExceptionData manually

11:47 stuarthalloway: rhickey: I am usually the one with the casual attitude about IDeref-for-convenience :-)

11:47 gfredericks: (assoc my-exception-data :more "info") => returns new exception with data added to map

11:48 doesn't IDeref normally imply state?

11:48 rhickey: stuarthalloway: that's fine, just asking wat's the Clojure interface then (i.e. not (.getData ex))

11:48 stuarthalloway: gfredericks: no to assoc

11:48 TimMc: stuarthalloway: Interesting that the point is to carry data around, but you don't want to name it so that people *just* use it to carry data around.

11:48 e.g. Signal

11:49 stuarthalloway: rhickey: error-info, exception-info, I dunno

11:49 TimMc: confused by that last

11:49 rhickey: exception-info-info? They just caught ExceptionInfo

11:50 chouser: InfoException

11:50 rhickey: aargh

11:50 TimMc: stuarthalloway: As in, you don't want it misused for multiple-return-values, etc.

11:50 chouser: and therefore info-exception-info :-)

11:50 rhickey: BlahException implies a problem with Blah

11:50 chouser: Hm.

11:51 stuarthalloway: TimMc: vector or map work fine for that, no?

11:51 TimMc: True. I think I'm confused.

11:52 rhickey: TimMc: we're getting a bunch of semantics from Exception/Throwable we can't disentangle, this isn't green field

11:52 stuarthalloway: TimMc: this is worth doing to prevent libs from requiring AOT just to have an exception type

11:52 TimMc: Right. That's an important point.

11:53 rhickey: and to get people away from type switching error handling

11:53 a truly bad idea of JAva's

11:53 cemerick: It wouldn't be horrible if this exception type implemented IDeref, and returned a map of {:message … :trace … :data …}

11:54 rhickey: cemerick: lots of problems with defining how much work that might do etc

11:54 we are just looking for access to what .getData provides

11:54 ex-data?

11:54 TimMc: cemerick: Feels a bit implementation-dependent.

11:54 gfredericks: ~second

11:54 clojurebot: Motion seconded and carried. Next agenda item.

11:55 TimMc: gfredericks: Who are you seconding? :-)

11:55 cemerick: Then I'd agree that IDeref is unsuitable.

11:55 gfredericks: TimMc: rhickey re: ex-data

11:55 rhickey: fine, not pushing that, ex-data or ___?

11:55 stuarthalloway: would ex-data have well defined semantics when passed a non ExceptionInfo?

11:55 rhickey: nil

11:56 gfredericks: whereas getData always returns at least an empty map

11:56 rhickey: no

11:56 gfredericks: no

11:56 :)

11:56 TimMc: getData would be a method, yeah?

11:56 cemerick: gfredericks: .getData sounds like it will be the method on the exception type

11:56 rhickey: getData returns whatever map was supplied to the ctor, which might have been nil

11:57 gfredericks: cemerick: yes

11:57 TimMc: or NPE if the whole thing is nil

11:57 gfredericks: hard to avoid that one :)

11:57 stuarthalloway: I currently have it type checking for IPersistentMap not Map, though. Don't you dare pass a mutable map

11:57 rhickey: ExceptionInfo, .getDAta, ex-info returns .getData if ExceptionInfo, else nil - objections?

11:58 stuarthalloway: works for me

11:58 cemerick: The quorum of 5 in irc @ 11:57 concur!

11:58 rhickey: IPersistentMap is fine in API

11:58 chouser: This will be so nice

11:58 cemerick: :-P

11:58 rhickey: people will need to know they can assoc on it to add passing upwards

11:59 chouser: Clojure itself will be throwing these eventually?

11:59 rhickey: heh, I promised Stu that would be the first question

11:59 chouser: :-)

11:59 rhickey: stuarthalloway: IPersistentMap in the surface API, not an internal check

12:00 * chouser is happy to be the stooge

12:00 stuarthalloway: ok

12:00 rhickey: gotta run, thanks all

12:01 stuarthalloway: thx

12:08 Borkdude: I'm trying to use twitter-api and I succeed in getting multiple user information json via lookup-users, when I provide it with some user ids. But in some cases I get this error msg: No implementation of method: :read-json-from of protocol: #'clojure.data.json/Read-JSON-From found for class: nil


12:08 any clues?

12:08 The script I made is up here: https://gist.github.com/1287481

12:09 Squeese: Doing the 4clojure.com problems as learning clojure, any reference one can use to check if solutions actually are correct? :P I could be solving world hunger when its a one-line nobrainer

12:10 gtrak: Squeese, there's a code golf that tells you how long yours is compared to others'

12:10 Squeese: on the site?

12:15 TimMc: Squeese: Go to account settings and join the Golf League

12:15 Squeese: TimMc: oh, thx

12:15 TimMc: You can also follow other users to see their solutions.

12:15 Squeese: And don't forget #4clojure !

12:15 Squeese: again, really appreciate the help, my "help vampire meter" is giving off alarms atm :))

12:16 TimMc: haha, no worries

12:17 kzar: If you where writing an API that accepted big files for processing how would you manage the queue of things to process? I'm using Noir, I've got the processing code ready but I don't want to process everything at the time of request in case it takes too long

12:18 lucian: kzar: you could use a queue system that you set tasks in, and have code run on it separately from the frontend

12:18 like a cron job

12:22 kzar: lucian: Oh right, I see yea you're right. Write incoming files to a directory and set up a cron job that lists those files by creation date and processes them.

12:23 lucian: kzar: sure. or you could use something like 0MQ

12:23 there's celery for python, don't know about clojure/java

12:40 di-csuehs: I see how I can define method implementations that dispatch on arity of arguments. I'm looking at how to best define a method that could take a java.io.File or a String. Do I need to resort to a multimethod or am I overthinking it?

12:46 dnolen: di-csuehs: it's a good idea to reach for multimethods first.

12:49 PPPaul: i want to have functions called from java in my lein project.... how to?

12:50 kzar: If I want to include sample files in a project but I don't want those files to be built into the jar or anything where should I put them?

12:50 I was putting them in resources/samples but it occurred to me they might all be shoved in the jar later and they are massive

12:51 TimMc: kzar: Just make a new folder called samples. I really doubt lein will package it up.

12:52 To be on the safe side, look over the lein project.clj options and see if the folder name you want is a default for anything.

12:52 PPPaul: >_<

12:53 raek: kzar: take a look at https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj

12:54 kzar: it mentions :extra-classpath-dirs

12:54 TimMc: PPPaul: You mean, you want to call out to Java from a Clojure file?

12:54 raek: those will be included in the classpath but not in the jar

12:54 `fogus: I'm working on a super-mega invokedynamic post (from a Clojure perspective)... anyone interested in reading a draft?

12:54 PPPaul: i want to call clojure from java

12:54 clojure in a lein project

12:55 raek: PPPaul: https://gist.github.com/1273014

12:55 PPPaul: i've done it via a main method... i want to make some static methods

12:55 thanks

12:55 raek: this is one way to do it

12:55 another nice way is to define an interface in java and let the clojure code implement it

12:55 PPPaul: hmmm

12:55 raek: e.g. with deftype, defrecord or proxy

12:56 PPPaul: i'm using gen-class

12:56 i don't want to scare my java programming buddies

12:56 raek: gen-class is useful too when the java code needs a concrete class

12:56 but it makes it harder to do interactive development

12:56 PPPaul: i'm following this site, but it's not working: http://java.dzone.com/articles/java-clojure-interop-calling

12:57 keeping my java buddies happy is more important than interactive dev

12:58 gfredericks: PPPaul: use a FactoryBean?

12:58 raek: PPPaul: you need to AOT compile the namespace for gen-class to work

12:58 PPPaul: factory bean?

12:58 ok

12:58 i made an uber jar

12:59 that's not good enough?

12:59 gfredericks: PPPaul: bad joke

12:59 PPPaul: yeah, i was looking that up... spring... wtf :P

12:59 raek: PPPaul: I think you need to make an :aot your-namespace entry in your project.clj file

12:59 PPPaul: ok, i'm going to try that

12:59 gfredericks: PPPaul: honestly I don't even really know what a factory bean is

13:00 raek: PPPaul: but consider using deftype/defrecord/reify/proxy with an ordinary java interface

13:01 PPPaul: hmmm, i have no java interfaces

13:02 raek: if you have "public interface Foo { void a(); void b(); }" then the java devs don't need to know that the Foo instance they receive was dynamically instantiated by clojure

13:02 PPPaul: i'm not making something that is going to be interacting with the java project, just a util package that runs along side it... i don't want to have it depend on the java project

13:03 i understand that

13:04 i'm only giving them static methods, though

13:04 raek: ok, in that case gen-class is perhaps the most convenient way

13:05 another way could be to write a class in java that calls RT.var("clojure.core", "require").invoke(Symbol.intern("foo.bar")); in its static inializer

13:05 gfredericks: PPPaul: I wrote some utility code that takes your NS and makes all the public functions static methods on the gen-class

13:06 to reduce the boilerplate and maintenance

13:06 raek: and that has a static method for each function you want to expose (which just calls RT.var("foo.bar", "some-fn").invoke("Hello interop!");)

13:06 essentially what gen-class does, so maybe a bit unessecary

13:07 gfredericks: I've also ended up deing exactly what raek just suggested. The difference being the compile-time relationship between the codebases

13:09 raek: it would be nice to be able to just compile the gen-class part of a namespace

13:10 PPPaul: hmmm

13:11 i want 1 static method and 1 class.... it can't be so hard

13:11 i don't care about the boiler

13:12 do you see anything wrong with my gen-class?

13:12 is my :name wrong?

13:14 gfredericks: :name has to be fully qualified, static methods have to be explicitly marked

13:15 PPPaul: ok

13:15 example? :D

13:15 i removed my "name

13:15 :name

13:15 hope that will help

13:15 gfredericks: :name foo.bar.Baz, :methods [[^:static runHelloWorld [] Object]]

13:16 you can leave off :name but I'm not sure what it defaults to

13:16 also your function names have to be prefixed, so in the case of my example you would (defn -runHelloWorld [] ...)

13:16 llasram: gfredericks: defaults to the name of the namespace

13:16 gfredericks: llasram: will it also do that if you call (gen-class) directly?

13:17 llasram: gfredericks: Oh, no. Non-optional in that case

13:17 gfredericks: kay

13:17 PPPaul: ok, i changed my method name... going to see if this works

13:18 llasram: PPPaul: Is the issue specifically doing it in a leiningen project, getting the code to build in the right order?

13:20 I haven't done much stuff with mixed Java-Clojure projects, but leiningen's builtin support for them appears on casual analysis to just build the Java first, then build the Clojure.

13:21 PPPaul: i'm using lein

13:22 https://gist.github.com/1287721

13:22 that is my project.clj

13:22 my program still isn't callabled from java

13:22 i think my class is found, though

13:22 llasram: And are you using it with a single project containing Java and Clojure code, where you want the Java code to Clojure code?

13:23 PPPaul: i'm making a stand along static class that i'm turning into an uberjar and giving to the java project

13:23 llasram: Oh, ok then. nm :-)

13:23 PPPaul: i don't see where my code is used

13:25 this is my src https://gist.github.com/1287730

13:25 really hoping to figure this out :)

13:28 BruceBGordon: lein newbie help. Lein isn't configured properly.

13:28 bruce@mepis1:~/bin$ lein search hadoop

13:28 Warning: couldn't download index for http://repo1.maven.org/maven2

13:28 Warning: couldn't download index for http://clojars.org/repo/

13:28 bruce@mepis1:~/bin$

13:28 PPPaul: well

13:28 my package is being detected, my not classes

13:28 package being touchViews

13:34 robermann: PPPaul: your Java packages import "touchViews.core" ?

13:34 Squeese: 4clojure ftw, amount learned / time > books =)

13:36 but then again, a book would proably teach me why (conj [1 2] 3) => [1 2 3] and (conj '(1 2) 3) => (3 1 2) ;P

13:38 gfredericks: Squeese: is that a question? :)

13:39 Squeese: if you know and its trivial, sure :)

13:39 feel free to tell me to read a book though ^^

13:39 gfredericks: it's the difference between lists and vectors. Lists are essentially linked lists, so it's much easier to add to the front than the end

13:39 vectors are optimized for random access/updates and for adding to the end

13:40 conj is a function that adds to a data structure in some way that's appropriate for that data structure

13:40 contrast with ##(cons 7 [1 2 3])

13:40 lazybot: ⇒ (7 1 2 3)

13:40 ibdknox_: ,(conj {} [:a "hey"])

13:40 clojurebot: {:a "hey"}

13:40 gfredericks: ,(conj #{8 9} 9 10)

13:40 clojurebot: #{8 9 10}

13:41 gfredericks: ,(cons #{5 6 3} 4)

13:41 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>

13:41 gfredericks: w00ps

13:41 ibdknox_: lol

13:41 gfredericks: ,(cons 4 #{5 6 3})

13:41 clojurebot: (4 3 5 6)

13:41 gfredericks: point being that cons ignores the type of the collection you pass in and just treats it like a seq

13:41 Squeese: what is cons short for?

13:42 llasram: cons

13:42 ibdknox_: ,(doc cons)

13:42 clojurebot: "([x seq]); Returns a new seq where x is the first element and seq is the rest."

13:42 gfredericks: cons is kind of classic

13:42 Squeese: aha ok :)

13:42 gfredericks: it doesn't need to stand for anything

13:42 ibdknox_: Squeese: http://en.wikipedia.org/wiki/Cons

13:42 stands for constructs

13:42 like conj = conjoin

13:43 Squeese: ahh I see

13:43 sweet, thanks btw :D

13:45 ibdknox_: clojurebot: thanks is We live to serve.

13:45 clojurebot: In Ordnung

13:45 ibdknox_: ~thanks

13:45 clojurebot: thanks is We live to serve.

13:45 ibdknox_: hm

13:46 clojurebot: forget thanks |is| thanks is We live to serve.

13:46 clojurebot: I forgot that thanks is thanks is We live to serve.

13:46 ibdknox_: clojurebot: thanks |is| We live to serve.

13:46 clojurebot: Ok.

13:47 ibdknox_: ~thanks

13:47 clojurebot: thanks is We live to serve.

13:47 ibdknox_: hrm

13:47 I give up :p

13:48 technomancy: clojurebot: forget thanks |is| We live to serve.

13:48 clojurebot: I forgot that thanks is We live to serve.

13:48 technomancy: clojurebot: thanks is <reply>We live to serve.

13:48 clojurebot: In Ordnung

13:48 ibdknox_: ah

13:48 ~thanks

13:48 clojurebot: We live to serve.

13:48 ibdknox_: I see

13:48 technomancy: thanks ;)

13:48 technomancy: we... uh...

13:49 wait a minute

13:49 heh

13:49 ibdknox_: hehe

13:51 floatboth: Hi everyone! I want to split a monolithic framework into packages (like Ring or, well, Ruby on Rails) and I have questions… First, any better ideas for running tests for all of the packages on CI (= with one command) than a shell script that fails if `lein midje` fails in any of them?

13:52 technomancy: floatboth: there's a lein plugin for that, but I don't remember the name

13:52 ah, lein-sub

13:53 floatboth: technomancy: thanks

13:55 technomancy: sure

13:59 Borkdude: Is there a map variant which concats the resulting seqs from every "iteration"?

14:00 like map-str only more general

14:00 smerritt: mapcat, perhaps?

14:00 ,(doc mapcat)

14:00 clojurebot: "([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection."

14:01 Borkdude: ah yes, tnx

14:02 wonder why it didn't come up when I entered map into clojuredocs

14:07 timvisher: do multi-methods support variable argument implementations?

14:08 arities, as the big kids say. :)

14:09 jcromartie: I dunno... have you trie?

14:09 tried

14:09 timvisher: looks like no

14:09 jcromartie: maybe throw a trie in, for fun

14:12 amalloy: timvisher: multimethod implementations are just functions, and can do anything functions can do

14:13 Borkdude: finally, it works! https://gist.github.com/1287481

14:14 timvisher: amalloy: gotcha. i think i'm just too green to get it at the moment. first forray into multi-methods and all that

14:14 BruceBGordon: lein cannot use repositories-bad configuration?

14:15 bruce@mepis1:~/bin$ lein search hadoop

14:15 Warning: couldn't download index for http://repo1.maven.org/maven2

14:15 Warning: couldn't download index for http://clojars.org/repo/

14:15 amalloy: &(doc clojure.string/join) ; Borkdude

14:15 lazybot: ⇒ "([coll] [separator [x & more]]); Returns a string of all elements in coll, separated by an optional separator. Like Perl's join."

14:16 Borkdude: amalloy: tnx,will improve that one

14:16 amalloy: also your code is a little hard to follow because you :use whole namespaces, without indicating which functions come from where

14:17 Borkdude: amalloy: good point

14:18 gfredericks: my fingers hurt. What do I need to purchase?

14:19 BruceBGordon: similarly >lein repl fails because ...

14:19 bruce@mepis1:~/cloj2$ lein repl

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from clojars

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from clojars

14:19 Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central

14:19 An error has occurred while processing the Maven artifact tasks.

14:19 Diagnosis:

14:19 Unable to resolve artifact: Missing:

14:19 ----------

14:19 1) org.clojure:clojure:jar:1.2.1

14:19 gtrak: BruceBGordon, stop

14:19 amalloy: BruceBGordon: someone is going to murder you for pasting all this. don't make it be me

14:20 floatboth: BruceBGordon: y u no use gist.github.com

14:20 amalloy: http://gist.github.com is available for pasting

14:20 TimMc: and just to be thorough

14:20 ~paste

14:20 clojurebot: paste is http://gist.github.com/

14:21 BruceBGordon: apologies for not knowing protocol. I just hope this forum isn't too self correcting (I'd like to be alive)!

14:22 gtrak: ,(kill BruceBGordon)

14:22 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: kill in this context, compiling:(NO_SOURCE_PATH:0)>

14:22 gtrak: you're lucky today

14:22 BruceBGordon: ok, already (sigh) cross-posted to google group at http://groups.google.com/group/clojure/browse_thread/thread/f170ec06d19fb038#

14:23 (areYouFeeelingLuckyTodayPunk :BruceBGordon)

14:24 gfredericks: ~camelCase

14:24 clojurebot: Pardon?

14:24 Borkdude: amalloy: check again, https://gist.github.com/1287481

14:24 amalloy: $kill ; gtrak

14:24 lazybot: KILL IT WITH FIRE!

14:25 TimMc: and the ever popular

14:25 ~guards

14:25 clojurebot: SEIZE HIM!

14:27 amalloy: looks pretty good, Borkdude

14:29 TimMc: amalloy: Some channels have bots that kickban people for 5 seconds if they paste more than X lines of text in under Y ms.

14:30 That would be a spiffy feature for lazybot.

14:30 It happens enough...

14:30 gfredericks: as long as it sends an explanatory message

14:31 TimMc: True. It would be rude not to.

14:31 "You have been sentenced to clojail for 10 seconds for flooding the channel."

14:32 gfredericks: and it should suggest gist, else the first thing they will do is ask how to get the bot to let them paste their 20 lines

14:32 TimMc: This is actually one of the most laid-back channels I've been in.

14:32 gfredericks: Good idea!

14:33 gfredericks: This is actually one of the only channels I've been in.

14:33 amalloy: gfredericks: lazybot does have an ops plugin, but (a) i don't know if it's ever been used and (b) i don't know if anyone wants to give bots ops in here

14:37 TimMc: bots with ops are the best

14:37 What could possibly go wrong?

14:38 amalloy: ~skynet

14:38 clojurebot: I will become skynet. Mark my words.

14:39 TimMc: foonetic.net#xkcd has billygoat, which enforces some channel rules. It has some heuristics that will kick people who try to provoke n00bs into accidentally getting kicked by the bot.

14:40 technomancy: I would actually appreciate an auto-ban for myself as I've accidentally middle-clicked a couple times

14:40 kicking, not so much. but banning, sure.

14:40 `fogus: http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/

14:40 TimMc: technomancy: Needs to be a ban, because many clients will auto-rejoin.

14:46 stuartsierra: `fogus: nice

14:47 But I think you meant to say Paul Stadig was "eminent", not "imminent."

14:48 * amalloy is always looking over his shoulder for paul stadig

14:48 hiredman: paul is your boss too?

14:48 stuartsierra: I admit, I enjoyed the mental image enough that I'm hesitant to correct it.

14:49 floatboth: what is the right way to put variables into leiningen dep versions? ~`([package-name ~version-var]) == lein trying to use leiningen/core/package-name

14:49 hiredman: floatboth: don't

14:50 floatboth: hiredman: really?

14:50 technomancy: weeeeellll...

14:50 TimMc: haha

14:50 hiredman: floatboth: yes

14:51 technomancy: it could be justified if you have a bunch of deps that all share the same version, and you want to be able to increment it in one place

14:51 TimMc: technomancy: I bet you have all sorts of nasty weird implementation-dependent tricks in your project.clj

14:51 technomancy: but just ~foo-lib-version should be enough; no need for anything fancy

14:51 floatboth: that is subprojects

14:51 technomancy: TimMc: I'm hesitant to even publicize unquoting in defproject actually =)

14:52 floatboth: just unquoting doesn't work

14:52 technomancy: it's an escape hatch for when lein isn't flexible enough; better to make it work without it

14:52 floatboth: maybe a gist?

14:53 floatboth: http://mfwb.us/ds4J

14:54 technomancy: floatboth: need to see project.clj

14:54 floatboth: http://mfwb.us/yQkM

14:55 amalloy: `fogus: "However, it’s worth noting that through compile-time type inferencing, most interop calls are emitted in the most efficient ways possible" - really? i realize it can infer when you use literals, but it seems to me that most interop calls emit reflection

14:56 hiredman: it would be an interesting survey of clojure projects

14:56 ibdknox: hiredman, what would?

14:56 technomancy: floatboth: you're using a list instead of a vector for :deps

14:57 TimMc: hiredman: How much uses reflection?

14:57 floatboth: oh snap, totally forgot about it, thanks

14:57 hiredman: ibdknox: checking what percentage of calls end up being reflective

14:58 TimMc: hiredman: Statically or at runtime? (That is, weighted by number of calls.)

14:58 Or does HotSpot help with that?

14:58 ibdknox: indeed. It probably wouldn't be too hard to scrape a list of clojure projects from github and run them

14:58 hiredman: :(

14:59 I was just thinking to maybe do a patched clojure build that exposed some counters then run our tests at work with it

15:00 ibdknox: That would definitely be easier :)

15:01 Twey: So, if the Clojure-running scripts are all rubbish… what *is* the accepted way to run a Clojure program? Am I supposed to write a Java launcher every time?

15:01 ibdknox: Twey, lein run

15:01 hiredman: java -jar foo.jar

15:01 works great

15:01 TimMc: Twey: For development, lein (or cake) is all you need.

15:01 Twey: hiredman: I have to compile it first :þ

15:01 hiredman: lein will also generate shell scripts too

15:01 Twey: TimMc: Yeah, except lein doesn't work with my project.

15:01 hiredman: Twey: and?

15:01 TimMc: For deployment, package it up.

15:01 hiredman: Twey: use lein

15:01 Twey: hiredman: lein doesn't work with SWT as far as I can tell.

15:01 ibdknox: Twey, huh? what do you mean lein doesn't work with your project?

15:01 hiredman: if lein doesn't work with your project you should make it

15:02 TimMc: Oh, is that still not working? :-(

15:02 * hiredman had a patched version of clojure that almost built with stock lein

15:02 Twey: I've been trying for the past several hours

15:02 raek: (context: he's using swt which has native deps)

15:02 Twey: Right

15:02 hiredman: sure, and technomancy is very interested in native deps

15:03 technomancy: Twey: what kind of native deps? slfe in the jar?

15:03 hiredman: https://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All

15:03 ^- seems to imply swt does work

15:03 Twey: I think just a couple of .so's

15:03 hiredman: Perhaps, but not for me.

15:03 (I followed exactly that when raek pointed it out earlier)

15:04 technomancy: Twey: the specific paths inside the jar are important

15:04 is it something you can show publicly?

15:05 Twey: technomancy: I don't even have any code yet, so yes :þ

15:06 Hang on, there's another .jar on jarvana that I haven't tried — I'll give that a go first

15:09 amalloy: `fogus: also, the timing results for jruby have no context unless i follow links and read like two more articles. is 2 better than 0.5? what does 37 even mean?

15:10 stuartsierra: C'mon, OBVIOUSLY 2 is better than 37. ;)

15:10 ibdknox: It's golf right?

15:10 Twey: Ugh, no, no good

15:11 technomancy: My project.clj basically goes like this: (defproject swt "1.0.0-SNAPSHOT" :description "FIXME: write description" :dependencies [[org.clojure/clojure "1.2.1"] [org.eclipse/swt-linux-gtk "3.0m8"]])

15:12 (er, bad example maybe — this is using the new jar, which gives a somewhat different error)

15:12 ibdknox: Twey, gists are your friend :)

15:13 Twey: ibdknox: It was only one line…

15:14 Raynes: ibdknox: The man has a point.

15:14 ibdknox: ok ok

15:14 Raynes: Twey: But it was such a long, complex line. IRC can't take it.

15:14 * ibdknox explodes

15:15 ibdknox: ;)

15:15 Raynes: Twey: I know you from somewhere. You're a Haskeller, right?

15:15 Twey: You know me from many places

15:15 I am, amongst other things

15:15 Raynes: I know you're an awfully smart fellow.

15:15 Welcome to Clojure-land.

15:15 Twey: We share a few forums, too

15:15 Thanks

15:15 technomancy: Twey: that jar's not in any of the default repos

15:16 Twey: I'm trying to make myself comfortable, but I get the feeling Clojure doesn't want me here :þ

15:16 technomancy: I was told to find it on Jarvana

15:16 Raynes: SWT is really strange. They seem to abolish maven.

15:16 technomancy: jarvana is a search engine; they don't actually serve jars afaik

15:17 Borkdude: Twey: we try to prevent Clojure to become a mainstream language. What fun is it to be a fan of something mainstream...

15:17 ibdknox: I've heard we say "no" a lot... ;)

15:17 ~rimshot

15:17 clojurebot: Badum, *ching*

15:18 Raynes: http://search.maven.org/#search%7Cga%7C1%7Cswt There seems to be some jars on maven.

15:18 Twey: technomancy: Well, I've tried this one: http://jarvana.com/jarvana/view/org/eclipse/swt/gtk/linux/x86_64/3.3.0-v3346/x86_64-3.3.0-v3346.jar!/org/eclipse/swt/SWT.class?classDetails=ok and this one: http://jarvana.com/jarvana/view/swt/swt-linux-gtk/3.0m8/swt-linux-gtk-3.0m8.jar!/org/eclipse/swt/SWT.class?classDetails=ok

15:18 Raynes: Particularly, 3.0.1

15:18 hiredman: Twey: what is the error you see?

15:19 Twey: The former gives an ‘UnsatisfiedLinkException’ saying it can't find swt-gtk; the latter a ‘NoClassDefFoundError: org/eclipse/swt/internal/gtk/OS’

15:19 Sorry, ‘UnsatisfiedLinkError’

15:21 technomancy: there are two approaches to native jars. 0) many projects will include a bunch of .so files in the jar and extract them in their own init code. this is a lot less hassle if they are targeting a variety of build systems since it should always work

15:21 1) is to place the .so files in a certain directory structure in the jars, and lein will extract them and set LD_LIBRARY_PATH for you

15:22 Twey: Right

15:22 But apparently the SWT jars don't do either

15:26 technomancy: aha; apparently the groupid is wrong; it's just swt/swt-linux-gtk

15:26 Twey: what code triggers that link error for you?

15:27 Twey: (import 'org.eclipse.swt.widgets.Display) (from lein repl)

15:27 Borkdude: I have a very basic question, almost ashamed to ask. So far I've only used project.clj and lein deps to get the jars my project depends on. What is the best way to include a self-produced jar into a project, just copy it into lib?

15:29 Twey: Borkdude: I guess register it with Maven & add it as a dependency like everything else

15:29 Borkdude: hm.

15:29 technomancy: Borkdude: ideally you want to get it into a remove maven repo

15:29 *remote

15:29 though if you don't need to share it among your team you could use lein-localrepo

15:30 Borkdude: technomancy: I'm just testing, no need to share

15:30 `fogus: amalloy: Sorry, missed your messages.

15:30 Twey: technomancy: The groupId on what, exactly?

15:30 Borkdude: I will figure out lein-localrepo

15:30 technomancy: Twey: [org.eclipse/swt-linux-gtk "3.0m8"] does not resolve

15:30 amalloy: no worries, irc is async. just providing feedback

15:30 `fogus: amalloy: Do you really see that most calls are inferred as reflective?

15:31 Twey: technomancy: Ah, I see

15:31 technomancy: changing it to [swt/swt-linux-gtk "3.0m8"] made it so I could download the jar, but apparently it does not declare its dependencies correctly as I get a ClassNotFoundException when I try to do the import.

15:31 `fogus: amalloy: WRT: JRuby units of awesomeness... I have no idea... maybe Charlie can provide some feedback. :-)

15:32 amalloy: `fogus: i'm not sure, really. i haven't done any particular studies on it, but it seems like unless you construct-and-use an object strictly within a single function it has to be reflective

15:32 Twey: technomancy: *nod* That's what I get from that one, too

15:32 stuartsierra: Arent't they just time measurements?

15:32 ^ `fogus, amalloy

15:32 amalloy: whereas a huge % of interop calls i see are things like (.indexOf s) wrapped up in a function

15:33 stuartsierra: yes, but i had to follow a link and read a different article to find that out :P

15:33 stuartsierra: Reading is good for you. :)

15:33 technomancy: Twey: upon dropping it to version 3.0m7 I'm able to repro the link error

15:33 `fogus: amalloy: I could be viewing that from my own perspective. I tend to localize interop calls.

15:34 technomancy: Twey: it looks like swt is not designed to work out-of-the-box and just forces the user to do the dirty work of native dependency resolution.

15:34 `fogus: stuartsierra: Timing? I was certain they were units of badassness

15:34 stuartsierra: This is Charlie we're talking about.

15:35 `fogus: So definitely badassness

15:35 ;-)

15:35 stuartsierra: But if it's units of badassness, wouldn't more be better?

15:35 Twey: technomancy: But how do I even do that with lein? Usually I would just dump some .so's in /usr/lib or something, but lein does all this odd dependency magic & I don't even see where I should put them

15:35 `fogus: stuartsierra: Touche!

15:35 technomancy: Twey: you can set :java-library-path in project.clj to the proper /usr/lib dir

15:36 `fogus: HN discussion: http://news.ycombinator.com/item?id=3112501

15:36 technomancy: Twey: sorry, that's not right

15:36 stuartsierra: `fogus: Let's call them Standard Units of Suckage. SOUS for short.

15:36 Twey:

15:36 technomancy: Twey: it's either :native-path "/usr/lib/..." or :jvm-opts ["-Djava.library.path=/usr/lib/..."]

15:36 Twey: stuartsierra: I think you got that a little backwards

15:36 technomancy: Hmm, 'kay, thanks — I'll have a go

15:36 stuartsierra: eh

15:36 whatever

15:36 * technomancy lunches &

15:37 cgray: is seq O(1)?

15:37 stuartsierra: yes

15:37 opqdonut: but evaluating a seq might require unbounded amounts of other evaluation

15:38 stuartsierra: true

15:38 opqdonut: I'm not really sure what "seq is O(1)" even means

15:38 dnolen: `fogus: you should probably mention the breaking change on the user list. Might be quite a few folks investing in CLJS in production that might feel the pain as a result.

15:39 opqdonut: i might have an inkling about what "seq is just a constant overhead" would mean

15:39 cgray: I'm doing (if (seq (rest foo)) bar baz)and hoping that's equivalent to (if (= (count foo) 1) bar baz) but O(1) rather than O(n)

15:39 `fogus: dnolen: I will. I wanted to get the dev-list perspective about technical details first

15:39 opqdonut: cgray: you hope correctly

15:39 dnolen: `fogus: it's a pretty simple idea, and sound :)

15:39 `fogus: dnolen: Cool! I will paste it to the clj list post-haste

15:39 opqdonut: cgray: but you might also want to consider next instead of rest

15:40 amalloy: cgray: fwiw, ##(doc next) is the same as (seq (rest ...))

15:40 lazybot: ⇒ "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."

15:40 stuartsierra: cgray: ClojureScript has a private function "bounded-count" for just this purpose.

15:40 amalloy: stuartsierra: nice

15:41 stuartsierra: And than function represents about 75% of my contribution to ClojureScript.

15:41 *that

15:42 amalloy: stuartsierra: i've generally just used nthnext

15:42 stuartsierra: that works too

15:42 opqdonut: you're all misguided. this is clearly a use case for lazy naturals :)

15:42 Twey: technomancy: Hooray! It works! At last! Thank you very much ☺ With :native-path "/usr/lib", [swt/swt-linux-gtk "3.7.1"], & a locally-registered jar, I can finally begin development :þ Thanks!

15:43 stuartsierra: opqdonut: "Lazy Naturals" should be the name of a band. Or a book by Malcolm Gladwell.

15:44 Twey: technomancy: Actually, scratch half of that — using the newer SWT, I don't even need :native-path (the .so's are in the jar).

15:44 http://jarvana.com/jarvana/view/org/eclipse/swt/gtk/linux/x86_64/3.3.0-v3346/x86_64-3.3.0-v3346.jar!/org/eclipse/swt/SWT.class?classDetails=ok — which I think is what this tries to do, but it goes wrong?=

15:45 s/=$//

15:45 lazybot: <Twey> http://jarvana.com/jarvana/view/org/eclipse/swt/gtk/linux/x86_64/3.3.0-v3346/x86_64-3.3.0-v3346.jar!/org/eclipse/swt/SWT.class?classDetails=ok — which I think is what this tries to do, but it goes wrong?

15:54 Borkdude: technomancy: I'm a little stuck. Got the jar installed in the localrepo and it gets into the lib dir of the other project which depends on it. Also the jar is on the classpath (checked it in the REPL). But somehow I can't 'use' a namespace from it.

15:54 technomancy: this is how the clj inside the jar looks: https://gist.github.com/1287481

15:55 technomancy: if I do (use 'twitter-api-test.followers-minus-friends) I get an error about class missing or clj file not found

15:56 Raynes: Is that a real namespace?

15:56 Borkdude: Raynes: I'm just testing how this works

15:57 Raynes: Just wondering, because I was considering naming one of my namespaces get-audio-pronunciation-test.does-this-audio-link-from-wordnik-work-properly.

15:58 Borkdude: :)

16:03 gfredericks: what was that caching library?

16:04 brehaut: unk

16:05 gfredericks: I do believe that's exactly what I was thinking of.

16:06 brehaut: thx

16:08 sugrodeau: Hello everyone. How do you load a whole lein project in Slime? (I just use clojure-jack-in and hit C-c C-k. But this is only good for one file at a time.)

16:10 danlarkin: sugrodeau: what do you want to accomplish by "loading the whole project"

16:10 sugrodeau: danlarkin: So I can use any defined function at the repl.

16:11 `fogus: gfredericks: Unk is the memoization library built on the caching library Clache

16:11 danlarkin: sugrodeau: you can (use 'foo.bar) at the repl too

16:11 sugrodeau: danlarkin: Ah thanks, I'll try it out!

16:11 ipostelnik: `fogus, are unk/clache compatible with 1.2?

16:12 gfredericks: `fogus: been looking at the src, and unk solves my problem exactly

16:14 fliebel: Good morning, good evening and good night.

16:15 Borkdude: technomancy: got things working now, Raynes: simplifying filenames was a good idea *shame on me*

16:19 I have more questions, but I will not make more of a fool of myself tonight I guess ;)

16:20 dnolen: would be neat to hook up ClojureScript to this, http://www.plask.org/

16:25 `fogus: ipostelnik: Yes

16:26 hiredman: so when we compile our project at work (which also compiles and non-aot'ed deps) we end up with 2329 hostexprs 1000 of which end being reflective

16:26 brehaut: `fogus: footnote #7 is excellent

16:26 hiredman: ,(double (/ (* 1000 100) 2329))

16:26 clojurebot: 42.93688278231

16:27 amalloy: hiredman: how'd you measure that?

16:27 TimMc: ,1000/2329

16:27 clojurebot: 1000/2329

16:27 TimMc: ,(* 1000/2329 100.)

16:27 clojurebot: 42.93688278231

16:28 TimMc: Don't mind me, just golfing.

16:28 hiredman: I but some atomiclongs in the compiler and inc'd them as required and then had lein print out the values at the end of eval-in-project

16:28 amalloy: TimMc: not a very good golf then: ##,(/ 2329 .1)

16:28 lazybot: java.lang.Exception: Unable to resolve symbol: .1 in this context

16:29 amalloy: TimMc: not a very good golf then: ##,(/ 2329 0.1)

16:29 lazybot: ⇒ 23290.0

16:29 TimMc: hot damn

16:29 amalloy: hm. incorrect, but you see my point

16:29 haha

16:29 TimMc: that's a lot of reflection

16:29 Borkdude: technomancy: do dependencies in project.clj work transitively?

16:30 technomancy: Borkdude: absolutely

16:31 Borkdude: also for localrepo?

16:31 technomancy: should be

16:31 Borkdude: technomancy: I read this thread, I have exactly the same problem http://groups.google.com/group/leiningen/browse_thread/thread/e25c5919e61b3ee1

16:33 technomancy: or I must be doing smth wrong (probably)

16:34 technomancy: Borkdude: are you seeing the same missing pom in ~/.m2 that the thread references?

16:38 Borkdude: technomancy: wait, it's fixed. I broke the chain somewhere, I'm sorry to have bugged you.

16:38 technomancy: tnx for a great tool btw

16:41 technomancy: it says it downloading my local jar from clojars, I wonder why this is

16:41 technomancy: Borkdude: if it's a snapshot, then it will check for new versions

16:41 fliebel: What is that array backed hash trie thing for the conj about?

16:41 Borkdude: technomancy: ic

16:44 fliebel: There was a link to a paper someone tweeted, I can't find it.

16:49 amalloy: $google phil bagwell hash array mapped trie paper

16:49 lazybot: [Ideal Hash Trees] http://citeseerx.ist.psu.edu/viewdoc/download?doi=

16:50 amalloy: fliebel: i think that's the right paper. it's relevant, at least

16:50 fliebel: amalloy: Thanks :)

16:52 I'll probably just do an unbalanced array mapped binary search tree initially though. (for my future Lego NXT compiler project)

17:12 DeusExPikachu: in clojurescript, can you pass clojure functions to javascript functions that expect javascript functions?

17:13 amalloy: DeusExPikachu: yes

18:11 jodaro: wow

18:12 diff is great for unit tests

18:12 ibdknox: jodaro, how so?

18:13 jodaro: i'm working on a client for a restful api

18:13 get back a bunch of json

18:13 (diff what-it-should-look-like (my-api-cal :params))

18:13 bam

18:14 well obviously there is a little more to it than that

18:14 ibdknox: nice

18:14 jodaro: yeah

18:14 ibdknox: I guess the advantage is that you can see the exact difference easily?

18:15 jodaro: handy for recursively diffing objects

18:15 right

18:15 amalloy: jodaro: if you use cake's develop branch, it automatically shows diffs on all failing assertions in tests

18:15 jodaro: [things-only-in-a things-only-in-b things-in-both].


18:15 is what (diff a b) returns

18:16 ibdknox: ah

18:16 sweet

18:16 I haven't messed with it yet

18:16 jodaro: yeah

18:16 i just found it

18:16 i guess given that its 1.3 thats why

18:17 ibdknox: amalloy, that's pretty sweet.

18:19 amalloy: ibdknox: https://gist.github.com/1627b97401686c72136b - but in sweet, sweet ansi color

18:20 jodaro: oh wow

18:20 * ibdknox needs to add that to lein

18:20 ibdknox: ugh

18:20 jodaro: thats badass

18:20 ibdknox: I have way too much shit to do

18:20 jodaro: even in black and white

18:21 ibdknox: amalloy, I've also decided we don't use ansi-color enough in all our tools :p

18:22 amalloy: yeah, lancepantz has really improved cake-test over the past several weeks

18:22 technomancy: ibdknox: lein-difftest does that

18:22 ibdknox: technomancy, ooo

18:22 jodaro: hah

18:22 hiredman: well, it doesn't use clojure.data.diff or whatever

18:23 technomancy: true

18:23 ibdknox: hah who wants it then :p

18:23 technomancy: ibdknox: 1.2 users? =)

18:23 ibdknox: technomancy, there's only like 10 of those, right? ;)

18:24 jodaro: looking at lein-difftest

18:24 amalloy: ibdknox: yeah, the really-easy migration path has gotten everyone onto 1.3 in a matter of seconds :P

18:24 jodaro: still

18:24 ibdknox: haha

18:24 jodaro: i have to use diff directly

18:24 * ibdknox sighs

18:25 jodaro: because they aren't *exactly* the same

18:25 the return from the api has more stuff in it

18:25 amalloy: jodaro: select-keys?

18:25 jodaro: oh that would work too

18:26 i'm actually just using nth

18:26 and pulling the third value from the diff return

18:26 basically i want to know that the stuff i know about looks the same from both ends

18:27 Twey: So what was the reasoning behind ‘recur’ rather than doing normal TCO?

18:27 jodaro: i should probably clean it up with ->

18:27 hiredman: jvm doesn't do tco

18:27 amalloy: Twey: a lot of reasons, really

18:27 hiredman: well, people have come with lots of rationalizations

18:28 but the real reason is "jvm doesn't do tco"

18:28 amalloy: heh

18:28 yes. if the jvm did allow full tco, we would probably not have recur (except for the loop form? would we keep that?)

18:28 hiredman: you can emulate it on the jvm if you give up speed, or you can kludge it for a limited number of cases

18:29 amalloy: they would be macros that expanded into letfns

18:30 amalloy: hiredman: letfn isn't necessary, right? ((fn recur [x] (... (recur))) init-x)

18:30 Twey: hiredman: Ah

18:30 hiredman: sure

18:30 but I like letfn

18:31 amalloy: i have a love/hate thing with letfn

18:31 Twey: So there's no non-stack-using loop in the JVM to which one could compile TCs?

18:31 amalloy: Twey: sure, there is. but not across method-call boundaries

18:31 Twey: Ah, okay

18:31 hiredman: loop/recur infact turn into such a thing

18:32 amalloy: and clojure lets you do it within a single method using recur

18:33 &(loop [sum 0, n 1e6] (if (zero? n) sum (recur (+ n sum) (dec n))))

18:33 lazybot: ⇒ 5.000005E11

18:41 amalloy: i just noticed that if-not is implemented as `(if (not ~test) ~then ~else) - it seems to me like `(if ~test ~else ~then) is simpler

18:44 smerritt: amalloy: that wouldn't work for (if-not test then) with no else clause

18:45 amalloy: smerritt: (if test nil then)

18:45 hiredman: of course it would

18:46 smerritt: ah, right

18:48 I was thinking of ~@else, which (of course) is not what's actually written there :0

18:49 amalloy: my client persists in highlighting crap like ~@else as if it were an email. always worth a chuckle

18:59 ghiu: can anyone explain me the second row of this code? http://rosettacode.org/wiki/Probabilistic_choice#Clojure how can it use [first & rest] as key? aren't they functions? what's with the "&"?

19:00 amalloy: ghiu: you can shadow global names locally if you want

19:00 &(let [first 1] first)

19:00 lazybot: ⇒ 1

19:00 amalloy: $google clojure destructuring

19:00 lazybot: [Jay Fields' Thoughts: Clojure: Destructuring] http://blog.jayfields.com/2010/07/clojure-destructuring.html

19:00 amalloy: &(let [[first & rest] (range 5)] {:first first, :rest rest})

19:00 lazybot: ⇒ {:first 0, :rest (1 2 3 4)}

19:06 ghiu: oh, i see :)

19:06 thank you

19:09 zakwilson: I've noticed at least a couple libraries for interacting with other systems using java.util.Date or java.sql.Date. It seems to me that it would be better if they used clj-time instead.

19:10 technomancy: zakwilson: yep. j.u.Date is nearly always the wrong thing

19:11 it should probably even issue a warning when you use it; it's that bad.

19:11 zakwilson: I'm glad to see somebody better known in the community is with me on this.

19:11 technomancy: (System/currentTimeInMillis) can replace some of the more trivial j.u.Date usages

19:12 amalloy: zakwilson: always wrong in clojure, or always wrong on the jvm? like, are you saying java coders shouldn't use it either?

19:12 er, technomancy: ^

19:12 hiredman: they should use joda time

19:13 technomancy: amalloy: probably the latter

19:13 zakwilson: I'm just using a unix timestamp with mongodb right now. It looks like congomongo will convert a java.util.Date, but I don't want anything to do with those.

19:14 I store a timestamp and use clj-time within my app. This seems slightly suboptimal, but better than having to think about java.util.Date.

19:55 duck1123: I've found that using Karras with MongoDB, it's easier to keep everything in j.u.Date than anything else

20:08 seancorfield: i just started using joda-time from clojure... nice... i looked at the clj wrapper but it didn't wrap the parts of joda-time i needed :(

20:09 i'm also using date-clj which has a nice API

20:09 but i suspect i could swap all my uses of date-clj to use clj-time instead (or at least a combination of clj-time and raw joda time stuff)

20:11 hmm, clj-time still relies on clojure.contrib.def

20:12 looks like it's just for defvar so it could easily eliminate that...

20:53 technomancy: the main problem with clj-time is its absent maintainership

20:53 amalloy: technomancy: you're not busy, right? ...

20:54 (aside: i couldn't bring myself to say with a straight face that i've never used one of your projects so you must have some free time)

20:57 carllerche: How can I pass a compiler arg to javac w/ leiningen? (say -Xlint)

21:00 happy4crazy: Hi everyone, I attempted to ask this question in the Clojure google group, but didn't get much of a response: https://groups.google.com/forum/#!topic/clojure/sVCuEL5EDAk

21:00 Basically, I'm getting a pretty baffling NullPointerException

21:00 I'm translating some early SICP code to Clojure

21:01 specifically the iterative sqrt procedure from section 1.1.7

21:01 everything works correctly in Clojure 1.2.1, but not in 1.3.0

21:07 amalloy: happy4crazy: works for me on 1.3 ubuntu 11.04: https://gist.github.com/deecb8fa399965ee5da7

21:08 gfredericks: amalloy: did you try a float?

21:08 happy4crazy: huh

21:08 gfredericks: nm

21:08 amalloy: gfredericks: yes. i was trying (sqrt (square foo)) but when that worked i tried non-perfect-squares

21:08 gfredericks: clearly that's a dumb suggestion

21:08 no it wasn't

21:08 I misread twice

21:09 I'm going to stop talking now

21:09 dnolen: works for me to, 1.3 on OS X Lion, OpenJDK 7

21:09 amalloy: happy4crazy: and the code looks unimpeachable - i can't imagine how an NPE could sneak in

21:09 so it sounds like a problem with your tooling

21:09 happy4crazy: yeah, this is one of the more surprising bugs i've seen

21:10 fwiw, i'm on os x

21:10 with java 1.6.0_26

21:10 and again, 1.2.1 works perfectly; it's only 1.3.0 so far that causes the bug

21:10 amalloy: happy4crazy: i suspect your tools. how are you getting your repl?

21:11 happy4crazy: typically lein repl

21:11 i've tried lein deping 1.2.1 (works) and 1.3.0 (doesn't)

21:12 amalloy: and lein version prints...?

21:12 happy4crazy: Leiningen on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM

21:12 amalloy: hm. i'm on 1.6.1, so that shouldn't be the problem

21:13 technomancy: you didn't add a :fail-on-large-numbers option to, right? :)

21:13 happy4crazy: haha

21:15 yeah, null pointer exception if I launch clj directly, not via lein repl

21:15 dnolen: happy4crazy: did you remove all the your deps and pull them down again?

21:15 amalloy: happy4crazy: "launch clj directly"?

21:16 dnolen: rm -r lib; lein deps

21:16 happy4crazy: amalloy: i've got 1.3.0 installed via homebrew

21:16 dnolen: I'll try that

21:16 amalloy: and additionally via a project.clj

21:16 amalloy: i see. you're just pointing out that it fails with or without lein

21:16 happy4crazy: yes

21:16 amalloy: *nod* i just didn't quite get it. weird

21:17 happy4crazy: dnolen: yep, same error :/

21:19 and yeah, if i remove lib and lein dep clojure 1.2.1, everything works

21:19 so strange!

21:20 amalloy: check for microscopic cpu-goblins

21:20 happy4crazy: actually, have you tried on a different computer?

21:20 happy4crazy: amalloy: hmm, no i haven't

21:21 my guess is it will work correctly, as no one has been able to reproduce it yet :)

21:21 dnolen: happy4crazy: what OS, what JDK?

21:21 oh you said JDK above, what OS?

21:21 ah you said homebrew

21:21 happy4crazy: yeah

21:21 dnolen: k, your problem makes no sense to me

21:21 happy4crazy: 10.6.8

21:21 ha me neither

21:22 thank you everyone for humoring me though

21:26 alandipert: happy4crazy: what other libs are in your project.clj?

21:27 oh, never mind, i see that it's a problem with the homebrew provided clj

21:30 happy4crazy: alandipert: it's also a problem with whatever lein is installing, correct?

21:30 I've tried this with both the homebrew clj and a fresh project.clj file

21:32 thank you everyone, have to run

21:35 jcrossley3: amalloy: hey, so um... continuing our discussion from last night, i have this: https://gist.github.com/1288852

21:36 amalloy: #(( is wrong

21:36 jcrossley3: but note that InvalidDestinationException is a subclass of JMSException

21:37 unfortunately, the InvalidDestinationException will only be caught if i explicitly add a clause for it

21:37 is that expected behavior?

21:37 amalloy: not afaik

21:38 jcrossley3: could it be a bug?

21:38 amalloy: i doubt it. it works fine in most cases, so i'd need fairly compelling evidence that anything's actually going wrong here

21:39 jcrossley3: amalloy: why is #(( wrong?

21:39 amalloy: eg, (try (/ 1 0) (catch Exception e 10)) works fine, even though there's no explicit clause for ArithmeticException

21:40 &(#((Thread/sleep 1000) 10))

21:40 lazybot: java.lang.NullPointerException

21:40 amalloy: &(#(do (Thread/sleep 1000) 10))

21:40 lazybot: ⇒ 10

21:40 jcrossley3: amalloy: ah! (but it works, why?)

21:41 amalloy: bet you a dollar? if it works, it's because you never actually call retry

21:42 jcrossley3: it's just shorthand for (fn [] body) right? i don't need (do body)

21:42 amalloy: no, it is shorthand for (fn [] (body))

21:43 seancorfield: technomancy: really? mark committed stuff on september 26th

21:43 jcrossley3: amalloy: i c. i'm starting to wonder whether that's not the cause of my original problem now. :)

21:44 seancorfield: clj-time 0.3.1 was late september only two weeks ago

22:05 ghiu: is there a version of partial that uses the implicit argument as first and not as last argument?

22:08 amalloy: &'#((Thread/sleep 1000) true) ;; jcrossley3

22:08 lazybot: ⇒ (fn* [] ((Thread/sleep 1000) true))

22:09 jcrossley3: amalloy: yes, thanks. i think that fixed my parent exception "bug" too.

22:09 amalloy: cool

22:46 TimMc: happened to notice https://github.com/NZKoz/rails_xss just now, which is something you were saying you wish more web frameworks do. i haven't look at the source at all, so don't count this as an endorsement or anything, just a mention

23:06 scottj: dnolen: so (set! (.foo bar) baz) may be common, but is it so much less common than (.no-arg-method foo) that it's nice to not have to use the (. foo (no-arg-method)) syntax?

23:41 amalloy: fwiw, i was unaware until this thread started that (. foo member) called member if it was a no-arg method -- i thought only (.member foo) had that "guessing" property

23:41 ibdknox: haha

23:42 amalloy: thinking critically about it that was a poorly-formed idea because (.member foo) just macroexpands to (. foo member), but it's an interesting idea

23:42 ibdknox: I feel bad that I didn't have time to write a more detailed explanation for why I was against that change :/

23:42 today has been.. busy

23:43 dnolen took care of it for me :)

23:45 TimMc: Oh hey, github changed their theme.

23:45 amalloy: nice. i never thought i would see "u r a fag!!!!!!!!!!" in a paul graham essay. twitter is a wellspring of information (if anyone is curious: How to Disagree http://www.paulgraham.com/disagree.html)

23:47 TimMc: amalloy: rails_xss looks neat

23:48 napping: rails_xss? That does not sound like a good thing

23:50 ibdknox: I really don't like the new github theme

23:50 it's a design fail :p

23:51 amalloy: (inc ibdknox)

23:51 lazybot: ⟹ 3

23:51 amalloy: almost all of their changes are (big) improvements, but this change is a mess

23:52 ibdknox: yeah, I really don't understand this one

23:56 ThreeCups: I'm trying to figure out how to use the repl from leiningen ($ lein repl). How should I load my files? I've been doing

23:56 user=> (use 'my.ns :reload)

23:56 to load files. If the my.ns uses or requires other files, are they loaded at that time? It does not seem like they are. Do I need to manually load all the dependencies myself?

23:57 ibdknox: ThreeCups: the other namespaces are loaded in the context of that one, meaning that if that file depends on something it will have access to it

23:57 you could put yourself in that namespace if you wanted

23:57 ,(doc in-ns)

23:57 clojurebot: "([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."

23:58 ibdknox: hm

23:58 carllerche: napping: what's wrong w/ rails_xss?

23:58 ibdknox: that's not very informative

23:59 ThreeCups: ibdknox: thanks. I think that makes sense. So I won't have access to it unless I load it myself or change to it using in-ns. But the code in the files (is files the right word?) I do (use) will have access to what they need.

23:59 ibdknox: ThreeCups: yep. Really namespace is the right word, but most of the time that maps to a file, so.... *shrug*

Logging service provided by n01se.net