#clojure logs

2011-10-14

00:02ibdknox_dnolen: yeah, there's some stuff in pinot to help with it. I went direct to the JS API... the gclosure stuff was ridiculous
00:03ibdknox_dnolen: I need to switch it off of using seqs, but I haven't done that yet
00:36jcromartieyou know, it's *really* hard to have an off-by-one error, or an infinite loop, when you're dealing with seqs
00:36jcromartieunless you make an infinite seq of course
00:37jcromartieso I guess that's not that hard
00:37jcromartie... derp
00:41amalloyjcromartie: 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
00:43jcromartieheh
00:44jcromartiebut yeah, I'm just meditating on the nature of bugs
00:44jcromartiemost of the bugs that come along in production are a failure to coordinate mutable state
00:44jcromartie(in our system)
00:45jcromartiethings like off-by-one, or = instead of ==... those are the easy ones
00:45jcromartiethose get caught early and often
00:46jcromartiebut the subtle bugs that slip under the radar are almost *always* mutable state
00:46amalloyOBO is a special case of having to manage mutable state, of course
00:47jcromartiewell OBO doesn't have to be mutable
00:47jcromartie&(range 1 5)
00:47lazybot⇒ (1 2 3 4)
00:47amalloyi guess that's true
00:47amalloybut at least a majority of the time, OBO comes from a for loop somewhere
00:47jcromartieyes ;)
00:48jcromartiebut anyway, I'm totally sold on the following ideas:
00:48jcromartie1) pure functions are better than assignment/mutation whenever it's even remotely practical
00:49jcromartie2) 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
00:49jcromartieso I'm putting that together now
00:50jcromartie(nathanmarz's recent post is prescient)
00:50Apage43anything you're -not- sold on? That might be more interesting to discuss.
00:50jcromartieApage43: NoSQL databases :)
00:50Apage43oh fun
00:50Apage43I work for a NoSQL company
00:50jcromartieApage43: "cloud" platforms
00:51jcromartieApage43: oh, no offense of course :)
00:51jcromartiewhich one?
00:51Apage43eh
00:51jcromartieI actually like CouchDB and Mongo
00:51Apage43i largely am annoyed by the way its marketed
00:51Apage43jcromartie: Couchbase
00:51jcromartiebut I think they are squarely in the "mutable by default" camp
00:51jcromartieso are most RDBMS
00:51Apage43formerly at Couchone/Couch.io
00:52jcromartieI think I like Couch a lot, actually
00:52Apage43jcromartie: well, i mean, it -is- a datastore
00:52jcromartiesure
00:52jcromartiebut someone let me know when a (popular) datastore comes along that never loses anything, by default
00:52Apage43Couch 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
00:53jcromartiesure but it disappears
00:53jcromartiedoesn't it?
00:53Apage43it does if you run compaction
00:53jcromartieright
00:53Apage43you have the option, if you want, -never- to run compaction
00:53jcromartiehuh, interesting
00:53jcromartiebut that doesn't let you use the history itself to re-define the state
00:53Apage43you can access previous revisions of documents as long as you haven't cleaned them up
00:53jcromartieyeah
00:54jcromartieI thought that was pretty cool, but then I realized you can't count on it
00:54Apage43nah
00:54Apage43we very explicitly tell people not to count on it
00:54Apage43if you want revisions you should save the old version explicitly
00:55Apage43but you could definitely build something really close to couch that did what you wanted
00:55Apage43since it is a log-structured btree
00:55jcromartieyeah
00:55jcromartieembed the old version in the new version
00:55Apage43very similar to clojure's datastructures
00:56Apage43attachments at least work that way
00:57Apage43so do the indexes
00:57Apage43but none of that is really a user-facing feature
00:58jcromartieI'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.
00:58jcromartieso, for example
00:58jcromartieyou have a command, like (set-user-password my-db "jcromartie" "foobar")
00:58jcromartiethat gets journaled
00:58Apage43I find log-structured/journaled stuff pretty fun to think about in general
00:59amalloybrehaut: https://gist.github.com/1286289 is 4clojure's code-golf fever gone mad
00:59jcromartieand set-user-password does something like (defn set-user-password [uid pw] (update-in state [:users key] assoc :password pw))
00:59jcromartieBTW this is not how I'd do it :)
00:59jcromartieso it just sticks the password in there
01:00jcromartienow what if you want to go to SHA-1? (assume you encrypt the journals, or something like that)
01:00jcromartie(bad example, I know)
01:00jcromartieso you change set-user-password, and reload your db
01:00jcromartienow (set-user-password my-db "member:jcromartie" "foobar") gets re-applied
01:00jcromartieand you store the SHA-1
01:01jcromartieOK now you want a password policy that says you can't use the same password twice
01:01jcromartieso you update set-user-password to store the password hash in a set in the user value
01:01jcromartiere-run the journal again
01:01jcromartieand you have your user objects with their full history of password hashes
01:02jcromartieno problem
01:02Apage43course anyone with read-access to the journal has the plaintext
01:02jcromartienow, again, I'm not advocating passing plaintext passwords and other sensitive info to get journaled... but that's a problem that any datastore has
01:02Apage43yeah =P
01:03jcromartiebut you can also go into the jorunal
01:03jcromartiejournal
01:03jcromartieif you *truly* have bad data
01:03jcromartiebecause the journal is just code, too, it can be parsed and processed
01:03jcromartiewith the same tools as any other data structure
01:03jcromartiehandy-dandy :)
01:03jcromartieanyway, the trick will be seeing how this scales
01:04jcromartieI did 100K simple transactions... they read back in in about 4 seconds
01:04jcromartiebut 100K is peanuts for a big application
01:04Apage43and concurrent access is a seperate problem as well
01:05jcromartiethat can be solved at a higher level
01:05jcromartieand this just uses refs for the db state
01:05jcromartieso they get transactions for free :)
01:05jcromartiethe journal write only happens AFTER the transaction, and only if it succeeds (exceptions would cause it to fail)
01:06jcromartieand it's in order (an agent does the journal-writing)
01:07jcromartiebut yeah, it's just for fun right now
01:07jcromartieanyway
01:07jcromartiegoodnight
01:07Apage43night
02:08hiredman,(+ 1 2)
02:08clojurebot3
02:40kiumahello
02:40archaichi
02:42kiumaI 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 ?
02:44ibdknox_kiuma: http://blip.tv/clojure/clojure-for-lisp-programmers-part-1-1319721
03:02chridohi idbknox, can i ask you something regarding postgres and timestamp with timezone?
03:04amalloyibdknox_: we need an ~anyone for that
03:06amalloychrido: 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
03:12winkthen again, the problem just solved itself :P
03:16rmrfchikhit he bug in 1.3; where to report?
03:16rmrfchiki have test case
03:26rmrfchikah, that's is defn inside defn.
03:35thorwilhmm, the link to the transcript on http://blip.tv/clojure/clojure-for-lisp-programmers-part-1-1319721 actually just redirects to the group
03:35thorwiland i see no way to access the purported files section of the group
04:02gu_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)?
04:06amalloygu_: i don't think so
04:10Blktgood morning everyone
04:14brehautamalloy: re:golf, thats mental
04:15amalloybrehaut: i did that just as an exercise, but some people's solutions look like that all the time
04:16brehauti havent yet tried to golf anything
04:17dbushenkohi all!
04:17amalloyaw, you're not counting the immense savings you get by typing partial less?
04:18dbushenkowhere is the clojure pattern matching library?
04:19dbushenkook, found it: core.match
04:20brehautamalloy: haha
04:21brehautamalloy: sadly thats been countered by some brain dead thinking blowouts
04:21amalloybrehaut: that's how i feel after solving chouser's recently-submitted problem
04:21brehautthats the challenge that got me to start 4clojure
04:21amalloynice
04:21brehaut(although i decided i needed to start at the start)
04:34brehauthuh tree-seq looks really handy
04:35brehautamalloy: heres the other one i flubbed http://www.4clojure.com/problem/solutions/66
04:37amalloybrehaut: eh. i looked up the gcd algo on wikipedia
04:38brehauti should have
04:38brehauti remember from my 100 level discrete math that euclid had a smart solution a while back
04:41gu_O_o suddenly clojure started interpreting docstrings as instructions failing.. any idea on what's going on?
04:46gu_it seems a problem with the use of single quotes in the string
05:14raekgu_: sounds like a missing double quote somewhere
05:28brehauti just solved the game of life 4clojure problem. there are some amazing concise solutions there
08:39jcromartie"If I had more time I would have written less code"
08:48gu_hi, can you answer this question? http://stackoverflow.com/questions/7767775/clojure-when-to-use-mutable-state
09:17gu_hi, can you answer this question? http://stackoverflow.com/questions/7767775/clojure-when-to-use-mutable-state
09:18jcromartiegu_: taking a look :)
09:20gu_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)
09:28tordmorgu_, 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.
09:30jcromartiegu_: I posted my thoughts.
09:31jcromartieI hope they are coherent.
09:33gu_thank you! i've read it :
09:35ljosDoes clojure have some kind of sleep without calling java?
09:37jcromartieljos: is this sufficient? (defn sleep [n] (Thread/sleep n))
09:38llasramHuh. So `case' can't even be used with Java 'static final' constants, only literals values? That's kind of weird :-/
09:38jcromartiecase is lower level than cond
09:39jcromartieit's faster but more restricted
09:39llasramjcromartie: Sure, but I still would have expected it to work with the JVM equivalent of compile-time constants
09:39jcromartiemaybe that can be fixed?
09:39ljosjcromartie: it works, I just wanted to know if it was in the language.
09:42jcromartiellasram: you could probably make a case that works that way, actually
09:42llasramjcromartie: 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
09:42jcromartiewell "compile time" is loosely defined in Clojure :)
09:43llasramjcromartie: Yeah, it wouldn't be that hard, actually -- just a macro which evaluates all the exprs then passes that the built-in `case'
09:43jcromartieyup
09:43jcromartieisn't that handy :)
09:48lnostdal_i find myself needing off-line access to the clojure reference documentation at times; is this available somewhere?
09:49lnostdal_perhaps there's a dead-tree edition available too?
09:50raeklnostdal_: you can clone the gh-pages branch of clojure/clojure on github
09:50jcromartiellasram: like this https://gist.github.com/1287160
09:50raekshould be static html files
09:50jcromartie:) just for fun
09:50jcromartieI am thinking about it now, and there are probably drawbacks
09:50jcromartiebut not many
09:51raekhttps://github.com/clojure/clojure/tree/gh-pages
09:52lnostdal_cool, didn't know about that, raek
09:52jcromartieactually this macro is just a bad idea
09:53jcromartiebecause you can't tell between any old symbol and a local binding
09:54jcromartieanyway, yeah, bad idea
09:54jcromartiedon't use it
10:00`fogusdnolen: Thanks for kicking butt on ClojureScript. Greatly appreciated
10:04TweyI'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:07raekTwey: try (import 'org.eclipse.swt.widgets.Display)
10:08TimMcTwey: (import org.eclipse.swt.widgets.Display)
10:08TimMcurgh
10:09raekthe claspath actually used depends completely on how you launched clojure
10:09Tweyraek: No difference
10:09TimMcTwey: (import Foo) tries to evaluate the form Foo before calling import -- that's why you need to quote it.
10:09Twey[@ twey algiz ] % CLASSPATH=/usr/share/java/swt.jar:$CLASSPATH clj
10:09TweyTimMc: Ah, I see
10:09raekTwey: there is no standard clojure launcher script
10:09dnolen`fogus: np!
10:09TimMcTwey: I never mess around with classpath directly -- have you tried using lein?
10:10TimMcTwey: https://github.com/technomancy/leiningen
10:10TweyI'm aware of its existence, but I've been skirting it ☺
10:10TimMcIt's really, really nice.
10:10raekTwey: 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:11raekthe launcher shell scripts that circulates on the net are pretty much only usable for "hello world"
10:12`fogusBreaking changes (likely) coming to ClojureScript. http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax
10:13Tweyraek: Success! Thank you ☺
10:13TweyI'll try to get Leiningen working
10:14raekTwey: to use lein and swt you need to find a Maven artiact for SWT
10:14raekthen you declare it as a dependency rather than give it the jar
10:15Twey>.<
10:15raekTwey: http://jarvana.com/jarvana/ <-- search engine for java maven artifacts
10:15TweyThere seem to be so many cognitive dependencies for writing a ‘Hello World’ app in anything Java-based
10:16llasramjcromartie: Oh, actually, I'd wandered off to write my own version :-) https://gist.github.com/1287230
10:16TweySo… Maven is a build manager? But I thought leiningen was a build manager?
10:16raekwell, at least maven and the clojure community share a dependency system...
10:17raekTwey: yes, but leiningen uses the dependency parts of maven
10:17TweyAh right
10:17llasramjcromartie: 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:17meliponehelp! how do i remove-duplicates but keep the order of the list?
10:17raekmelipone: distinct
10:17meliponedistinct does not work for me because I need to extract the name of an object
10:18raek,(distinct [1 1 9 7 1 6 3 9])
10:18clojurebot(1 9 7 6 3)
10:18jcromartiellasram: yours tries to eval strings and numbers
10:18llasramjcromartie: Which is fine
10:18llasram,(eval 1)
10:18clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:18llasramHaha
10:18meliponedistinct does not work because I have a list of structs
10:18llasramOk, anyway, it just returns the same reader-literal
10:18jcromartiemaybe that's in 1.3?
10:19jcromartiehuh weird
10:19jcromartieoh I had some other error
10:19raekmelipone: so "equality" in your case means something else than that the structs are equal?
10:19jcromartieI assumed...
10:19meliponeyes, i need to extract the name from the struct and do the equal on that
10:20jcromartiegood catch
10:20llasramThere probably are problems with the approach, but it's working for my case ATM. Thanks for the inspiration in the right direction :-)
10:22Squeese"Clojure is high signal, low noise." Im lost as to what this means
10:22dnolen`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:23dnolenSqueese: less ceremony.
10:23raekmelipone: 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:24raekhttp://clojuredocs.org/clojure_core/clojure.core/distinct#source
10:25Squeeseless ceremony? Omg, abstractions is totally lost on me.. ;(
10:26SqueeseOr would the correct word be metaphor? lolzlzlz brains not compute, leaving..
10:26gamzovicovhello
10:26ljosI 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:26ljosI can create the object from the class though.
10:27gfredericksljos: are they static or instance methods? what syntax are you using to call them?
10:27ljosgfredricks: instance methods. I am running (.getScore msp)
10:28raekmelipone: something like this https://gist.github.com/1287265 (not tested)
10:28gfredericksljos: and what's the error message?
10:28jcromartieSqueese: ok let's slow down
10:28raek(distinct-key :name structs)
10:28ljosException in thread "main" java.lang.NullPointerException at mspacman.NUIMsPacman.getScore(Unknown Source)
10:28jcromartieSqueese: compare Java's "hello world" with Clojure's
10:29TweyHmph
10:29gfredericksljos: sounds like the method is getting called but something's going wrong inside the method?
10:29Squeese"Clojure is high signal, low noise" is really just saying "Less code" ?
10:29ljosNo.. I can run it from java.
10:29jcromartieSqueese: now compare a transactional concurrent datastore in Java with a Clojure version :)
10:29jcromartieSqueese: not just less code, but the right code...
10:29gfredericksljos: and the method doesn't take any arguments?
10:29ljosnone
10:30TweyWent 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:30jcromartieSqueese: for example, I can write an API like this in Clojure: https://gist.github.com/be1d88c9c0363e542f4f
10:30gfredericksljos: and (type msp) returns your class?
10:30Squeesejcromartie: 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:30jcromartieSqueese: not in the sense of "logically correct"
10:30ljosgfredricks: yes
10:31ljosgfredricks: 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:31Twey(.. System (getProperties) (getProperty "java.class.path")) includes /home/twey/Development/Clojure/swt/lib/swt-3.7.1.jar
10:31jcromartieSqueese: 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:31TweyWhich is something Leiningen put there >.>
10:31gfredericksljos: maybe you could put the full stack trace in a paste?
10:32gfredericksljos: 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:32Squeesejcromartie: ok, thx :)
10:32jcromartieSqueese: 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:32raekTwey: did you include it under :dependencies in your project.clj file?
10:32ljoshttp://pastebin.com/fyFxjr9r
10:32gfredericksljos: i.e., maybe you're setting things up differently when you do it from java?
10:32Tweyraek: [org.eclipse.swt/swt "3.7.1"]
10:33ljosgfredricks: how could it be different? It's a method call!
10:33gfredericksjcromartie: the stack trace clearly indicates that your method is being called.
10:33gfredericksljos: sorry, ^that was for you
10:33gfredericksljos: is it your java code? could you stub that method with "return null" and see if it succeeds?
10:33TweyThe 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:33Squeesejcromartie: 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:34jcromartieSqueese: yeah, pretty much
10:34Squeesejcromartie: ah ok, cool - then Im aboard :)
10:34jcromartieSqueese: anything that doesn't express the solution to your problem
10:34jkkramerTwey: you sure org.eclipse.swt.Display exists?
10:35Tweyjkkramer: I have no idea
10:35TweyHow would I find out?
10:35jkkramerfirst google result is org.eclipse.swt.widgets.Display
10:35raekTwey: are you sure it shouldn't be org.eclipse.swt.widgets.Display?
10:35TweyAh, like that
10:35jkkrameri don't know, presumably you're entering it for a reason
10:35TweyHaha :-D
10:36Squeesejcromartie: so, were just waiting on someone to figure out how to remove all the (((( and )))) noise and were set. :)
10:36TweyYay, new error
10:36raekTwey: but the dependency and the classpath looks good, so I think you're all set in that area
10:36Tweyjava.lang.UnsatisfiedLinkError: no swt-gtk-1.0.0-SNAPSHOT or swt-gtk in swt.library.path, java.library.path or the jar file
10:36ljosgfredrics: 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:36TweyDo 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:36TimMcSqueese: Then you have Haskell, which I find less readable.
10:37jcromartieSqueese: sure, but right now the ((( and ))) are what let you get rid of things like class definitions
10:37ljosgfredicks: though it does do it in java.
10:37gfredericksljos: are you using maven?
10:37jcromartieso I'll take the parens and uniform syntax along with the ability to create any kind of syntax form I need
10:37jcromartiethat's the key: forms
10:37ljosgfredrics: not really.
10:38gfredericksljos: some build tool? or just raw command-line java/javac calls?
10:38raekTwey: 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:38ljosgredricks: For clojure I'm using leiningen. For java I start everything from eclipse mostly.
10:39gfredericksljos: so it's something that eclipse is doing for you that leiningen isn't, does that sound plausible?
10:39Squeeseis there a syntax disagreement within lisp as it does in "c like langs" as to where to put {, new line or not? :)
10:39gamzovicovi'm new in clojure and i want to lern functional programing
10:39Tweyraek: Yes, but I just get a lot of code tutorials & not so many setup ones :-\
10:39gamzovicovcan someone tell me a good tutorials
10:39gfredericksgamzovicov: 4clojure.com
10:40raekI've heard that the maven package system does not have a standardized way of dealing with native dependencies... :/
10:40jcromartieSqueese: there's a general Clojure style
10:40`fogusdnolen: I will definitely bring it up on the ML. Formulating a post now
10:40TimMcSqueese: Do what Emacs tells you. :-)
10:40jcromartiedon't put parens on lines by themselves
10:40jcromartieyeah I was going to say
10:41TimMcamalloy_: There should be more real-estate-based puzzles on 4clojure
10:41TimMcor banking :-P
10:41jcromartiejust like Ruby style :) ... Matz uses ruby-mode
10:41ljosgfredricks: It does. But I'm am very unsure of what. EVerything should be on the buildpath.
10:41SqueeseTimMc: damnit, emac keeps bugging me, Im trying to stick with Textmate.. I really have to try emacs :P
10:42raekTwey: found this: https://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All
10:42TimMcIt's worth the long learning curve.
10:42st3fanemacs is awesome
10:42gfredericksljos: 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:43TimMcSqueese: 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:43TimMcOver time you'll stop using the cheatsheet.
10:44SqueeseTimMc: I didnt really understand what you said, but I guess I will when I learned the emac basics? Copy paste msg for later.
10:44TimMcThose are some examples of commands you will want to know right away.
10:44Squeeseaha ok
10:45Tweyraek: Ah, your Google-fu is strong. Thanks!
10:45TimMcCancel, hide all but current buffer window, search help, quit.
10:45jcromartieParedit is just amazing
10:46TimMcAt the very least, paredit means only typing half the parens. :-)
10:46jcromartiePeople 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:46raekclojurebot: swt?
10:46clojurebotTitim gan éirí ort.
10:46jcromartiebecause you can really slice and dice expressions
10:46ljosgfredricks: 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:46SqueeseTimMc: thx
10:46raekclojurebot: swt is https://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All
10:46clojurebotOk.
10:46TimMcjcromartie: Yeah, if I could edit Java forms the way I can edit Lisp forms, Java would suck a bit less.
10:46jcromartieand in other languages, where the syntax isn't uniform, you just can't do that, even with a powerful IDE
10:47ljosgfredricks: but I'll see what happens when I run it form the terminal.
10:47TimMcM-x java-slurp-try-catch-backwards :-P
10:50TimMcThat would break declarations, though.
10:51Tweyraek: No, I just keep getting the same >.<
10:52TimMc`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:52raekTwey: did you run a lein deps in between?
10:53TweyI did
10:54ljosgfredricks: I have to look at it tomorrow. I have to go now. Thanks for the help though.
10:54gfredericksljos: yessir
10:54TimMcTwey: Doess lein classpath show the SWT jar?
10:55raekTwey: Are you using exactly the same deps as in the tutorial? Otherwise I'm out of advice, I'm afraid.
10:56TweyTimMc: /home/twey/Development/Clojure/swt/lib/swt-linux-gtk-x86_64-3.3.0.jar is in there
10:56Squeeseis there anything I need to install extra with emacs to "support clojure" like plugin or something?
10:57Tweyraek: No, I'm using linux-gtk-x86_64, not win32-win32-x86_64
10:57TweyBut other than that, yes, as far as I can tell
10:57Twey(and no guiftw, obviously)
10:57FletchcutusHave 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:58TweySqueese: You'll need clojure-mode; see if you can M-x clojure-mode, & if not you might need to install it
10:58Squeeseok thx
10:58TweySqueese: I use the modification from ergoemacs.org which includes clojure-mode amongst other things
10:59FletchcutusMy first attempt was something like (map (fn [[m1 m2]] (== (. o1 m1) (. o2 m2)) [ [:o1Method :o2Method] ])
11:01Fletchcutusbut that complains about no matching field found m1 for class (class of o1)
11:01Fletchcutusam I barking up the wrong tree?
11:02gfredericksFletchcutus: I'm not sure there's an easy way to call java methods programmatically. Might have to use java reflection?
11:02FletchcutusEeew. :/ Same conclusion I was coming to.
11:03gfredericksFletchcutus: not too hard to write a helper method for that though
11:03Fletchcutusyeah, a macro similar to what memfn does would prossibly do it
11:04Fletchcutuswas just diddling in the repl trying to come up with some tests for some swig'd c++ really quick.
11:04gfredericksFletchcutus: actually I think you would want exactly _not_ a macro
11:05gfrederickssince a macro would require you know the name of the method
11:05TimMcWhen possible, don't put core functionality into macros.
11:06TimMcTwey: You have looked in the jar to make sure org/eclipse/swt/Display.class is there?
11:07raekFletchcutus: use = and not ==
11:07TimMcTwey: Are you using (import '...) from the REPL or (:import ...) in the ns form?
11:08raekFletchcutus: since methods are not first class on the jvm, you need to wrap them in clojure functions
11:08TweyTimMc: REPL (import …)
11:08TimMck
11:09raek(map (fn [[m1 m2]] (= (m1 o1) (m2 o2))) [[#(.m1 %) #(.m2 %)]])
11:09TimMcTwey: org.eclipse.swt.*widgets*.Display, maybe?
11:10TweyTimMc: Yep, it exists
11:10Fletchcutusraek: ooh, that looks promising
11:10TimMcunder the widgets subpackage, or under swt directly?
11:10TweyTimMc: Under ‘widgets’
11:10raekTwey: what error did you get? class not found or native library thingy?
11:10TweyYeah, I know, I was typo'ing that at the start — we got past that
11:11TimMcAh, OK.
11:11TweyI'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:11TweyI'm not really very sure what that even is
11:11TweyIs it looking for a directory?
11:12raekthat probably means that it doesn't find a native library
11:12Fletchcutusrake: that works but it's a slight bit uglier than I'd hoped for. Thanks :)
11:12stuarthallowaynaming help requested
11:12TimMcstuarthalloway: "Jennifer"
11:12Tweyraek: Yeah, that's what I figured ;) I'm just not sure what to do to make it find one…
11:12stuarthallowayI need a name for an exception type, to be added to Clojure, the carries along structured data
11:13gfredericksStone? :)
11:13TimMcraek: Sounds like Display is found, but it is not finding some dep of its own.
11:13stuarthalloway.net gets this right, having data on the base exception type: http://msdn.microsoft.com/en-us/library/system.exception.data.aspx
11:13TimMcstuarthalloway: This would be ? extends Exception?
11:14stuarthallowayTimMc: extend RuntimeException to stay out of checked exception land
11:14TimMcright
11:14raekTwey: maybe you need to install some package in you OS? (like GTK header files or something)
11:14raekI'm just guessing here
11:14gfredericksRuntimeExcljeption?
11:14TimMcterrible
11:15stuarthallowaythis exception should be usable as a building block for different exception libraries
11:15raekstuarthalloway: ClojureException? ;-)
11:15Fletchcutusraek: 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:15stuarthallowaysuch that the higher level libraries do not need to make a new class, and (importantly!) do not need AOT
11:15stuarthallowayraek: certainly on the list
11:15stuarthallowaygfredericks: ouch
11:16stuarthallowayconsidering StructuredException
11:16stuarthallowayor Mulligan
11:16stuarthalloway:-)
11:16gfredericks~second
11:16clojurebotMotion seconded and carried. Next agenda item.
11:16TimMcstuarthalloway: 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:17stuarthallowayTimMc: would be foundation for that
11:17TimMcOK.
11:17TimMcShort names are nice. How about Fit, as in (throw (Fit.))
11:17Tweyraek: Uhh… I don't think so: it works from Java
11:18Twey(using my system libs, rather than the SWT ones)
11:18raekmaybe the exception should have a name that suggests that the name is about the exception and not about the cause
11:18TimMcTwey: 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:18stuarthallowayhmm... Exc? Err? Condition?
11:18stuarthallowayraek: agreed, and that is tricky because everybody exceptions the name to tell you about the problem
11:19stuarthalloways/exceptions/expects
11:19lazybot<stuarthalloway> raek: agreed, and that is tricky because everybody expects the name to tell you about the problem
11:19TweyFor that matter, it works if I use my system libraries in general
11:19raekTwey: 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:20raekDataCarryingException
11:20stuarthallowayTimMc: notes are rough, but at http://dev.clojure.org/display/design/Error+Handling
11:20TimMcstuarthalloway: Would this name show up in 1) stack traces, 2) relying Java code, 3) relying Clojure code (excepting exception libs)
11:20TimMcthx
11:20cemerickstuarthalloway: I've always liked Fault and Signal
11:20hugodTimMc We've been implementing that sort of message buildup with contexts in pallet
11:20stuarthallowayTimMc: yes, like any class name it will show up in stack traces
11:21stuarthallowaycemerick: both good
11:21TimMccemerick: Nice.
11:21stuarthallowayseems like we have three categories of possible name
11:21stuarthalloway(1) synonym for exception, suggesting that this is how you do it in Clojure, e.g. Fault Signal
11:22TimMcstuarthalloway: 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:22stuarthalloway(2) something that tells you the exception carries info, e.g. DataCarryingException or StructuredException
11:22jkkramerPayloadException
11:22jkkramer?
11:22stuarthallowayor (3) goofy brand name. e.g. Mulligan or Fit
11:22TimMc"FooException" tells me "Something went wrong in or with Foo"
11:23gfredericks"Something went wrong in or with Structured"
11:23stuarthallowayyeah
11:23stuarthallowaywhich argues for a category 1 name
11:23cemerickCamelCaseOftenHurts
11:23cemerickExceptionStructuredThusly, or perhaps ExceptionCarryingData
11:24TimMcIf we use cat 2, s/Exception/Exc/
11:24stuarthallowaythen the tradeoff becomes name length
11:24gfredericks(throw (new E))
11:24stuarthallowayas this may become the exception you typically deal with in Clojure
11:24TimMc\o/
11:25raekan adjective or a verb in -ing form has the advantage of not making sense when interpreted as "Something went wrong in or with _____"
11:25gfredericks"Something went wrong while _____"
11:25raekhrm, yeah
11:25gfredericksnot for adjectives though
11:25gfredericksColorfulException
11:26raekforgot that the -ing ending can form both a noun and an adjective... :/
11:26raeknaming is always the hardest part :)
11:27gfredericksVectorSetPointerOutOfKeyHashException
11:27TimMcgfredericks: Good one, no one will have any preconceptions.
11:28gfredericksif we had punctuation in class names we could (throw (new E!??!))
11:28TimMcSo the point here is to have a single exception class that allows non-type-based dispatch?
11:28gfrederickshow does it relate to slingshot?
11:28stuarthallowayTimMc: 1st goal IMO is to have data
11:28TimMck
11:29raekRequestSpecificProcessorFactoryFactoryException
11:29stuarthallowaygfredericks: hopefully slingshot would use it as mechanism and not need AOT compilation as a result
11:29gfredericksPregnantException
11:29gfredericksstuarthalloway: so it's mostly just replacing slingshot's Stone class?
11:29stuarthallowayTimMc: there is, ahem, disagreement about how/whether to do non-type based dispatch
11:30stuarthallowaygfredericks: that is a slingshot specific way of looking at it :-)
11:30TimMcBubble
11:30gfredericksHotPotato
11:30TimMc(blow (Bubble.))
11:30gfredericks\o/
11:30stuarthallowayI am leaning toward a category 1 (synonym for exception) name
11:30stuarthallowayall the "I has data" names are too long and ugly
11:31TimMcgfredericks: I am totally going to use HotPotato in my next Java project.
11:31stuarthallowayand once you get use to it ("of course Clojure exceptions have data") you won't care about that anymore
11:31hugodstuarthalloway: will this introduce new try and throw forms?
11:31stuarthallowayhugod: no and maybe
11:32stuarthallowayno: this is a freestanding simple thing
11:32stuarthallowaymaybe: at some point in the future some enhanced exception capabilities might use it
11:32TimMcstuarthalloway: Fault is less likely to name-collide than Signal.
11:32stuarthallowayTimMc: and I don't want to encourage the notion of signalling for non-error conditions
11:32TimMcAnd Signal might encourage control-flow usage -- is that bad?
11:32TimMcright
11:33stuarthallowayTimMc :-)
11:33TimMcIs that still expensive in the JVM?
11:33clojurebotI don't understand.
11:33@rhickey@stuarthalloway you are talking about the interface name?
11:33TimMcclojurebot: Maybe when you're older.
11:33clojurebotGabh mo leithscéal?
11:33stuarthallowayrhickey: no, the concrete name
11:33stuarthallowaywhich people will have to throw and catch
11:35@rhickeyhrm, the interface not buying us anything then
11:36stuarthallowaybeautiful Java
11:36stuarthallowaycan neither throw nor catch and interface
11:36@rhickeythat changes things a bit
11:37stuarthalloways/and/an
11:37lazybot<stuarthalloway> can neither throw nor catch an interface
11:37TimMcYou can't catch an interface?
11:37stuarthallowayTimMc: you have to catch a subclass of Throwable
11:37TimMcAha!
11:37hugodis it envisaged that people will subclass this? or that core will subclass it?
11:38gfredericksstuarthalloway: 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:38stuarthallowayhugod: hope not!
11:38@rhickeyExceptionData?
11:38gfredericksthat sounds like it's not an exception
11:38stuarthallowayyeah
11:38@rhickeywhat is an exception?
11:39stuarthalloway(to gfredericks)
11:39gfredericksis this a trick question?
11:39@rhickeynope
11:39@rhickeyDoes Exception sound like an exception?
11:39gfredericksthen (partial instance? Exception), I would say
11:39@rhickeyor Throwable?
11:39stuarthallowaya piece of data passed by stack unwinding
11:40gfredericksrhickey: ExceptionData sounds like just a data class, e.g., that an exception would keep an instance of
11:40stuarthallowayrhickey: I am warming to it
11:40@rhickeyonly 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:41stuarthallowayrhickey: and is the interface dead now, just a concrete getData method?
11:41@rhickeyit itself is information about the error
11:41@rhickeyExceptionInfo w/getData
11:41@rhickey?
11:42@rhickeystuarthalloway: yes, dead
11:42stuarthallowayExceptionInfo w /getData works for me
11:42@rhickeystuarthalloway: go for it
11:42stuarthallowayuseful to note that .NET API name is getData
11:42stuarthallowayor however they capitalize it
11:42stuarthallowayand correctly placed on the base class
11:43stuarthallowaycemerick: while I like Signal, I have come around to ExceptionInfo because it implies a position about what exceptions are
11:43lucianGetData most likely
11:44@rhickeychouser: Signal just invites new semantics not supplied
11:44stuarthallowaycemerick: did anybody finalize the reflection warning patch? I want to apply that today too
11:44TimMcrhickey: How about Fault?
11:44cemerickYeah chouser, knock it off! ;-)
11:44chousersorry! man.
11:45cemerickstuarthalloway: I don't think so; I can add the test in a separate patch on the ticket if you like.
11:45@rhickeyExceptionInfo supports IDeref in addition to getData?
11:45stuarthallowaywhich returns what?
11:45@rhickeythe map
11:45gfredericksgetData always returns a Map? or an Object?
11:46@rhickeyMap
11:46stuarthallowaybut the map isn't everything (does not have the message, stacktrace)
11:46@rhickeystuarthalloway: right, so?
11:46stuarthallowaymakes me feel uncomfortable with IDeref
11:46gfredericksshould it then be assoc'able as well so you can add more data?
11:47@rhickeyok, but getData is going to look gross, so you'll need to wrap it in Clojure with ___
11:47stuarthallowaygfredericks: maps are assoc'able
11:47TimMcBut it HasA, not IsA.
11:47gfredericksstuarthalloway: right, but then you'd have to construct the new ExceptionData manually
11:47stuarthallowayrhickey: I am usually the one with the casual attitude about IDeref-for-convenience :-)
11:47gfredericks(assoc my-exception-data :more "info") => returns new exception with data added to map
11:48gfredericksdoesn't IDeref normally imply state?
11:48@rhickeystuarthalloway: that's fine, just asking wat's the Clojure interface then (i.e. not (.getData ex))
11:48stuarthallowaygfredericks: no to assoc
11:48TimMcstuarthalloway: 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:48TimMce.g. Signal
11:49stuarthallowayrhickey: error-info, exception-info, I dunno
11:49stuarthallowayTimMc: confused by that last
11:49@rhickeyexception-info-info? They just caught ExceptionInfo
11:50chouserInfoException
11:50@rhickeyaargh
11:50TimMcstuarthalloway: As in, you don't want it misused for multiple-return-values, etc.
11:50chouserand therefore info-exception-info :-)
11:50@rhickeyBlahException implies a problem with Blah
11:50chouserHm.
11:51stuarthallowayTimMc: vector or map work fine for that, no?
11:51TimMcTrue. I think I'm confused.
11:52@rhickeyTimMc: we're getting a bunch of semantics from Exception/Throwable we can't disentangle, this isn't green field
11:52stuarthallowayTimMc: this is worth doing to prevent libs from requiring AOT just to have an exception type
11:52TimMcRight. That's an important point.
11:53@rhickeyand to get people away from type switching error handling
11:53@rhickeya truly bad idea of JAva's
11:53cemerickIt wouldn't be horrible if this exception type implemented IDeref, and returned a map of {:message … :trace … :data …}
11:54@rhickeycemerick: lots of problems with defining how much work that might do etc
11:54@rhickeywe are just looking for access to what .getData provides
11:54@rhickeyex-data?
11:54TimMccemerick: Feels a bit implementation-dependent.
11:54gfredericks~second
11:54clojurebotMotion seconded and carried. Next agenda item.
11:55TimMcgfredericks: Who are you seconding? :-)
11:55cemerickThen I'd agree that IDeref is unsuitable.
11:55gfredericksTimMc: rhickey re: ex-data
11:55@rhickeyfine, not pushing that, ex-data or ___?
11:55stuarthallowaywould ex-data have well defined semantics when passed a non ExceptionInfo?
11:55@rhickeynil
11:56gfrederickswhereas getData always returns at least an empty map
11:56@rhickeyno
11:56gfredericksno
11:56gfredericks:)
11:56TimMcgetData would be a method, yeah?
11:56cemerickgfredericks: .getData sounds like it will be the method on the exception type
11:56@rhickeygetData returns whatever map was supplied to the ctor, which might have been nil
11:57gfrederickscemerick: yes
11:57TimMcor NPE if the whole thing is nil
11:57gfrederickshard to avoid that one :)
11:57stuarthallowayI currently have it type checking for IPersistentMap not Map, though. Don't you dare pass a mutable map
11:57@rhickeyExceptionInfo, .getDAta, ex-info returns .getData if ExceptionInfo, else nil - objections?
11:58stuarthallowayworks for me
11:58cemerickThe quorum of 5 in irc @ 11:57 concur!
11:58@rhickeyIPersistentMap is fine in API
11:58chouserThis will be so nice
11:58cemerick:-P
11:58@rhickeypeople will need to know they can assoc on it to add passing upwards
11:59chouserClojure itself will be throwing these eventually?
11:59@rhickeyheh, I promised Stu that would be the first question
11:59chouser:-)
11:59@rhickeystuarthalloway: IPersistentMap in the surface API, not an internal check
12:00stuarthalloway ok
12:00@rhickeygotta run, thanks all
12:01stuarthallowaythx
12:08BorkdudeI'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:08Borkdude
12:08Borkdudeany clues?
12:08BorkdudeThe script I made is up here: https://gist.github.com/1287481
12:09SqueeseDoing 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:10gtrakSqueese, there's a code golf that tells you how long yours is compared to others'
12:10Squeeseon the site?
12:15TimMcSqueese: Go to account settings and join the Golf League
12:15SqueeseTimMc: oh, thx
12:15TimMcYou can also follow other users to see their solutions.
12:15TimMcSqueese: And don't forget #4clojure !
12:15Squeeseagain, really appreciate the help, my "help vampire meter" is giving off alarms atm :))
12:16TimMchaha, no worries
12:17kzarIf 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:18luciankzar: you could use a queue system that you set tasks in, and have code run on it separately from the frontend
12:18lucianlike a cron job
12:22kzarlucian: 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:23luciankzar: sure. or you could use something like 0MQ
12:23lucianthere's celery for python, don't know about clojure/java
12:40di-csuehsI 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:46dnolendi-csuehs: it's a good idea to reach for multimethods first.
12:49PPPauli want to have functions called from java in my lein project.... how to?
12:50kzarIf 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:50kzarI 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:51TimMckzar: Just make a new folder called samples. I really doubt lein will package it up.
12:52TimMcTo 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:52PPPaul>_<
12:53raekkzar: take a look at https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj
12:54raekkzar: it mentions :extra-classpath-dirs
12:54TimMcPPPaul: You mean, you want to call out to Java from a Clojure file?
12:54raekthose will be included in the classpath but not in the jar
12:54`fogusI'm working on a super-mega invokedynamic post (from a Clojure perspective)... anyone interested in reading a draft?
12:54PPPauli want to call clojure from java
12:54PPPaulclojure in a lein project
12:55raekPPPaul: https://gist.github.com/1273014
12:55PPPauli've done it via a main method... i want to make some static methods
12:55PPPaulthanks
12:55raekthis is one way to do it
12:55raekanother nice way is to define an interface in java and let the clojure code implement it
12:55PPPaulhmmm
12:55raeke.g. with deftype, defrecord or proxy
12:56PPPauli'm using gen-class
12:56PPPauli don't want to scare my java programming buddies
12:56raekgen-class is useful too when the java code needs a concrete class
12:56raekbut it makes it harder to do interactive development
12:56PPPauli'm following this site, but it's not working: http://java.dzone.com/articles/java-clojure-interop-calling
12:57PPPaulkeeping my java buddies happy is more important than interactive dev
12:58gfredericksPPPaul: use a FactoryBean?
12:58raekPPPaul: you need to AOT compile the namespace for gen-class to work
12:58PPPaulfactory bean?
12:58PPPaulok
12:58PPPauli made an uber jar
12:59PPPaulthat's not good enough?
12:59gfredericksPPPaul: bad joke
12:59PPPaulyeah, i was looking that up... spring... wtf :P
12:59raekPPPaul: I think you need to make an :aot your-namespace entry in your project.clj file
12:59PPPaulok, i'm going to try that
12:59gfredericksPPPaul: honestly I don't even really know what a factory bean is
13:00raekPPPaul: but consider using deftype/defrecord/reify/proxy with an ordinary java interface
13:01PPPaulhmmm, i have no java interfaces
13:02raekif 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:02PPPauli'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:03PPPauli understand that
13:04PPPauli'm only giving them static methods, though
13:04raekok, in that case gen-class is perhaps the most convenient way
13:05raekanother 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:05gfredericksPPPaul: I wrote some utility code that takes your NS and makes all the public functions static methods on the gen-class
13:06gfredericksto reduce the boilerplate and maintenance
13:06raekand 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:06raekessentially what gen-class does, so maybe a bit unessecary
13:07gfredericksI've also ended up deing exactly what raek just suggested. The difference being the compile-time relationship between the codebases
13:09raekit would be nice to be able to just compile the gen-class part of a namespace
13:10PPPaulhmmm
13:11PPPauli want 1 static method and 1 class.... it can't be so hard
13:11PPPauli don't care about the boiler
13:12PPPauldo you see anything wrong with my gen-class?
13:12PPPaulis my :name wrong?
13:14gfredericks:name has to be fully qualified, static methods have to be explicitly marked
13:15PPPaulok
13:15PPPaulexample? :D
13:15PPPauli removed my "name
13:15PPPaul:name
13:15PPPaulhope that will help
13:15gfredericks:name foo.bar.Baz, :methods [[^:static runHelloWorld [] Object]]
13:16gfredericksyou can leave off :name but I'm not sure what it defaults to
13:16gfredericksalso your function names have to be prefixed, so in the case of my example you would (defn -runHelloWorld [] ...)
13:16llasramgfredericks: defaults to the name of the namespace
13:16gfredericksllasram: will it also do that if you call (gen-class) directly?
13:17llasramgfredericks: Oh, no. Non-optional in that case
13:17gfrederickskay
13:17PPPaulok, i changed my method name... going to see if this works
13:18llasramPPPaul: Is the issue specifically doing it in a leiningen project, getting the code to build in the right order?
13:20llasramI 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:21PPPauli'm using lein
13:22PPPaulhttps://gist.github.com/1287721
13:22PPPaulthat is my project.clj
13:22PPPaulmy program still isn't callabled from java
13:22PPPauli think my class is found, though
13:22llasramAnd are you using it with a single project containing Java and Clojure code, where you want the Java code to Clojure code?
13:23PPPauli'm making a stand along static class that i'm turning into an uberjar and giving to the java project
13:23llasramOh, ok then. nm :-)
13:23PPPauli don't see where my code is used
13:25PPPaulthis is my src https://gist.github.com/1287730
13:25PPPaulreally hoping to figure this out :)
13:28BruceBGordonlein newbie help. Lein isn't configured properly.
13:28BruceBGordonbruce@mepis1:~/bin$ lein search hadoop
13:28BruceBGordonWarning: couldn't download index for http://repo1.maven.org/maven2
13:28BruceBGordonWarning: couldn't download index for http://clojars.org/repo/
13:28BruceBGordonbruce@mepis1:~/bin$
13:28PPPaulwell
13:28PPPaulmy package is being detected, my not classes
13:28PPPaulpackage being touchViews
13:34robermannPPPaul: your Java packages import "touchViews.core" ?
13:34Squeese4clojure ftw, amount learned / time > books =)
13:36Squeesebut 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:38gfredericksSqueese: is that a question? :)
13:39Squeeseif you know and its trivial, sure :)
13:39Squeesefeel free to tell me to read a book though ^^
13:39gfredericksit'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:39gfredericksvectors are optimized for random access/updates and for adding to the end
13:40gfredericksconj is a function that adds to a data structure in some way that's appropriate for that data structure
13:40gfrederickscontrast with ##(cons 7 [1 2 3])
13:40lazybot⇒ (7 1 2 3)
13:40ibdknox_,(conj {} [:a "hey"])
13:40clojurebot{:a "hey"}
13:40gfredericks,(conj #{8 9} 9 10)
13:40clojurebot#{8 9 10}
13:41gfredericks,(cons #{5 6 3} 4)
13:41clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
13:41gfredericksw00ps
13:41ibdknox_lol
13:41gfredericks,(cons 4 #{5 6 3})
13:41clojurebot(4 3 5 6)
13:41gfrederickspoint being that cons ignores the type of the collection you pass in and just treats it like a seq
13:41Squeesewhat is cons short for?
13:42llasramcons
13:42ibdknox_,(doc cons)
13:42clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
13:42gfrederickscons is kind of classic
13:42Squeeseaha ok :)
13:42gfredericksit doesn't need to stand for anything
13:42ibdknox_Squeese: http://en.wikipedia.org/wiki/Cons
13:42ibdknox_stands for constructs
13:42ibdknox_like conj = conjoin
13:43Squeeseahh I see
13:43Squeesesweet, thanks btw :D
13:45ibdknox_clojurebot: thanks is We live to serve.
13:45clojurebotIn Ordnung
13:45ibdknox_~thanks
13:45clojurebotthanks is We live to serve.
13:45ibdknox_hm
13:46ibdknox_clojurebot: forget thanks |is| thanks is We live to serve.
13:46clojurebotI forgot that thanks is thanks is We live to serve.
13:46ibdknox_clojurebot: thanks |is| We live to serve.
13:46clojurebotOk.
13:47ibdknox_~thanks
13:47clojurebotthanks is We live to serve.
13:47ibdknox_hrm
13:47ibdknox_I give up :p
13:48technomancyclojurebot: forget thanks |is| We live to serve.
13:48clojurebotI forgot that thanks is We live to serve.
13:48technomancyclojurebot: thanks is <reply>We live to serve.
13:48clojurebotIn Ordnung
13:48ibdknox_ah
13:48ibdknox_~thanks
13:48clojurebotWe live to serve.
13:48ibdknox_I see
13:48ibdknox_technomancy: thanks ;)
13:48technomancywe... uh...
13:49technomancywait a minute
13:49technomancyheh
13:49ibdknox_hehe
13:51floatbothHi 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:52technomancyfloatboth: there's a lein plugin for that, but I don't remember the name
13:52technomancyah, lein-sub
13:53floatbothtechnomancy: thanks
13:55technomancysure
13:59BorkdudeIs there a map variant which concats the resulting seqs from every "iteration"?
14:00Borkdudelike map-str only more general
14:00smerrittmapcat, perhaps?
14:00smerritt,(doc mapcat)
14:00clojurebot"([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:01Borkdudeah yes, tnx
14:02Borkdudewonder why it didn't come up when I entered map into clojuredocs
14:07timvisherdo multi-methods support variable argument implementations?
14:08timvisherarities, as the big kids say. :)
14:09jcromartieI dunno... have you trie?
14:09jcromartietried
14:09timvisherlooks like no
14:09jcromartiemaybe throw a trie in, for fun
14:12amalloytimvisher: multimethod implementations are just functions, and can do anything functions can do
14:13Borkdudefinally, it works! https://gist.github.com/1287481
14:14timvisheramalloy: gotcha. i think i'm just too green to get it at the moment. first forray into multi-methods and all that
14:14BruceBGordonlein cannot use repositories-bad configuration?
14:15BruceBGordonbruce@mepis1:~/bin$ lein search hadoop
14:15BruceBGordon Warning: couldn't download index for http://repo1.maven.org/maven2
14:15BruceBGordon Warning: couldn't download index for http://clojars.org/repo/
14:15amalloy&(doc clojure.string/join) ; Borkdude
14:15lazybot⇒ "([coll] [separator [x & more]]); Returns a string of all elements in coll, separated by an optional separator. Like Perl's join."
14:16Borkdudeamalloy: tnx,will improve that one
14:16amalloyalso your code is a little hard to follow because you :use whole namespaces, without indicating which functions come from where
14:17Borkdudeamalloy: good point
14:18gfredericksmy fingers hurt. What do I need to purchase?
14:19BruceBGordonsimilarly >lein repl fails because ...
14:19BruceBGordonbruce@mepis1:~/cloj2$ lein repl
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from clojars
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from clojars
14:19BruceBGordonDownloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central
14:19BruceBGordonAn error has occurred while processing the Maven artifact tasks.
14:19BruceBGordon Diagnosis:
14:19BruceBGordonUnable to resolve artifact: Missing:
14:19BruceBGordon----------
14:19BruceBGordon1) org.clojure:clojure:jar:1.2.1
14:19gtrakBruceBGordon, stop
14:19amalloyBruceBGordon: someone is going to murder you for pasting all this. don't make it be me
14:20floatbothBruceBGordon: y u no use gist.github.com
14:20amalloyhttp://gist.github.com is available for pasting
14:20TimMcand just to be thorough
14:20TimMc~paste
14:20clojurebotpaste is http://gist.github.com/
14:21BruceBGordonapologies for not knowing protocol. I just hope this forum isn't too self correcting (I'd like to be alive)!
14:22gtrak,(kill BruceBGordon)
14:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: kill in this context, compiling:(NO_SOURCE_PATH:0)>
14:22gtrakyou're lucky today
14:22BruceBGordonok, already (sigh) cross-posted to google group at http://groups.google.com/group/clojure/browse_thread/thread/f170ec06d19fb038#
14:23BruceBGordon(areYouFeeelingLuckyTodayPunk :BruceBGordon)
14:24gfredericks~camelCase
14:24clojurebotPardon?
14:24Borkdudeamalloy: check again, https://gist.github.com/1287481
14:24amalloy$kill ; gtrak
14:24lazybotKILL IT WITH FIRE!
14:25TimMcand the ever popular
14:25TimMc~guards
14:25clojurebotSEIZE HIM!
14:27amalloylooks pretty good, Borkdude
14:29TimMcamalloy: Some channels have bots that kickban people for 5 seconds if they paste more than X lines of text in under Y ms.
14:30TimMcThat would be a spiffy feature for lazybot.
14:30TimMcIt happens enough...
14:30gfredericksas long as it sends an explanatory message
14:31TimMcTrue. It would be rude not to.
14:31TimMc"You have been sentenced to clojail for 10 seconds for flooding the channel."
14:32gfredericksand 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:32TimMcThis is actually one of the most laid-back channels I've been in.
14:32TimMcgfredericks: Good idea!
14:33gfredericksThis is actually one of the only channels I've been in.
14:33amalloygfredericks: 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:37TimMcbots with ops are the best
14:37TimMcWhat could possibly go wrong?
14:38amalloy~skynet
14:38clojurebotI will become skynet. Mark my words.
14:39TimMcfoonetic.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:40technomancyI would actually appreciate an auto-ban for myself as I've accidentally middle-clicked a couple times
14:40technomancykicking, not so much. but banning, sure.
14:40`fogushttp://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/
14:40TimMctechnomancy: Needs to be a ban, because many clients will auto-rejoin.
14:46stuartsierra`fogus: nice
14:47stuartsierraBut I think you meant to say Paul Stadig was "eminent", not "imminent."
14:48hiredmanpaul is your boss too?
14:48stuartsierraI admit, I enjoyed the mental image enough that I'm hesitant to correct it.
14:49floatbothwhat is the right way to put variables into leiningen dep versions? ~`([package-name ~version-var]) == lein trying to use leiningen/core/package-name
14:49hiredmanfloatboth: don't
14:50floatbothhiredman: really?
14:50technomancyweeeeellll...
14:50TimMchaha
14:50hiredmanfloatboth: yes
14:51technomancyit 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:51TimMctechnomancy: I bet you have all sorts of nasty weird implementation-dependent tricks in your project.clj
14:51technomancybut just ~foo-lib-version should be enough; no need for anything fancy
14:51floatboththat is subprojects
14:51technomancyTimMc: I'm hesitant to even publicize unquoting in defproject actually =)
14:52floatbothjust unquoting doesn't work
14:52technomancyit's an escape hatch for when lein isn't flexible enough; better to make it work without it
14:52technomancyfloatboth: maybe a gist?
14:53floatbothhttp://mfwb.us/ds4J
14:54technomancyfloatboth: need to see project.clj
14:54floatbothhttp://mfwb.us/yQkM
14:55amalloy`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:56hiredmanit would be an interesting survey of clojure projects
14:56ibdknoxhiredman, what would?
14:56technomancyfloatboth: you're using a list instead of a vector for :deps
14:57TimMchiredman: How much uses reflection?
14:57floatbothoh snap, totally forgot about it, thanks
14:57hiredmanibdknox: checking what percentage of calls end up being reflective
14:58TimMchiredman: Statically or at runtime? (That is, weighted by number of calls.)
14:58TimMcOr does HotSpot help with that?
14:58ibdknoxindeed. It probably wouldn't be too hard to scrape a list of clojure projects from github and run them
14:58hiredman:(
14:59hiredmanI was just thinking to maybe do a patched clojure build that exposed some counters then run our tests at work with it
15:00ibdknoxThat would definitely be easier :)
15:01TweySo, 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:01ibdknoxTwey, lein run
15:01hiredmanjava -jar foo.jar
15:01hiredmanworks great
15:01TimMcTwey: For development, lein (or cake) is all you need.
15:01Tweyhiredman: I have to compile it first :þ
15:01hiredmanlein will also generate shell scripts too
15:01TweyTimMc: Yeah, except lein doesn't work with my project.
15:01hiredmanTwey: and?
15:01TimMcFor deployment, package it up.
15:01hiredmanTwey: use lein
15:01Tweyhiredman: lein doesn't work with SWT as far as I can tell.
15:01ibdknoxTwey, huh? what do you mean lein doesn't work with your project?
15:01hiredmanif lein doesn't work with your project you should make it
15:02TimMcOh, is that still not working? :-(
15:02TweyI've been trying for the past several hours
15:02raek(context: he's using swt which has native deps)
15:02TweyRight
15:02hiredmansure, and technomancy is very interested in native deps
15:03technomancyTwey: what kind of native deps? slfe in the jar?
15:03hiredmanhttps://github.com/santamon/GUIFTW/wiki/One-Tutorial-For-All
15:03hiredman^- seems to imply swt does work
15:03TweyI think just a couple of .so's
15:03Tweyhiredman: Perhaps, but not for me.
15:03Twey(I followed exactly that when raek pointed it out earlier)
15:04technomancyTwey: the specific paths inside the jar are important
15:04technomancyis it something you can show publicly?
15:05Tweytechnomancy: I don't even have any code yet, so yes :þ
15:06TweyHang on, there's another .jar on jarvana that I haven't tried — I'll give that a go first
15:09amalloy`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:10stuartsierraC'mon, OBVIOUSLY 2 is better than 37. ;)
15:10ibdknoxIt's golf right?
15:10TweyUgh, no, no good
15:11Tweytechnomancy: 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:12Twey(er, bad example maybe — this is using the new jar, which gives a somewhat different error)
15:12ibdknoxTwey, gists are your friend :)
15:13Tweyibdknox: It was only one line…
15:14Raynesibdknox: The man has a point.
15:14ibdknoxok ok
15:14RaynesTwey: But it was such a long, complex line. IRC can't take it.
15:15ibdknox;)
15:15RaynesTwey: I know you from somewhere. You're a Haskeller, right?
15:15TweyYou know me from many places
15:15TweyI am, amongst other things
15:15RaynesI know you're an awfully smart fellow.
15:15RaynesWelcome to Clojure-land.
15:15TweyWe share a few forums, too
15:15TweyThanks
15:15technomancyTwey: that jar's not in any of the default repos
15:16TweyI'm trying to make myself comfortable, but I get the feeling Clojure doesn't want me here :þ
15:16Tweytechnomancy: I was told to find it on Jarvana
15:16RaynesSWT is really strange. They seem to abolish maven.
15:16technomancyjarvana is a search engine; they don't actually serve jars afaik
15:17BorkdudeTwey: we try to prevent Clojure to become a mainstream language. What fun is it to be a fan of something mainstream...
15:17ibdknoxI've heard we say "no" a lot... ;)
15:17ibdknox~rimshot
15:17clojurebotBadum, *ching*
15:18Rayneshttp://search.maven.org/#search%7Cga%7C1%7Cswt There seems to be some jars on maven.
15:18Tweytechnomancy: 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:18RaynesParticularly, 3.0.1
15:18hiredmanTwey: what is the error you see?
15:19TweyThe former gives an ‘UnsatisfiedLinkException’ saying it can't find swt-gtk; the latter a ‘NoClassDefFoundError: org/eclipse/swt/internal/gtk/OS’
15:19TweySorry, ‘UnsatisfiedLinkError’
15:21technomancythere 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:21technomancy1) 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:22TweyRight
15:22TweyBut apparently the SWT jars don't do either
15:26technomancyaha; apparently the groupid is wrong; it's just swt/swt-linux-gtk
15:26technomancyTwey: what code triggers that link error for you?
15:27Twey(import 'org.eclipse.swt.widgets.Display) (from lein repl)
15:27BorkdudeI 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:29TweyBorkdude: I guess register it with Maven & add it as a dependency like everything else
15:29Borkdudehm.
15:29technomancyBorkdude: ideally you want to get it into a remove maven repo
15:29technomancy*remote
15:29technomancythough if you don't need to share it among your team you could use lein-localrepo
15:30Borkdudetechnomancy: I'm just testing, no need to share
15:30`fogusamalloy: Sorry, missed your messages.
15:30Tweytechnomancy: The groupId on what, exactly?
15:30BorkdudeI will figure out lein-localrepo
15:30technomancyTwey: [org.eclipse/swt-linux-gtk "3.0m8"] does not resolve
15:30amalloyno worries, irc is async. just providing feedback
15:30`fogusamalloy: Do you really see that most calls are inferred as reflective?
15:31Tweytechnomancy: Ah, I see
15:31technomancychanging 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`fogusamalloy: WRT: JRuby units of awesomeness... I have no idea... maybe Charlie can provide some feedback. :-)
15:32amalloy`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:32Tweytechnomancy: *nod* That's what I get from that one, too
15:32stuartsierraArent't they just time measurements?
15:32stuartsierra^ `fogus, amalloy
15:32amalloywhereas a huge % of interop calls i see are things like (.indexOf s) wrapped up in a function
15:33amalloystuartsierra: yes, but i had to follow a link and read a different article to find that out :P
15:33stuartsierraReading is good for you. :)
15:33technomancyTwey: upon dropping it to version 3.0m7 I'm able to repro the link error
15:33`fogusamalloy: I could be viewing that from my own perspective. I tend to localize interop calls.
15:34technomancyTwey: 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`fogusstuartsierra: Timing? I was certain they were units of badassness
15:34stuartsierraThis is Charlie we're talking about.
15:35`fogusSo definitely badassness
15:35`fogus;-)
15:35stuartsierraBut if it's units of badassness, wouldn't more be better?
15:35Tweytechnomancy: 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`fogusstuartsierra: Touche!
15:35technomancyTwey: you can set :java-library-path in project.clj to the proper /usr/lib dir
15:36`fogusHN discussion: http://news.ycombinator.com/item?id=3112501
15:36technomancyTwey: sorry, that's not right
15:36stuartsierra`fogus: Let's call them Standard Units of Suckage. SOUS for short.
15:36Twey
15:36technomancyTwey: it's either :native-path "/usr/lib/..." or :jvm-opts ["-Djava.library.path=/usr/lib/..."]
15:36Tweystuartsierra: I think you got that a little backwards
15:36Tweytechnomancy: Hmm, 'kay, thanks — I'll have a go
15:36stuartsierraeh
15:36stuartsierrawhatever
15:37cgrayis seq O(1)?
15:37stuartsierrayes
15:37opqdonutbut evaluating a seq might require unbounded amounts of other evaluation
15:38stuartsierratrue
15:38opqdonutI'm not really sure what "seq is O(1)" even means
15:38dnolen`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:39opqdonuti might have an inkling about what "seq is just a constant overhead" would mean
15:39cgrayI'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`fogusdnolen: I will. I wanted to get the dev-list perspective about technical details first
15:39opqdonutcgray: you hope correctly
15:39dnolen`fogus: it's a pretty simple idea, and sound :)
15:39`fogusdnolen: Cool! I will paste it to the clj list post-haste
15:39opqdonutcgray: but you might also want to consider next instead of rest
15:40amalloycgray: fwiw, ##(doc next) is the same as (seq (rest ...))
15:40lazybot⇒ "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."
15:40stuartsierracgray: ClojureScript has a private function "bounded-count" for just this purpose.
15:40amalloystuartsierra: nice
15:41stuartsierraAnd than function represents about 75% of my contribution to ClojureScript.
15:41stuartsierra*that
15:42amalloystuartsierra: i've generally just used nthnext
15:42stuartsierrathat works too
15:42opqdonutyou're all misguided. this is clearly a use case for lazy naturals :)
15:42Tweytechnomancy: 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:43stuartsierraopqdonut: "Lazy Naturals" should be the name of a band. Or a book by Malcolm Gladwell.
15:44Tweytechnomancy: Actually, scratch half of that — using the newer SWT, I don't even need :native-path (the .so's are in the jar).
15:44Tweyhttp://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:45Tweys/=$//
15:45lazybot<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:54Borkdudetechnomancy: 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:54Borkdudetechnomancy: this is how the clj inside the jar looks: https://gist.github.com/1287481
15:55Borkdudetechnomancy: if I do (use 'twitter-api-test.followers-minus-friends) I get an error about class missing or clj file not found
15:56RaynesIs that a real namespace?
15:56BorkdudeRaynes: I'm just testing how this works
15:57RaynesJust wondering, because I was considering naming one of my namespaces get-audio-pronunciation-test.does-this-audio-link-from-wordnik-work-properly.
15:58Borkdude:)
16:03gfrederickswhat was that caching library?
16:04brehautunk
16:05gfredericksI do believe that's exactly what I was thinking of.
16:06gfredericksbrehaut: thx
16:08sugrodeauHello 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:10danlarkinsugrodeau: what do you want to accomplish by "loading the whole project"
16:10sugrodeaudanlarkin: So I can use any defined function at the repl.
16:11`fogusgfredericks: Unk is the memoization library built on the caching library Clache
16:11danlarkinsugrodeau: you can (use 'foo.bar) at the repl too
16:11sugrodeaudanlarkin: Ah thanks, I'll try it out!
16:11ipostelnik`fogus, are unk/clache compatible with 1.2?
16:12gfredericks`fogus: been looking at the src, and unk solves my problem exactly
16:14fliebelGood morning, good evening and good night.
16:15Borkdudetechnomancy: got things working now, Raynes: simplifying filenames was a good idea *shame on me*
16:19BorkdudeI have more questions, but I will not make more of a fool of myself tonight I guess ;)
16:20dnolenwould be neat to hook up ClojureScript to this, http://www.plask.org/
16:25`fogusipostelnik: Yes
16:26hiredmanso 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:26brehaut`fogus: footnote #7 is excellent
16:26hiredman,(double (/ (* 1000 100) 2329))
16:26clojurebot42.93688278231
16:27amalloyhiredman: how'd you measure that?
16:27TimMc,1000/2329
16:27clojurebot1000/2329
16:27TimMc,(* 1000/2329 100.)
16:27clojurebot42.93688278231
16:28TimMcDon't mind me, just golfing.
16:28hiredmanI 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:28amalloyTimMc: not a very good golf then: ##,(/ 2329 .1)
16:28lazybotjava.lang.Exception: Unable to resolve symbol: .1 in this context
16:29amalloyTimMc: not a very good golf then: ##,(/ 2329 0.1)
16:29lazybot⇒ 23290.0
16:29TimMchot damn
16:29amalloyhm. incorrect, but you see my point
16:29amalloyhaha
16:29TimMcthat's a lot of reflection
16:29Borkdudetechnomancy: do dependencies in project.clj work transitively?
16:30technomancyBorkdude: absolutely
16:31Borkdudealso for localrepo?
16:31technomancyshould be
16:31Borkdudetechnomancy: I read this thread, I have exactly the same problem http://groups.google.com/group/leiningen/browse_thread/thread/e25c5919e61b3ee1
16:33Borkdudetechnomancy: or I must be doing smth wrong (probably)
16:34technomancyBorkdude: are you seeing the same missing pom in ~/.m2 that the thread references?
16:38Borkdudetechnomancy: wait, it's fixed. I broke the chain somewhere, I'm sorry to have bugged you.
16:38Borkdudetechnomancy: tnx for a great tool btw
16:41Borkdudetechnomancy: it says it downloading my local jar from clojars, I wonder why this is
16:41technomancyBorkdude: if it's a snapshot, then it will check for new versions
16:41fliebelWhat is that array backed hash trie thing for the conj about?
16:41Borkdudetechnomancy: ic
16:44fliebelThere was a link to a paper someone tweeted, I can't find it.
16:49amalloy$google phil bagwell hash array mapped trie paper
16:49lazybot[Ideal Hash Trees] http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.6279&amp;rep=rep1&amp;type=pdf
16:50amalloyfliebel: i think that's the right paper. it's relevant, at least
16:50fliebelamalloy: Thanks :)
16:52fliebelI'll probably just do an unbalanced array mapped binary search tree initially though. (for my future Lego NXT compiler project)
17:12DeusExPikachuin clojurescript, can you pass clojure functions to javascript functions that expect javascript functions?
17:13amalloyDeusExPikachu: yes
18:11jodarowow
18:12jodarodiff is great for unit tests
18:12ibdknoxjodaro, how so?
18:13jodaroi'm working on a client for a restful api
18:13jodaroget back a bunch of json
18:13jodaro(diff what-it-should-look-like (my-api-cal :params))
18:13jodarobam
18:14jodarowell obviously there is a little more to it than that
18:14ibdknoxnice
18:14jodaroyeah
18:14ibdknoxI guess the advantage is that you can see the exact difference easily?
18:15jodarohandy for recursively diffing objects
18:15jodaroright
18:15amalloyjodaro: if you use cake's develop branch, it automatically shows diffs on all failing assertions in tests
18:15jodaro[things-only-in-a things-only-in-b things-in-both].
18:15jodaro
18:15jodarois what (diff a b) returns
18:16ibdknoxah
18:16ibdknoxsweet
18:16ibdknoxI haven't messed with it yet
18:16jodaroyeah
18:16jodaroi just found it
18:16jodaroi guess given that its 1.3 thats why
18:17ibdknoxamalloy, that's pretty sweet.
18:19amalloyibdknox: https://gist.github.com/1627b97401686c72136b - but in sweet, sweet ansi color
18:20jodarooh wow
18:20ibdknoxugh
18:20jodarothats badass
18:20ibdknoxI have way too much shit to do
18:20jodaroeven in black and white
18:21ibdknoxamalloy, I've also decided we don't use ansi-color enough in all our tools :p
18:22amalloyyeah, lancepantz has really improved cake-test over the past several weeks
18:22technomancyibdknox: lein-difftest does that
18:22ibdknoxtechnomancy, ooo
18:22jodarohah
18:22hiredmanwell, it doesn't use clojure.data.diff or whatever
18:23technomancytrue
18:23ibdknoxhah who wants it then :p
18:23technomancyibdknox: 1.2 users? =)
18:23ibdknoxtechnomancy, there's only like 10 of those, right? ;)
18:24jodarolooking at lein-difftest
18:24amalloyibdknox: yeah, the really-easy migration path has gotten everyone onto 1.3 in a matter of seconds :P
18:24jodarostill
18:24ibdknoxhaha
18:24jodaroi have to use diff directly
18:25jodarobecause they aren't *exactly* the same
18:25jodarothe return from the api has more stuff in it
18:25amalloyjodaro: select-keys?
18:25jodarooh that would work too
18:26jodaroi'm actually just using nth
18:26jodaroand pulling the third value from the diff return
18:26jodarobasically i want to know that the stuff i know about looks the same from both ends
18:27TweySo what was the reasoning behind ‘recur’ rather than doing normal TCO?
18:27jodaroi should probably clean it up with ->
18:27hiredmanjvm doesn't do tco
18:27amalloyTwey: a lot of reasons, really
18:27hiredmanwell, people have come with lots of rationalizations
18:28hiredmanbut the real reason is "jvm doesn't do tco"
18:28amalloyheh
18:28amalloyyes. if the jvm did allow full tco, we would probably not have recur (except for the loop form? would we keep that?)
18:28hiredmanyou can emulate it on the jvm if you give up speed, or you can kludge it for a limited number of cases
18:29hiredmanamalloy: they would be macros that expanded into letfns
18:30amalloyhiredman: letfn isn't necessary, right? ((fn recur [x] (... (recur))) init-x)
18:30Tweyhiredman: Ah
18:30hiredmansure
18:30hiredmanbut I like letfn
18:31amalloyi have a love/hate thing with letfn
18:31TweySo there's no non-stack-using loop in the JVM to which one could compile TCs?
18:31amalloyTwey: sure, there is. but not across method-call boundaries
18:31TweyAh, okay
18:31hiredmanloop/recur infact turn into such a thing
18:32amalloyand clojure lets you do it within a single method using recur
18:33amalloy&(loop [sum 0, n 1e6] (if (zero? n) sum (recur (+ n sum) (dec n))))
18:33lazybot⇒ 5.000005E11
18:41amalloyi 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:44smerrittamalloy: that wouldn't work for (if-not test then) with no else clause
18:45amalloysmerritt: (if test nil then)
18:45hiredmanof course it would
18:46smerrittah, right
18:48smerrittI was thinking of ~@else, which (of course) is not what's actually written there :0
18:49amalloymy client persists in highlighting crap like ~@else as if it were an email. always worth a chuckle
18:59ghiucan 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:00amalloyghiu: you can shadow global names locally if you want
19:00amalloy&(let [first 1] first)
19:00lazybot⇒ 1
19:00amalloy$google clojure destructuring
19:00lazybot[Jay Fields' Thoughts: Clojure: Destructuring] http://blog.jayfields.com/2010/07/clojure-destructuring.html
19:00amalloy&(let [[first & rest] (range 5)] {:first first, :rest rest})
19:00lazybot⇒ {:first 0, :rest (1 2 3 4)}
19:06ghiuoh, i see :)
19:06ghiuthank you
19:09zakwilsonI'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:10technomancyzakwilson: yep. j.u.Date is nearly always the wrong thing
19:11technomancyit should probably even issue a warning when you use it; it's that bad.
19:11zakwilsonI'm glad to see somebody better known in the community is with me on this.
19:11technomancy(System/currentTimeInMillis) can replace some of the more trivial j.u.Date usages
19:12amalloyzakwilson: always wrong in clojure, or always wrong on the jvm? like, are you saying java coders shouldn't use it either?
19:12amalloyer, technomancy: ^
19:12hiredmanthey should use joda time
19:13technomancyamalloy: probably the latter
19:13zakwilsonI'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:14zakwilsonI 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:55duck1123I've found that using Karras with MongoDB, it's easier to keep everything in j.u.Date than anything else
20:08seancorfieldi 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:09seancorfieldi'm also using date-clj which has a nice API
20:09seancorfieldbut 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:11seancorfieldhmm, clj-time still relies on clojure.contrib.def
20:12seancorfieldlooks like it's just for defvar so it could easily eliminate that...
20:53technomancythe main problem with clj-time is its absent maintainership
20:53amalloytechnomancy: you're not busy, right? ...
20:54amalloy(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:57carllercheHow can I pass a compiler arg to javac w/ leiningen? (say -Xlint)
21:00happy4crazyHi 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:00happy4crazyBasically, I'm getting a pretty baffling NullPointerException
21:00happy4crazyI'm translating some early SICP code to Clojure
21:01happy4crazyspecifically the iterative sqrt procedure from section 1.1.7
21:01happy4crazyeverything works correctly in Clojure 1.2.1, but not in 1.3.0
21:07amalloyhappy4crazy: works for me on 1.3 ubuntu 11.04: https://gist.github.com/deecb8fa399965ee5da7
21:08gfredericksamalloy: did you try a float?
21:08happy4crazyhuh
21:08gfredericksnm
21:08amalloygfredericks: yes. i was trying (sqrt (square foo)) but when that worked i tried non-perfect-squares
21:08gfredericksclearly that's a dumb suggestion
21:08gfredericksno it wasn't
21:08gfredericksI misread twice
21:09gfredericksI'm going to stop talking now
21:09dnolenworks for me to, 1.3 on OS X Lion, OpenJDK 7
21:09amalloyhappy4crazy: and the code looks unimpeachable - i can't imagine how an NPE could sneak in
21:09amalloyso it sounds like a problem with your tooling
21:09happy4crazyyeah, this is one of the more surprising bugs i've seen
21:10happy4crazyfwiw, i'm on os x
21:10happy4crazywith java 1.6.0_26
21:10happy4crazyand again, 1.2.1 works perfectly; it's only 1.3.0 so far that causes the bug
21:10amalloyhappy4crazy: i suspect your tools. how are you getting your repl?
21:11happy4crazytypically lein repl
21:11happy4crazyi've tried lein deping 1.2.1 (works) and 1.3.0 (doesn't)
21:12amalloyand lein version prints...?
21:12happy4crazyLeiningen 1.6.1.1 on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM
21:12amalloyhm. i'm on 1.6.1, so that shouldn't be the problem
21:13amalloytechnomancy: you didn't add a :fail-on-large-numbers option to 1.6.1.1, right? :)
21:13happy4crazyhaha
21:15happy4crazyyeah, null pointer exception if I launch clj directly, not via lein repl
21:15dnolenhappy4crazy: did you remove all the your deps and pull them down again?
21:15amalloyhappy4crazy: "launch clj directly"?
21:16dnolenrm -r lib; lein deps
21:16happy4crazyamalloy: i've got 1.3.0 installed via homebrew
21:16happy4crazydnolen: I'll try that
21:16happy4crazyamalloy: and additionally via a project.clj
21:16amalloyi see. you're just pointing out that it fails with or without lein
21:16happy4crazyyes
21:16amalloy*nod* i just didn't quite get it. weird
21:17happy4crazydnolen: yep, same error :/
21:19happy4crazyand yeah, if i remove lib and lein dep clojure 1.2.1, everything works
21:19happy4crazyso strange!
21:20amalloycheck for microscopic cpu-goblins
21:20amalloyhappy4crazy: actually, have you tried on a different computer?
21:20happy4crazyamalloy: hmm, no i haven't
21:21happy4crazymy guess is it will work correctly, as no one has been able to reproduce it yet :)
21:21dnolenhappy4crazy: what OS, what JDK?
21:21dnolenoh you said JDK above, what OS?
21:21dnolenah you said homebrew
21:21happy4crazyyeah
21:21dnolenk, your problem makes no sense to me
21:21happy4crazy10.6.8
21:21happy4crazyha me neither
21:22happy4crazythank you everyone for humoring me though
21:26alandiperthappy4crazy: what other libs are in your project.clj?
21:27alandipertoh, never mind, i see that it's a problem with the homebrew provided clj
21:30happy4crazyalandipert: it's also a problem with whatever lein is installing, correct?
21:30happy4crazyI've tried this with both the homebrew clj and a fresh project.clj file
21:32happy4crazythank you everyone, have to run
21:35jcrossley3amalloy: hey, so um... continuing our discussion from last night, i have this: https://gist.github.com/1288852
21:36amalloy#(( is wrong
21:36jcrossley3but note that InvalidDestinationException is a subclass of JMSException
21:37jcrossley3unfortunately, the InvalidDestinationException will only be caught if i explicitly add a clause for it
21:37jcrossley3is that expected behavior?
21:37amalloynot afaik
21:38jcrossley3could it be a bug?
21:38amalloyi doubt it. it works fine in most cases, so i'd need fairly compelling evidence that anything's actually going wrong here
21:39jcrossley3amalloy: why is #(( wrong?
21:39amalloyeg, (try (/ 1 0) (catch Exception e 10)) works fine, even though there's no explicit clause for ArithmeticException
21:40amalloy&(#((Thread/sleep 1000) 10))
21:40lazybotjava.lang.NullPointerException
21:40amalloy&(#(do (Thread/sleep 1000) 10))
21:40lazybot⇒ 10
21:40jcrossley3amalloy: ah! (but it works, why?)
21:41amalloybet you a dollar? if it works, it's because you never actually call retry
21:42jcrossley3it's just shorthand for (fn [] body) right? i don't need (do body)
21:42amalloyno, it is shorthand for (fn [] (body))
21:43seancorfieldtechnomancy: really? mark committed stuff on september 26th
21:43jcrossley3amalloy: i c. i'm starting to wonder whether that's not the cause of my original problem now. :)
21:44seancorfieldclj-time 0.3.1 was late september only two weeks ago
22:05ghiuis there a version of partial that uses the implicit argument as first and not as last argument?
22:08amalloy&'#((Thread/sleep 1000) true) ;; jcrossley3
22:08lazybot⇒ (fn* [] ((Thread/sleep 1000) true))
22:09jcrossley3amalloy: yes, thanks. i think that fixed my parent exception "bug" too.
22:09amalloycool
22:46amalloyTimMc: 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:06scottjdnolen: 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:41amalloyfwiw, 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:41ibdknoxhaha
23:42amalloythinking critically about it that was a poorly-formed idea because (.member foo) just macroexpands to (. foo member), but it's an interesting idea
23:42ibdknoxI feel bad that I didn't have time to write a more detailed explanation for why I was against that change :/
23:42ibdknoxtoday has been.. busy
23:43ibdknoxdnolen took care of it for me :)
23:45TimMcOh hey, github changed their theme.
23:45amalloynice. 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:47TimMcamalloy: rails_xss looks neat
23:48nappingrails_xss? That does not sound like a good thing
23:50ibdknoxI really don't like the new github theme
23:50ibdknoxit's a design fail :p
23:51amalloy(inc ibdknox)
23:51lazybot⟹ 3
23:51amalloyalmost all of their changes are (big) improvements, but this change is a mess
23:52ibdknoxyeah, I really don't understand this one
23:56ThreeCupsI'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:56ThreeCupsuser=> (use 'my.ns :reload)
23:56ThreeCupsto 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:57ibdknoxThreeCups: 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:57ibdknoxyou could put yourself in that namespace if you wanted
23:57ibdknox,(doc in-ns)
23:57clojurebot"([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
23:58ibdknoxhm
23:58carllerchenapping: what's wrong w/ rails_xss?
23:58ibdknoxthat's not very informative
23:59ThreeCupsibdknox: 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:59ibdknoxThreeCups: yep. Really namespace is the right word, but most of the time that maps to a file, so.... *shrug*