#clojure logs

2009-03-25

00:01slashus21Anyone thought of adding some examples to clojure's wikipedia page?
00:05durka42clojurebot: examples?
00:05clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
00:06durka42those may be kind of old
00:06slashus21I made a syntax highlighting lang file for gedit.
00:07slashus21It works pretty well. Still working on it.
00:07durka42nice
01:44Gilbert987does anyone know if there's a clojure interface for couchdb?
02:50blbrownGilbert987, isn't couchdb a rest interface. probably wouldn't be too hard to cook one up using Java's URL libs
02:51hiredmanthere are java couchdb libs too
02:54blbrownhiredman, I have java code and I am invoking the clojure interpreter (legacy_script) is there a way to pass a Java object to that instance of the clojure script) Kind of as a global
02:55hiredmanyour java code is calling the clojure runtime?
02:56blbrownyea, just a copy of the clojure.main.java code
02:57blbrownnevermind, I got it
03:04blbrownOK, nevermind, dont have it. I thought I could do something with Var.invoke
03:06Rayneshiredman: You're still my hero.
03:06hiredmanyou want Var.intern I think
03:06hiredmansomething like
03:06hiredman Var.intern(Namespace.findOrCreate(Symbol.create("clojure")), Symbol.create("*console*"), console);
03:07blbrownnice
03:34Raynesc.c.duck-streams is the best thing evar.
03:41RaynesAll your clojure contrib are belong to us.
03:55Raynes"Web browser in VB.NET" Failure failure, beep beep blue screen of death.
04:40AWizzArd~seen cemerick
04:40clojurebotcemerick was last seen quiting IRC, 644 minutes ago
04:51antifuchshmm, opening pages on the clojure wiki is a bit tedious with its cache control headers. who runs the server? (:
04:52antifuchs(opening /api takes 1.35 seconds. every time I load it. agh /-:)
04:54AWizzArdI think its hosted on a commercial wiki provider.
04:54antifuchsah, wikispaces
04:55AWizzArdyup, that was the one
04:55antifuchsI'll ask them if they know their page load times are annoying (:
04:55AWizzArd*g*
05:05antifuchsright. hopefully they'll respond; this is getting slightly annoying /-:
05:21hjleeare there easy way to change radix? specifically decimal to binary.
05:38AWizzArd,16rff
05:38clojurebot255
05:39AWizzArd,16r2
05:39clojurebot2
05:39AWizzArd,2r1611001
05:39clojurebotFor input string: "1611001"
05:39AWizzArdnah
05:40AWizzArd,2r101011
05:40clojurebot43
05:40AWizzArdhjlee: does that help?
05:40hjleei want to get 101011 from 43 ...
05:40antifuchshjlee: also, I see that cl-format has print radix control
05:41AWizzArd,(Integer/toBinaryString 43)
05:41clojurebot"101011"
05:41hjleethat's it, thank you!
06:22antifuchsok, so hm. is there a way to create a .class file (via compile of a .clj file containing a gen-class form) from swank-clojure without tearing my hair out over classpath issues?
06:29HolcxjoI get the impression that the classpath problems are one of the biggest hurdles for clojure -- why oh why can't that be adjusted at runtime?
06:31antifuchssuppose that would require a custom classloader thing and then other things would break
06:32antifuchsunder the circumstances, it may be the best thing for now. it's just a pretty grating experience (:
06:34antifuchsok, so how /do/ I add a directory (not a jar) to the classpath with swank-clojure?
06:34hoeckantifuchs: just set your classpath with [m-x] customize-variable [ret] swank-clojure-extra-classpaths
06:35hoeckand restart emacs and slime
06:35antifuchshoeck: but that will disable autoloading of the stuff in ~/.clojure - right?
06:35antifuchsor let's say auto-classpathing
06:36hoeckI don't know, who calls ~/clojure, swank-clojure or clojure.lang.main?
06:36antifuchsthat's swank-clojure, IIANM
06:38antifuchsok. I may have made an error setting the current classpath. is there a way to inspect the classpath that's currently set?
06:43hoeckthere is (System/getProperty "java.class.path")
06:44antifuchsoh, thats cool
06:44antifuchsseems like the extra paths I'm pushing to swank-clojure-extra-classpaths isn't getting passed through to java.
06:45antifuchsso... is anybody using swank-clojure?
06:45antifuchsfrom the things I'm encountering, it looks like it's not really actively improved. /-:
06:46hoeckyou need to restart emacs, swank-clojure-extra-classpaths is only evaluated when emacs loads the swank-clojure.el file
06:47antifuchsyes
06:48antifuchsI'm familiar with emacs. been using it for lisp development for 10 years (:
06:48antifuchsI also need to restart emacs after ,quit in the clojure swank repl. this is what was giving me that above impression (:
06:49antifuchs(need to restart because the next time I run clojure with slime, connecting to the swank port will hang)
06:52hoeckand you're right about the jars in ~/.clojure, they are ignored if you customize the extra classpath
06:53antifuchswhat did was remove the 'clojure implementation from the swank impl alist, and add another one which works to my specifications
06:53antifuchsthis isn't hyper-ideal, but for now it'll work well enough (:
06:55hoeckI have written a function for to do that for me, restarting emacs after changing the classpath for clojure is a bit odd
06:56antifuchsyeah. it's a bit annoying having to restart emacs after quitting clojure, too, let me tell you (:
06:57hoeckare the classpaths showing up in the string produced from the swank-clojure-cmd function?
06:58antifuchsnow they are.
06:58antifuchsI'm thinking this may be easier if I just define one command to start clojure for each project
07:03hoeckI have always one clojure instance running, the classpath and clojure-package system works very well in separating all the projects
07:08antifuchsyeah, I was (naively) hoping I could avoid the whole initial setup cost.
07:08mib_5zec882qAnyone know if the ants demo still works with the latest version of clojure?
07:08mib_5zec882qhttp://clojure.googlegroups.com/web/ants.clj?gda=AH2v2joAAAC2LrkjeC7f10uHiY7GOiyx4PWDLdmXu1edmOpq5JPfP-9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0
07:08mib_5zec882qI just get a swing window with a blue square on it
07:08mib_5zec882qbut no ants
07:09AWizzArddid you look at the comments at the bottom?
07:09AWizzArd(def ants (setup))
07:09mib_5zec882qno, I started at the top and didn't get to the bottom yet :)
07:09AWizzArdthere you find commented out some calls that create the ants and start the simulation
07:09mib_5zec882qthanks, that should help
07:12AWizzArdAlthough that file could really need a little update. For example we find (. Thread (sleep evap-sleep-ms))
07:12mib_5zec882qCool, I have ants now!
07:12mib_5zec882qThanks
07:12AWizzArdBut today we would say: (Thread/sleep evap-sleep-ms)
07:13AWizzArdBtw antifuchs, nice to have you here :)
07:14mib_5zec882qAlso, a comment at the top saying "see the bottom of the file for how to run it" would have helped
07:14antifuchsAWizzArd: and you (:
07:14antifuchsI'm glad I finally have the time to work with clojure a bit (:
07:31antifuchshm, how can I get the full path of a file whose (compile ) failed?
07:33AWizzArdWhat error message do you get when you try to compile?
07:36AWizzArdIt should tell you at least the filename + linenumber
07:46AWizzArdclojurebot: max people
07:46clojurebotmax people is 164
07:48antifuchsjust the basename. I was hoping for a full path
07:52leafwantifuchs: grep is your friend then
07:56antifuchsleafw: like pathnames are never ambiguous
07:58AWizzArdbut should there not be just one .clj file of that name in your classpath?
07:59antifuchsnot sure
08:05hoeckAWizzArd: not necessarily, there could be hoeck/lib.clj and awizzard/lib.clj in the classpath, and the compiler just says error in "lib.clj"
08:17AWizzArdhoeck: but they will sit in different namespaces? (ns de.clojure.hoeck.lib ...) vs (ns de.clojure.awizzard.lib ...)
08:18AWizzArdand when /home/clj/src/ is in the classpath, and when I know what I am compiling, I could dive into those dirs: emacs /home/clj/scr/de/clojure/hoeck/lib.clj
08:21antifuchsI think my problem was related to now knowing what I was compiling (:
08:21antifuchsanyway... that works now, thank goodness
08:21antifuchsnow I'm getting odd ClassFormatErrors when I try to load the class files that compile emits
08:21antifuchsjava.lang.ClassFormatError: Repetitive method name/signature in class file org/reprap/artofillusion/SwankTool (NO_SOURCE_FILE:0)
08:23antifuchswhat is up with that? (-:
08:24HolcxjoVery Ruby-esque: Don't repeat yourself!
08:25antifuchsI wasn't meaning to (:
08:26antifuchshuh, seems like the :methods clause in ns does that. will debug further
08:26HolcxjoThe error messages often have a hint of a Zen-like riddle.
08:26HolcxjoHow new-age is that?
08:31antifuchsit goes away once I remove the method declaration clause in ns. no idea if it's really needed. hm (:
08:34hoeckantifuchs: are you generating a class with additional methods?
08:53antifuchsyes, I am
08:56antifuchsoh wow, and look here. I have created my first .jar plugin to Art of Illusion that includes clojure (:
08:57antifuchsdidn't have to write any java code at all; that wasn't too hard, let's see if I can get a Swank repl now (:
09:12antifuchsthanks - most of what kept me were misunderstandings that you all helped clear up (:
09:28AWizzArdantifuchs: grats to your .jar
10:08cconstantineDoes anyone know a good resource for a high school kid who wants to get into programming (not clojure programming, programming in general)
10:11leafwcconstantine: a shell, gcc, an good text editor, and python/java/sbcl ... and their webpages with docs, that can give you most of what you need to tinker. Having a task in mind to accomplish will help a lot too.
10:11gnuvincecconstantine: http://greenteapress.com/thinkpython/thinkCSpy/html/
10:12cconstantineleafw: I'm pretty sure this kid only has a windows machine so things like a decent shell and/or gcc could be hard to get working and just a frustration before they hit any kind of 'real' programming
10:12Holcxjocconstantine: Squeak is meant for that sort of audience as well I believe
10:13cconstantinegnuvince: that looks like it might be useful
10:14cconstantineHolcxjo: thanks, looking into it
10:14antifuchscconstantine: squeak is a really cool environment to get impressive results quickly
10:14cconstantineantifuchs: that'll be important :)
10:14antifuchsimmensely. you get a really nice multimedia environment, and modifying it is really quite easy
10:17HolcxjoDanger is of course, that Smalltalk is much like Lisp in that it spoils you for life -- going back to other languages will be difficult
10:18cconstantinelol
10:18cconstantinehook 'em while they're young!
10:19HolcxjoYou laugh -- but then they'll be made to program in Java or similar. Their peers will think it's cool to churn out mega bytes of interfaces, declarations etc but they are doomed to a life of misery.
10:20gnuvinceHolcxjo: don't you know that IDE-oriented programming is the best new programming paradigm?
10:20gnuvinceWhy have a better language when you can click on a button and Eclipse spits out the 20 lines of code you need, every time you need them?
10:21antifuchss/misery/productivity/ (-:
10:24AWizzArdWell, as they have no macros they need the ide to insert/maintain the code.
10:24AWizzArdPeople want Lisp, they just don't know it.
10:24gnuvinceAWizzArd: they don't even have closures
10:25cconstantineand to think there was a time that I thought having code blocks that looked almost identical was a good thing
10:26gnuvincethat looked almost identical?
10:27cconstantinefunction after function, or class after class that were identical except for a single minor detail (like a different type)
10:27Chouser_sure, it indicates you've found a key pattern in your design
10:27gnuvincecconstantine: oh
10:27Chouser_...and failed to abstract it. ;-)
10:27cconstantineright
10:28AWizzArdAlthough, I think Java had closures right from the beginning.
10:29gnuvinceJava doesn't have closures
10:29hoeckbut java has objects
10:29AWizzArdvia anonymous inner classes
10:29AWizzArdthey are just an ugly syntax for closures
10:31digashAnonymous classes are not clojures.
10:31cconstantinewould you call that a language feature though? I believe you can do that in C++ too
10:31AWizzArdhttp://kawagner.blogspot.com/2006/08/closures-for-java.html
10:32Chouser_wow, Java's had those much longer than I thought
10:32AWizzArddigash: In Java closures are called anonymous inner classes.
10:33digashAs I said anonymous inner classes are not closures.
10:33cconstantineYou can use closures in any language, even ASM... (a turing complete language is a turing complete language and all) but I wouldn't say ASM has closures
10:33digashThey do no enclose environment.
10:33gnuvincehttp://video.google.com/videoplay?docid=4051253555018153503&hl=en
10:33AWizzArddigash: wrong, they do
10:33gnuvinceThat guy explains why anonymous inner classes fail at being closures.
10:34AWizzArdThe guy in the blog explains why they are closures :)
10:34gnuvinceAWizzArd: who's that guy?
10:34AWizzArdgnuvince: http://kawagner.blogspot.com/2006/08/closures-for-java.html
10:35gnuvinceI linked you Neal Gafter
10:35AWizzArdand funny, Neal Gafter, who made your video, commented in the blog :)
10:35gnuvincehttp://gafter.blogspot.com/2006/08/closures-for-java.html
10:35SethTisuefwiw, inner classes weren't in Java "in the beginning" (Java 1.0)
10:36SethTisuethey were added in Java 1.1. just a minor point
10:36cconstantinethat's still pretty early
10:37digashAWizzArd: http://en.wikipedia.org/wiki/Closure_(computer_science)
10:42digashAWizzArd: by that definition Java anonymous classes are not closure, but of cause you can call object closure and Java is a dialect of List because it has GC.
10:42AWizzArdGafter seems to have no arguments for what his Closures can do and which is not possible yet with anon inner classes. He has good arguments why it is more practical.
10:43AWizzArdBut if we log at his blog entry, then we see Karsten Wagner responding there, explaining why Java already has full closures and why Gafters proposal is a bad idea.
10:43selloutI'm pretty sure Java doesn't have closures, since they recently decided not to add closures in Java 7.
10:44AWizzArdsellout: you can use anonymous inner classes to close over some environment.
10:45digashthe main point is that closures are functions and not objects.
10:45AWizzArdOr even better: use Clojure :)
10:45AWizzArddigash: yes, ugly to use
10:45AWizzArdif the language had explicit support for closures it would make it much more usable.
10:46Chouser_but in clojure, functions *are* objects
10:46AWizzArdanyway, as we see, some people are still against explicit support, because that will also come with disadvantages.
10:46AWizzArdhttp://gafter.blogspot.com/2006/08/closures-for-java.html?showComment=1156164900000#c115616492091390744
10:47digashChouser_: that is an implementation detail.
10:47AWizzArdChouser_: hidden from the Clojure user
10:48AWizzArdhere another nice example: http://kawagner.blogspot.com/2006/08/some-more-remarks-on-closures-in-java_22.html
10:48digashI will ask Guy Steel once the talk is over if he thinks that anonymous classes in Java are closures.
10:49leafwdigash: don't waste his time, it's semantics.
10:49jsankeyat the end of the day, it doesn't matter whether they are closures or not, really
10:49jsankeythey still suck for various reasons :)
10:50Chouser_right, java anon classes do what they do, Clojure fns do what they do. Doesn't matter too much what they're called.
10:50AWizzArdI really suggest to write the application in Clojure instead of Java.
10:51jsankeyarguing against the closures for java proposals on the basis that anonymous inners are closures misses the point
10:52AWizzArdjsankey: he mentioned other arguments
10:52Chouser_a better argument might be: if you want to write that kind of code why not use Clojure?
10:52jsankeyAwizzard: sure, there are valid arguments against them to weigh
10:53jsankeybut saying java already has closures is meaningless
10:53Chouser_jsankey: how about: java already has anonymous inner classes that can be used in a lot of cases where you might otherwise use a closure?
10:54jsankeybecause the fact is that using anonymous inners to implement higher-order functions and custom control structures ranges between painful and impossible
10:54Chouser_hm.
10:54digashif you have closures you do not need Visitor pattern and some other ones.
10:55jsankeyhigher order functions are painful because functions aren't first class
10:55AWizzArdjsankey: I can agree on that humans don't like to do it this way, as there is too much syntax. But they still can technically be used for what one wants to do with closures.
10:55Chouser_Java doesn't have functions, does it?
10:55jsankeyso you need to define interfaces describing your function types
10:56jsankey(not to mention that almost none of these have a standard defintion, so lots of peopledefine their own)
10:56Chouser_it has methods instead
10:56AWizzArddigash: But the visitor pattern is mostly about method dispatch. What does this have to do with closures?
10:56jsankeyAWizzArd: technically is right. but i care more about practically :)
10:57jsankeyChouser_: yes, there are no free functions, everything is a method on some type
10:57AWizzArdI think nearly 100% of all people care about this. That is probably the reason why anon inner clases are very rarely used in place of closures.
10:57AWizzArdSo yeah, forget Java, write it in Clojure :)
10:57jsankey:)
10:58brianh2it is possible (if incredibly painful) to do functional programming in raw java code
10:58jsankeyi guess i would say i understand the desire to add more support for closures to Java, as is would allow higher-level abstractions
10:58AWizzArdbrianh2: yes, although this is now coming closer to the turing argument :)
10:58cconstantinebrianh2: first step; write a clojure compiler in java.
10:58jsankeybut in reality, yeah, just use clojure!
10:59Chouser_second step: write a clojure compiler in clojure
10:59brianh2cconstantine: even without a compile step ;)
11:00cconstantinehehe
11:02brianh2the main problem is the poor sucker who has to come behind me and re-write all my code 'cuz they don't have a clue about what the code is really doing.
11:03AWizzArdapropos closures: very often, it seems, people think that anon functions are closures. Things like #(...) or (fn [x y] ...). In general this is not the case.
11:04Chouser_more semantics? when it closes over one binding it becomes a closure?
11:04AWizzArdWell, at least I personally I would find this to be a better definition.
11:04AWizzArdBecause otherwise really every function is a closure, even if it just captures the empty environment.
11:05Chouser_but that's how it actually is, at least in clojure -- every FnExpr has a 'closes' map, which is frequently empty.
11:06AWizzArdYeah, in that case I would call it a function.
11:06AWizzArdClosures are a subset of functions, and not the set of functions.
11:06AWizzArdA true subset I mean
12:52Cark~def str
12:54Carkare ou there hirdeman ?
12:56Cark~seen hiredman
12:56clojurebothiredman was last seen in #clojure, 589 minutes ago saying: Var.intern(Namespace.findOrCreate(Symbol.create("clojure")), Symbol.create("*console*"), console);
13:19st3fanola .. is there a downloadable copy of the documentation available?
13:19st3fani'm traveling and i would like to read things while not online
13:19leafwst3fan: there's a pdf somewhere in the website
13:19leafwotherwise, wget spider is your friend :)
13:19st3fanhmyeah
13:24st3fanwhat is the official clojure-contrib project? there is one on github, sf and google code
13:26Carkgoogle code
13:28st3fangot it
13:34dheahas anyone had any luck getting clojure + processing working?
13:36hoeckdhea: yes
13:37hoeckdhea: http://github.com/rosado/clj-processing/tree/master
13:37dheausing it, im having a problem getting the core.jar and processing.jar loaded
13:37dheaadded it to classpath, cant find it though
13:40hoeckis it in (System/getProperty "java.class.path")
13:42hoeckare you using clojure with emacs-slime or another ide or just from the shell?
13:42dheaemacs-slime
13:42dheaits not in the java.class.path, but ive added the jars with add-classpath
13:49st3fanis clojure-mode good to start? i'm a little afraid of slime and for now i just want to type and eval things
13:49Carkthat's what i'm using
13:50Chouser_st3fan: that's what rhickey uses.
13:52dheaI get the error: java.lang.RuntimeException: You need to use "Import Library" to add processing.core.PGraphicsJava2D to your sketch. (NO_SOURCE_FILE:0)
13:54hoeckdhea: are you trying the example from clj-processing?
13:54dheai've add a (:import (processing.core PGraphicsJava2D))
13:54dheayes, simple.clj
13:55dheathe swing frame is up and running, its only when the (.init p5-applet) line is called
13:55hoeckmhh, maybe better adding the jars to the clojure-swank-extra-classpaths or into ~/.clojure/
13:56dheajars in ~/.clojure are auto added to classpath?
13:57hoeckyes, by default, swank-clojure builts a list of all jars from ~/.clojure/
13:58hoeckor you do [m-x] customize-variable [ret] swank-clojure-extra-classpaths
13:59hoeckbut you must to restart emacs after resetting the classpath
13:59dheayup, that did it
14:00dheaexcellent
14:00dheathank you sven hoeck
14:02lisppaste8hoeck pasted "swank-clojure-cmd-update-classpath" at http://paste.lisp.org/display/77591
14:02hoecknp, or use ^^^ that function instead of restarting emacs
14:03hoeckbtw, for processing, the P3D renderer is much faster (for me) than the default P2D
14:13antifuchshaha, the wikispaces.com guys deny that clojure.com is hosted by them... should I be worried? (-:
14:13Chouser_clojure.org?
14:14antifuchserm, yeah
14:14antifuchsmistypo'd (:
14:14Chouser_well, I guess it redirects
14:16cadsmay I load a jar into the classpath from inside the repl?
14:16antifuchsit's probably just a little misunderstanding, but I'm amused that their helpdesk guy would point me to a page that has their email prominently displayed (-:
14:17hiredmancads: there is add-classpath but it is not reliable
14:18antifuchsis there a rule for when add-classpath will work or not?
14:22cadsthanks hiredman, I'll try it out
14:24cemerickantifuchs: short of having control over your classloader (moreso than you get from java's boot classloader), I think it's generally best to assume that add-classpath will never work.
14:24antifuchsgood to know. thanks
14:24cemerickif you have stuff in a jar, there's no reason to not simply include it in your classpath.
14:24antifuchsright
14:25hiredmancconstantine has the highest non bot url count
14:25cemerickif you want to be able to hot-deploy clojure code that depends on a new jar, then set up your deployment environment so that the classpath points at a directory, and unzip your jar(s) into that directory before attempting to load them from your (completely dynamically loadable) clojure.
14:26cemerickthat's likely something that could be made very clean with a library, but I don't think anyone's bothered with such a mechanism yet.
14:27cconstantinehiredman: hu?
14:29hiredmancconstantine: for the channel, the only nick that has pasted more urls then you is lisppaste8
14:29hiredman(this is only in the last week or so)
14:30cconstantineah
15:25lisppaste8slashus2 pasted "with-out-file" at http://paste.lisp.org/display/77597
15:28slashus2Accidentally hit enter when trying to format it :-(
15:28slashus2Would it be good practice to make the boolean-append to be optional?
15:31Chouser_maybe an optional :append flag? maybe put it before the filename?
15:39Chouser_pop quiz: what does the following return? (no fair trying it out): (binding [* '+] (* '{1 / - * + 6}))
15:39gnuvinceprobably an error?
15:39gnuvinceYou can't call a symbol
15:40kotarakI would think so, too.
15:40hiredmanfools
15:40hiredman+
15:40RaynesI'll go with Error.
15:40gnuvinceoh
15:40cemerickhrm
15:40hiredmanyou can call a symbol
15:40kotarakSymbols are functions of maps?
15:40gnuvince,(ifn? 'foo)
15:40clojurebottrue
15:40hiredmanjust like a keyword
15:40RaynesIt returns 6.
15:40gnuvince6 then?
15:40Raynes>_>
15:41hiredmanfine
15:41Chouser_6 it is.
15:41Chouser_now wasn't that fun?
15:41cemerickChouser_: that could be a regular blog series for you :-P
15:41gnuvincePop quiz: what does this do: zip.ap fmap.(id &&& wtf)
15:42Raynesgnuvince: Eats my kittehs.
15:45kotarakThe depths of undocumented features...
15:47gnuvinceWhat's undocumented?
15:47RaynesWhy are virtually all twitter clients built on AIR?
15:48Raynes:|
15:48RaynesI don't like AIR.
15:48RaynesIt's too AIRy.
15:48slashus2plus is assigned 6, but since the symbol plus is bound to * retrieving * is actually retrieving '+ from the map.
15:48kotarakgnuvince: I think that Symbols are callable. I only knew for keywords.
15:48kotarakgnuvince: or did I miss that on the api page?
15:49hiredmanhttp://clojure.org/data_structures <-- under Symbols
15:49gnuvinceYeah they are
15:50gnuvinceI was confusing with the fact that lists are not callable
15:50gnuvince,(ifn? ())
15:50clojurebotfalse
15:50kotarakHmm... I should reread that from time to time.
15:50hiredmanclojurebot: symbols?
15:50clojurebotIt's greek to me.
15:50hiredmanclojurebot: symbols is <reply>http://clojure.org/data_structures#toc10
15:50clojurebotAlles klar
15:51slashus2,(ifn? '+)
15:51clojurebottrue
15:51hiredman,(ifn? +)
15:51clojurebottrue
15:51slashus2,(ifn? 'a)
15:51clojurebottrue
15:52Chouser_,(ifn? #'+)
15:52clojurebottrue
15:52Chouser_,(#'+ 2 4)
15:52clojurebot6
15:52Chouser_,(@#'+ 2 4)
15:52clojurebot6
15:52hiredman,(class +)
15:52clojurebotclojure.core$_PLUS___3313
15:53hiredmanbah
15:53hiredman,(class #'+)
15:53clojurebotclojure.lang.Var
15:53Chouser_,(class @#'+)
15:53clojurebotclojure.core$_PLUS___3313
15:53hiredman,(map #(.getName %) (.getMethods clojure.lang.Var))
15:53clojurebot("applyTo" "call" "alter" "bindRoot" "pushThreadBindings" "popThreadBindings" "setTag" "setMeta" "setMacro" "isMacro" "fn" "internPrivate" "setValidator" "doSet" "hasRoot" "unbindRoot" "commuteRoot" "alterRoot" "releaseThreadBindings" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "invoke" "
15:56slashus2,@#'*ns*
15:56clojurebot#<Namespace sandbox>
17:44lisppaste8rich_holygoat pasted "Confusing sort behavior" at http://paste.lisp.org/display/77605
17:45rich_holygoatcould someone more experienced than I comment on this apparently-odd behavior of sort on a map?
17:45rich_holygoatthe default comparator sorts just fine, but explicitly specifying a comparator does not.
17:45rich_holygoatthis is with r1337.
17:46stuhoodrich_holygoat: the comparator would need to accept Map.Entry
17:46stuhoodi think
17:46kotarakThe map is turned into sequence of map entries. Obviously the Comparator expects a String => Failure. (at least the is my understanding of the error messages)
17:46kotarakMaybe you want a sorted-map?
17:47rich_holygoatah yes, and the ordinary sort actually calls compare on the map entries
17:47rich_holygoatkotarak: apparently I do :)
17:48rich_holygoatis there literal syntax for a sorted map, or a function to turn an associate thing into one without having to pass the contents as args to sorted-map?
17:48rich_holygoats/associate/associative
17:49hiredman,(class (into (sorted-map) {:a 1 :b 2}))
17:49clojurebotclojure.lang.PersistentTreeMap
17:49kotarak(into (sorted-map) a-normal-map)
17:49rich_holygoatah, thank you folks
18:41stuhood~def into
18:42stuhood~def c.l.PersistentTreeMap
19:34cconstantine~def union
19:36cconstantineSo, how is into different from union... from a caller's perspective?
19:38hiredman,(doc clojure.set/union)
19:38hiredmanclojurebot: ping?
19:38cmvkksudden death
19:38clojurebot"([] [s1] [s1 s2] [s1 s2 & sets]); Return a set that is the union of the input sets"
19:38clojurebotPONG!
19:39sohailthe JVM was collecting garbage
19:39antifuchsthere can be a lot of that on irc channels (:
19:51antifuchsyes, hello sohail (:
19:52cconstantineGotta love seeing java take 200+% CPU
21:11cconstantine~def time
22:06cconstantineI'm making a macro, and I"m using '"`" to quote a block, how do I get a sub-expression to unquote and execute at macro-expand time?
22:07Chouser~
22:07clojurebotrest never returns a unicorn
22:07Chouserha!
22:10cconstantinethanks
22:11cconstantinegrr, it appears to work in macroexpand.. and doesn't when I make the call
22:13cconstantine,(defmacro foo [expr] `([ ~expr ~(str expr)])) (macroexpand '(foo asdf))
22:13clojurebotDENIED
22:14durka42when you do (foo asdf) it says unable to resolve asdf, which is true
22:14durka42([asdf "asdf"]) isn't going to work
22:14cmvkkyou're beter of doing `([ ~expr (str ~expr)])
22:17cconstantinebah, getting the right "layer" of macro execution is hard
22:17cmvkkit is slightly annoying because you can't do macros that require the value of the arguments passed to them;
22:18cmvkksince those values aren't available at compile-time. in common lisp you could do it that way i'm pretty sure
22:18cmvkkbecause in CL there's no distinction between compile time and run time, etc..
22:19cconstantinecmvkk: there is... I just want the expression as a string, and the expression and is confusing
22:20cmvkkoh i see. you don't want the value, you just want the string of the expression itself.
22:20cconstantineright
22:21cconstantineI'm writing a macro that records runtimes for expressions to a global map of accumulcated time-to-execute
22:23cmvkk(def(defmacro foo [expr] vector ~expr ~(str expr)))
22:23cmvkkerr, ignore the first 4 characters
22:23cmvkkand it's missing `(
22:23cmvkkdarn you 'screen'
22:24cconstantinehehe
22:24cmvkkthat should do it though, the problem i was getting was that you were expanding to a vector inside a list...meaning it was trying to call the vector
22:25cmvkk....and i now see that durka42 already explained this.
22:32cconstantineso I'm doing my first sync, and ref-set inside my first macro... yay fun tim!
22:32cconstantinetime
22:33Chouser:-)
22:34cconstantinei wanted ~(str expr)
22:35cmvkk ~(str expr) works, right?
22:36cconstantineyeah
22:36cconstantineI did (str ~expr) at first and got a string of the result
22:36cconstantinewhich for :a was the same ;)
22:38cconstantinenow I have a macro (with-timing [expr]) that will return the result of expr, and accumulate time-to-execute and store it in a map keyed off the expr as a string
22:39cmvkkout of curiosity, how do you store the time to execute? i know (time ...) prints it out but...
22:39lisppaste8cconstantine pasted "with-timing" at http://paste.lisp.org/display/77615
22:40lisppaste8cconstantine annotated #77615 "untitled" at http://paste.lisp.org/display/77615#1
22:40cconstantinethat's stolen from the implementation of the 'time' macro
22:41durka42did you also write time-val
22:41durka42also, (sync nil ==> (dosync
22:41cmvkkis there any different currently between sync and dosync--
22:41cconstantineoh right!
22:41cmvkkyou read my mind
22:42durka42cmvkk: what i said is the definition of dosync
22:42lisppaste8cconstantine annotated #77615 "time-val" at http://paste.lisp.org/display/77615#2
22:43cconstantineyeah... I'm always suspicious when an API doc says "just pass null/nil for this argument"... or when str-tok's docs say "don't use this"
22:43cmvkkone day, though, there might be flags for sync
22:43cconstantineI know, but in the meantime it raises flags for me ;)
22:44durka42"reserved for future use" means i can use that field for my own app-specific settings, right? ;)
22:44cconstantinelol
22:45cconstantineso, I would love for this to make it into clojure... is it reasonable to have that global reference to a map?
22:45cconstantineor would it be better form to make some kind of structure that needs to be passed in?
22:46durka42global variables, two thubs down
22:46durka42thumbs
22:47durka42i dunno, carrying the structure around sounds unwieldy though
22:47Chouseryou mean like *out*, *err*, *warn-on-reflection*, etc?
22:47cconstantineyeah
22:47durka42this macro smells like the beginning of a profiler library
22:47cconstantinepart of hte problem is that timings are kind of intrinsically a side-effect
22:47cconstantinedurka42: yes
22:48cconstantinedurka42: with that raw data (or better data) you could get hings like average runtime, number of execs, max, min, yada yada
22:48durka42that would be cool
22:49cconstantineon any form... not just functions (which I'm assuming all the java-level profilers limit you too)
22:49durka42then you'd have clojure.contrib.timings/*all-timings* which sounds more reasonable
22:49cconstantineI'm a programmer by trade... so I understand how hurtful bad code can be to a code-base.
22:50cconstantinehell, I suffered through a 3 hour code review of stuff that was forced to be terrible by the terrible APIs it had to work with....
22:50cconstantinetoday
22:50cmvkkdo most of the people in here program professionally, I wonder
22:50durka42i don't
22:50durka42not yet anyway
22:51cconstantinehehe
22:51cmvkkme neither
22:51cconstantineI'm threatening to rewrite our testing framework in clojure :)
22:51cconstantineNo one there knows it, but the current java framework is pretty bad
22:51cconstantine*it == clojure
22:52cconstantineah... clojure.contrib.timings... that would mean I'd need to learn namespaces :/
22:53durka42they're like java packages
22:53durka42correspond to folders
22:53cconstantinepackages... I know what folders are *bush*
22:53cconstantine*blush*
22:53cmvkkI get namespaces but I totally don't understand all this classpath stuff
22:54cmvkkwhat annoys me is if I load a file with load-file, and that file defines a namespace, then i try to (use ...) that namespace
22:54cmvkkit doesn't work if the file isn't in the classpath.
22:54cconstantinehehe
22:54durka42right because use goes straight for the file
22:54durka42not that that's logical...
22:54cconstantine(use ...) tries to find the compiled clojure/java stuff?
22:55durka42if the files defines a namespace isn't it already used
22:55cmvkkI guess.
22:55cmvkkwell it would be loading a file with a different namespace than the one i'm in already.
22:55cmvkkthen what i really want to do is refer everything.
22:57Chouserif you loaded it with load-file, you can bring the symbols into your namespace with refer
22:57Chouser(doc refer)
22:57clojurebotrefers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current namespace. Filters can be
22:57cmvkkso something like (load-file "bar-namespace.clj") (ns foo) (refer bar)
22:58ChouserI suppose.
22:59Chouseryou've got essentially different levels of api
22:59cmvkki know it's the wrong way to do things, i don't actually do it that way.
22:59cmvkkbut the fact of the matter is, i often know where my other files are much better than i know what the classpath is.
23:00cmvkki like a system where all I need to know is where the other code is, rather than knowing what the classpath is.
23:00Chouserload-file works on files directly and in-ns and refer work on namespaces directly
23:01Chouserns, use, and require work on "libs" which are an abstraction that combine files and namespaces.
23:03duderdoWhat's the equivalent to 'assoc' from cl in clojure?
23:03cmvkkassoc
23:04duderdoreally? Hm
23:04cmvkk,(doc assoc)
23:04clojurebot"([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
23:04cmvkk(assoc [1 2 3] 1 4)
23:04durka42no, CL's assoc is "get"
23:05durka42http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/fun_assoccm_a_assoc-if-not.html
23:05cmvkkohh yeah.
23:05duderdoah that's what I thought
23:05durka42maps are callable too
23:05duderdothanks.
23:05durka42,({:a 1 :b 2} :a)
23:05clojurebot1
23:05durka42,(:b {:a 1 :b 2})
23:05clojurebot2
23:05cmvkki can't believe i've forgotten that much about CL already
23:06duderdoI'm trying forget, I keep getting mixed up
23:07Chouseryou already forgot "to", so you're well on your way.
23:09duderdoheh
23:11Chouser:-)
23:14duderdoHow can I make a keyword from a string? Is this possible?
23:14durka42,(keyword "boo")
23:14clojurebot:boo
23:14duderdoSweet
23:15duderdoThanks guys. night.
23:15cconstantineooo with a rich programmable timing infrastructure you could make something that takes a set of expressions that implement the same functionality and do automatic detection of fastest algorithm/source (like, an expression for each server to issue requests to, and it could choose the server that's tending to respond faster)
23:16durka42that would be really cool
23:16cconstantineor the parallel/non-parallel algorithms
23:19durka42(defmacro halts? [expr] `(= Double/POSITIVE_INFINITY (time-val ~expr))
23:19durka42i mean
23:19durka42(defmacro halts? [expr] `(< Double/POSITIVE_INFINITY (time-val ~expr))
23:19durka42no still backwards
23:19durka42failed joke :(
23:20cconstantine(defmacro halts? [expr] `(> Double/POSITIVE_INFINITY (first (rest (time-val ~expr)))))
23:20cconstantinethere ya go :)
23:21durka42frest
23:21durka42also that macro might need some optimization :)
23:21Chouserfnext
23:21durka42oh yeah that
23:21cconstantineand should probably return the value of ~expr
23:22cconstantinebut I get it... if it's runtime is less that positive infinity it halted
23:22cconstantineoh right, returns a bool
23:23cconstantinedidn't halt... bah
23:25cconstantineahh, the halting problem
23:25cconstantinesomeone at work today claimed they had a turing complete language that had solved it.
23:25cconstantineshockingly they were mistaken
23:26durka42(defmacro does-halt [expr] `(if (halts? ~expr) (loop [] (recur)) "Logical fallacy complete."))
23:27durka42http://www.reddit.com/r/programming/comments/6wamg/the_terminator_project_taking_on_the_halting/
23:27cconstantinethat reminds me of using exec() in C... exec( ...); exit(1);
23:29cconstantineie, if exec() returns, you have a problem.