#clojure logs

2011-12-18

00:00accelhow many animals do I need to sacrifice to ensure that in the comman dline, I can press <UPARROW> instead of typing (load-file "main.clj") every time? right now, UPARROW gives me ^[[A or something like that
00:01dmansenhow are you launching your REPL?
00:02acceljava clojure.main
00:02accelI'm on OSX
00:02accelosx LION. ROARRRRRRRRRRRRRRRRRRRRR
00:02accel*deers in the area run away in fear*
00:02accel*elephants bow down in awe*
00:02accel*Scar looks on from the distance and snickers.*
00:02dmansenyeah, you gotta wrap that in jline
00:02dmansenlemme look this up
00:02acceljline: command not found
00:03dmansenhttp://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_JLine
00:03dmansengotta grab the jar and such
00:03accelnoted; thanks
00:04dmansenusing leiningen is also nice and easier - i'd recommend that
00:04dmansenhttp://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
00:04lazybotThe riddell.us tutorials are much more highly-ranked on Google than they deserve to be. They're old and way too complicated. If you're trying to install Clojure...don't! Instead, install Leiningen (https://github.com/technomancy/leiningen/tree/stable) and let it manage Clojure for you.
00:04dmansenoh
00:04dmansenam i being outdated? hahah
00:04accelI have this philosophy in life:
00:05accelI should learn how to crawl before I jump into a F15
00:05accelstill playing with the repl / java paths for now
00:05dmansenit's not a bad idea
00:05dmansenjline will make it bearable
00:08acceli have to admit
00:08acceljava has the best libraries ever
00:08dmanseni hate to admit that as well, but it's the truth
00:08acceli've been writing this application since earlier today
00:08acceland every library I needed
00:08accelat my finger tip
00:09dmansenthe clojure interop makes it so nice
00:09accelno ./configure && make && curse at incompatible versions
00:09dmansenthe missing link
00:09accelshit just works
00:09accelit's amazing
00:09dmansenthat's why they say "joy of clojure"
00:09dmansenit's really fun
00:12devnanyone here use parsatron?
00:14amalloyjline is terrible. if you really can't bear to spend two minutes installing lein, then use readline; jline is not an enjoyable substitute
00:15amalloyrlwrap <whatever command you were running before>
00:16devn(run (between (char \() (char \)) (>> (char \+) (char \space) (many1 (letter)) (char \space) (many1 (letter)))) "(+ test case)")
00:16accelwhat is clojure's repelacemnt of "begin" ?
00:17devn(run (between (char \() (char \)) (many1 (any-char))) "(+ test case)")
00:17devni wonder why one passes and the other succeeds...
00:17devnaccel: like, ruby begin?
00:17duck1123accel: if you mean begin as in begin escue end, try
00:17devn^-
00:17duck1123try and catch to be presise
00:17devnand finally
00:18dmanseni think that too
00:18dmansenfirst thing i thought
00:18devn,(do (+ 1 1) (/ 1 3))
00:18clojurebot1/3
00:18amalloy$findfn 'stuff 'more-stuff 'result 'result
00:18lazybot[clojure.core/get clojure.core/trampoline]
00:19amalloyoh right, do isn't a function, so he doesn't try it
00:19amalloytrampoline, though. good joke, lazybot
00:19jsnikerisanyone know why the latest release of ClojureQL (1.0.2) isn't in Clojars?
00:20amalloyif it's not in clojars, it's not the latest release?
00:20devnjsnikeris: i haven't a clue
00:21accelamalloy: you win; it's "do"
00:21accelduck1123: good try
00:22devnwhat, no honorable mention?
00:22amalloyseriously though, jsnikeris, if it's no in clojars it isn't released. if you're getting the version number from their github project.clj, then presumably that's the version that's being worked on
00:23jsnikerisstrangely the github page's README.md says the most recent release is 1.0.2, but clojureql.org states 1.0.0
00:23amalloythough actually i see even their readme says to use that version
00:24amalloyjsnikeris: well, lau probably owns clojureql.org, and he hasn't done any clojure for quite some time
00:24jsnikerisah OK
00:24amalloybendlas is maintaining cql; you should probably ask him on github what the deal is
00:24amalloysince the readme shouldn't suggest a version that doesn't exist
00:25duck1123whatever happened to him?
00:25jsnikerisI was under the impression that Lau just did a complete rewrite of clojureql
00:26amalloy"just" about a year ago
00:27devnhttp://zef.me/2637/on-language-design-my-problem-with-clojureql
00:27devnUpdate: Since this post, ClojureQL has been completely redesigned, my criticism in this post no longer applies.
00:27jsnikerisah gotcha
00:27devnjsnikeris: have you checked out sqlkorma>
00:27jsnikerisI have not
00:28devnhttp://sqlkorma.com/
00:28technomancy_duck1123: he got on rich's bad side
00:28accelgoofing around has been fun and all that
00:28accelbut now I neex ot get serous
00:28duck1123korma is very nice and a natural way to do sql in clojure
00:28acceland split my clojure prog
00:28accelacross multiple files
00:28fielcabralHi I just cloned ClojureScript and run script/bootstrap. Should it be possible to run (require '[goog.string :as gstring]) in the REPL provided by script/repljs?
00:28accelcan someone sugest some docummnentation?
00:28ihodeshmmm. trying to figure out the best way to do this. so I have this LinkedBlockingQueue, and I have a function that wants to `add` to it as long as it can in one thread, and in another thread i want to pop from it and do something with that value, indefinitely. what's a good way of doing this? just dispatching the producer function to another thread?
00:29devnaccel: about using namespaces?
00:29accelis that what seprate files are called?
00:29accelnamespaces?
00:29clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
00:29devnhttp://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
00:29amalloyihodes: sounds like ##(doc seque)
00:29lazybot⇒ "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent... https://gist.github.com/1492466
00:30devnamalloy: you write some beautiful clojure on 4clojure
00:30jsnikerisdevn: I kind of like how stays close to the relational model
00:30devnim "following" you on there now, redoing old problems
00:30amalloydevn: thanks! which problem were you looking at just now
00:30devnjsnikeris: *nod* -- it's very well done
00:31acceldevn: require looks awesome
00:31amalloy(side note: some of my solutions look like total crap because i input someone else's solution to repro a bug they were having)
00:31devnamalloy: it was a series of them. I'm helping a friend learn clojure so i've been re-solving problems with him
00:31devnwe're following you and there are some beauties
00:31jsnikerisdevn: should have had a clojureql in that last comment
00:31amalloyi think my favorite is Beauty Is Symmetry
00:32devnamalloy: which number is that?
00:32accelis "use" equiv to "require blah :as '' " ?
00:32ihodesamalloy: that would work... nice. thanks. still things in 1.0 i don't know about...sigh.
00:32acceli.e. require :as <empty string>
00:33amalloydevn: 50-something, i think
00:33amalloy$google 4clojure beauty symmetry
00:33lazybot[96. Beauty is Symmetry - 4clojure] http://4clojure.com/problem/96
00:33amalloyfactor of 2. not bad
00:33devnaccel: no. (:require [foo.core :as f]) would mean that throughout your program you (f/fn args) in order to call foo.core/* functions
00:33devnaccel: if you (:use [foo.core]), you would (fn args)
00:34devnaccel: but using means it can overwrite a local definition of (fn).
00:34amalloyaccel: yes, it's a lot like requiring as the empty string, if that were possible
00:35ihodesamalloy: except it's returning a seq, which means i can't really peek/pop/.take
00:35devnamalloy: am i confusing his question again with something in scheme?
00:35devnrequire :as is not the same as :use -- when you say 'yes', what are you referring to?
00:35amalloyihodes: you don't need to, just map or doseq your side-effecty function over the seq produced by seque; it will block as long as necessary
00:36amalloydevn: he asked if :use is kinda like :require with an empty prefix
00:36devnd'oh, i see now. :X
00:37devni assumed it was the old use/require question.
00:39devnamalloy: heh, 96 is interesting indeed
00:39ihodesamalloy: excellent!
00:40choffsteinCan anyone help me with a weird error I am getting? https://gist.github.com/1492480
00:40choffsteinI don't understand why I am getting the ArityException I am with my assoc usage
00:42amalloyincanter probably defines another function called assoc that behaves differently
00:42choffstein…that would make sense
00:42choffsteinand this is why I shouldn't code at night
00:43amalloyalso, those flattens are horrible
00:43amalloy~flatten
00:43clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
00:43choffstein…but they do exactly what I want :D
00:44devnamalloy_: everything was going along just fine until i hit the vectors
00:48fielcabral"require" question for ClojureScript: Can I (require '[goog.string :as gstring]) in ClojureScript's script/repljs REPL? (https://gist.github.com/1492486)
01:23accelA = code works. B = A, except a function foo is moved into another namespace. B does not work (i.e. in the GUI, I end up drawing a blank box instead of drawing pictures). Java does not throw any errors (everything is properly imported). I can't figure out what's going on -- unless there's some library I'm used, which is loaded twice, and their internal state is conflictgin?
01:33technomancy_you guys
01:33technomancy_I am very excited
01:33technomancy_clj-stacktrace in swank.
01:33dmansenhey
01:33technomancy_squeeeeeeeeee
01:33technomancy_dmansen: nice work =)
01:33dmanseni have really enjoyed modifying this
01:34dmanseni should be going to bed, but this is a lot of fun
01:34technomancy_I'll let it simmer a while and then cut a release maybe at the end of the week if no issues are reported.
01:34dmansenexcellent
01:35technomancy_I love it when you're expecting something to be this big burden, and then when it's done you discover it was much simpler than you were expecting.
01:35technomancy_even better when someone else does it for you =)
01:35technomancy_but I better head off too; see you later.
01:35technomancy_thanks
01:35leo2007technomancy_: what does clj-stacktrace for swank do?
01:36dmansenit makes the stacktraces print prettier
01:40accelDAMN IT
01:40accelI found my BUG :-)
01:40accelsuppose foo/dog.clj depends on foo/cat.clj
01:40accel(load-file "foo.dog.clj") does NOT reload "foo/cat.clj"
01:41acceleven if "foo/cat.clj" has changed
01:41accelhow do I tell clojure to do a
01:41accel(load-file-and=-load-all-dependences-that-have-changed "foo/dog.clj") ?
01:54accelalright
01:54accelso on the web
01:55accelI keep on finding documentation on defrecord
01:55accelhowever, I want mutable fields
01:55accelis there a good example of how to use deftype
01:55accel(and setting the fileds) anywhere?
02:01accelalright; so I have
02:01duck1123accel: for the first question of the reloading, try adding a :reload-all flag in your require block
02:01duck1123as for the "i want mutable fields" you probably don't actually
02:01accel(deftype Bar [a b c d e]); (def b (Bar 1 2 3 4 5)); now, how do I set field :c of b ?
02:02accelduck1123: you're probably right; what do I wnat instead?
02:02duck1123well, if you go with defrecord, you have a type that has all the powers of a map
02:03duck1123so (let [b (Bar. 1 2 3 4 5)] (assoc b :c 17)
02:04accelduck1123: (:require crfx.util)
02:04accelwhere do I stick the :reload-all ?
02:04duck1123(:require foo.dog :reload-all)
02:04accelduck1123: alright; I am convinced I have no idea what I am talking about.
02:05accelhere's the situation: I need to store some data structure
02:05accelthis data structured needs to store lots of GUI elements
02:05accelI need to call functions w/ side effects on these GUI elements
02:05duck1123reload all is kinda tricky, and I tend to avoid it really, but that's only because saving a file and sending it to the swank session is an automatic pattern for me
02:06devnatom(s)?
02:06duck1123are these gui elements java classes that need special care?
02:06clojurebotsucc 0 is 1
02:06accelthey're java classes
02:06accelI don't know if they need special care
02:07accelyou know
02:07devnaccel: it helps if you can tell everyone your general goal. there are many ways to write the same program.
02:07accelthis sounds like prmature optimization
02:07accelI'm writing a WYSIWYG document editor
02:07duck1123well, in most cases, you make it so that whenever you need to make a change, you have your function return a new copy of the structure
02:07accelwhen a user presses a key, some internalt state is updated
02:08duck1123this gets tricy with mutable java objects
02:08accelwhen this state is updated, I need to call repaint on a bunch of GUI elements
02:08accelSTMs _only_ roll back clojure state (i.e. Refs), and does not "time-wrap/un-execute" java code right?
02:09duck1123I don't get into gui, but I know there are several libraries that make this sort of thien easier in clojure, have you looked at them?
02:09accelnot yet
02:09accelthis isn't a full GUI
02:09accelI need only to keep two java Graphics2D elements updated
02:09devnI think duck1123 is right to suggest that as a next step. Learn how other people do it. When you say WYSIWIG it sounds like a GUI to me.
02:09duck1123right, Clojure's stm can't undo a mutable java poperation
02:10devnText editors aren't simple. It's worth looking at existing solutions to the problem.
02:10devnFinding the analgous problem and its solution is valuable.
02:11duck1123from what I've heard, the java gui libraries really went out of their way to make it a PITA for clojure
02:12ihodesamalloy: seque isn't going to work, i need a way to .take from the queue...
02:12devnduck1123: we can make them suck less with concerted effort.
02:12ihodesis there a way to send my producer to another thread and just have it add to the agent, unless i tell it to stop? agent?
02:13duck1123accel: this might get you started https://github.com/search?type=Repositories&amp;language=Clojure&amp;q=swing
02:14acceli got it figured out
02:14accelI want agents + watchers
02:14accelduck1123: will look into it; thanks
02:14accelerr, we are blaming java for not taking into account the needs of a programming langauge that did not exist at the time java was being built?
02:15duck1123absolutely! That;s no excuse
02:16amalloyjava developers will go so far as inventing a time machine to increase the getter/setter proliferation
02:16duck1123some would argue that some core features of Java don't take into account the needs of Java
02:17accelcode in a STM block may be re-executed
02:17accelfor an agent, does the function that I pass to it
02:17accelget guaranteed to be executed exactly once?
02:17amalloyaccel: would you ming using some punctuation instead of gratuitous newlines? it rather clutters up the channel
02:18amalloyand i believe it's guaranteed to execute at most once. you can't guarantee it ever executes, because some prior action may fail, clogging the pipe
02:21duck1123There's something about if you send inside a dosync, then it only gets sent wen it finishes, but then there's something about "only with a ref" that I got wrong before. Can't find the relevant docs
02:22duck1123Will atoms ever trigger a retry?
02:22accelamalloy: Understood. Will try to be better in the future.
02:23devnduck1123: As with all reference types, the intended use of atom is to hold one of Clojure's immutable data structures. And, similar to ref's alter and agent's send, you change the value by applying a function to the old value. This is done in an atomic manner by swap! Internally, swap! reads the current value, applies the function to it, and attempts to compare-and-set it in. Since another thread may have changed the value in the intervening time, it may ...
02:23devn... have to retry, and does so in a spin loop.
02:24devnduck1123: http://clojure.org/atoms
02:24accelSo clojure does NOT do any time of scheduling to ensure that only one of these modify-functions on an agent is executed at a given time?
02:24duck1123devn: right, I was just reading that. I'm just trying to understand the "only with refs" part I was corrected on
02:26amalloyaccel: certainly it does. that's the point of agents. but duck1123 was asking about atoms
02:26devnduck1123: where at?
02:27devnaccel: atoms, refs, and agents are different animals.
02:28devnhttp://techbehindtech.com/2010/06/05/simple-matrix-refs-atom-agents-clojure/
02:30acceldevn: lol; thanks
02:30accelin terms of GUI/repainting. I'm looking at http://java.ociweb.com/mark/clojure/ClojureSnake.html <-- why does this code not proxy an obejct + override it's paint() function?
02:31devnaccel: Aaron Bedra and Stu Halloway's update to "Programming Clojure" has a demonstratrion of the snake program.
02:33accellooking at their code; it seems like they're doing it the "wrong" way; i.e. they have a main loop, where they draw everything + -then sleep for 30 milliseconds
02:33accelI was under the belief this is NOT the correct way to do things.
02:34devnaccel: we invent the correct way by doing it correctly
02:34acceldevn: you believe snake.clj's way of handling repaints + nteractivity is the right way?
02:34duck1123I think that's more the shortcut way, where doing anything better was outside the scope
02:35devnaccel: i do not believe in ultimate correctness.
02:35devni believe in a general form of correctness that takes into account the nature of the problem and the goal of its solution
02:36amalloyaccel: i believe that is a very common pattern for game code, where you just want a canvas to draw on however you like whenever you like
02:36amalloyif you want to make a menu with lots of nice clicky buttons, this isn't the way to do it; but that's not what they're doing
02:38devnhttp://ique.github.com/bebot/ is interesting
02:38duck1123make your code read from a lamina channel and take that data and draw your form. then you could enqueue transitions from other threads
02:38devnwhat about avout?
02:39duck1123ok, so you can enqueue from any machine in his cluster?
02:40accelamalloy: good call, I believe most OpenGL apps are writen in a similar manner.
02:40devnaccel: i was talking to someone the other day. they were very concerned with being "right" immediately.
02:40duck1123I've been excited about the possibility of avout + lamina, but I haven't hade the time yet
02:41devnduck1123: i got a few friends at work to install zookeeper and we had a bit of fun
02:41devnit's very cool
02:42accelI thin this is what I wanted to read: http://pragprog.com/magazines/2010-11/getting-clojure.
02:45duck1123devn: I think when I do get around to using avout for my one project, I'll use the mongo backend as I'm already using it as my datastore.
03:08accel(def curline (agent "")) ; (send curline (fn (x) x)) <-- why does this code result in an error?
03:09acceluser=> (def curline (agent "")) (send curline (fn (x) x))
03:09accel#'user/curline
03:09accelCompilerException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(NO_SOURCE_PATH:7)
03:09accelwhat is wrong with this?
03:10accelI'm sending it the identity function
03:10acceland yet it can't do anything with it?
03:12accelI want [x], damn it :-)
03:13amalloyaccel: you want ##(doc identity)
03:13lazybot⇒ "([x]); Returns its argument."
03:14amalloyalthough what the hell, why are you sending an agent identity?
03:15accelamalloy: i simplfied my code to a minimal failure case
03:15acceldespite the sutpidity I have demosntrated so far, I do not send agents the identity function :-)
03:29duck1123I just finished documenting Ciste's routing mechanism. Anyone willing to provide feedback? https://github.com/duck1123/ciste
03:29duck1123I really need to break this into a Wiki
03:56acceli do not know if this is the right window to ask: I am using Clojure on OSX Lion. Is there anyway to make one of my awt/swring windows _transparent_ ? I don't need rounded corners; I only need transparent.
04:02kumarshantanuaccel: http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
04:04kumarshantanuYou must be on JDK 1.6.10 or higher, on Lion latest as of now is 1.6.29
04:05accel~$ java -version
04:05acceljava version "1.6.0_29"
04:05clojurebothttp://java.sun.com/docs/books/tutorial/java/index.html
04:05accelkumarshantanu: thanks!
04:06devn(inc kumarshantanu)
04:07accel(dec accel)
04:07lazybotYou can't adjust your own karma.
04:07accel(read accel)
04:07accellazybot: help
04:07lazybotYou're going to need to tell me what you want help with.
04:07accellazybot: help karma
04:07lazybotaccel: Checks the karma of the person you specify.
04:08accel(karma accel)
04:08accelkarma accel
04:08accellazybot: karma accel
04:08lazybotaccel has karma 0.
04:09duck1123accel: if you want to play with clojurebot, it'll respond over /query
04:09Raynesduck1123: That isn't clojurebot.
04:09RaynesBut he will also respond over /query.
04:09Raynesduck1123: If you ever call lazybot clojurebot again, he might just end you.
04:09duck1123lol
04:10RaynesKeep laughing. You'll get yours.
04:10amalloyRaynes: usually i tell people to knock it off and use /msg, but lazybot keeps separate karmas per channel (and /msg is a separate channel)
04:10accelit's alright; I'll stop :-)
04:11Raynesaccel: FYI, you didn't really do anything over the top or bother anyone. We were just mentioning the query capability so that you didn't. :)
04:11RaynesWe still <3 you.
04:12amalloyRaynes: anyway, lazybot is here for the entertainment of #clojure denizens, right???
04:12lazybotamalloy: How could that be wrong?
04:13RaynesNot to mention that it is 3AM, 1AM, and 2AM and variations thereof in the US, so all the people with lives are asleep.
04:13keith__:(
04:14RaynesOn the other hand, all the cool people are awake.
04:14keith__:)
04:21accelis it bad style to use _ instead of - in clojure code?
04:21accelsomehow, I find foo_bar easier to read than foo-bar
04:23keith__it's a lisp convention
04:23keith__I think they just like to gloat about how no one else can do it though
04:23acceldoes _ have special meaning in clojure?
04:23keith__only when used alone
04:23keith__as a function argument
04:23accelas in ignore thi sargument?
04:23keith__it discards the parg
04:23keith__ya
04:24amalloy_ has no special meaning in any context
04:25amalloy&((fn [_] (inc _)) 10)
04:25lazybot⇒ 11
04:26amalloyi mean, in a language with macros, any macro could give _ special meaning, of course. but none of the built-ins do
04:26keith__&((fn [_ _] _) 1 2)
04:26lazybot⇒ 2
04:26keith__&((fn [a a] a) 1 2)
04:26lazybot⇒ 2
04:26keith__oh I guess not
04:33accelis there any clojure data type (i.e. deftype, defrecord) where I also specify the types of the members?
04:35duck1123accel: chances are, you don't really need it
04:36duck1123what are you looking to gain by specifying the types of the members?
04:36acceleasier to debug
04:36accelcoming over from haskell
04:39duck1123yeah, clojure is a very different beast from haskell when it comes to types. In clojure, it's generally recommended to code against abstractions and use those abstractions to build the bigger picture.
04:40amalloyduck1123: i don't think the second sentence is really relevant
04:40accelwhat do ou mean "code vs abstractions" ?
04:41accelare these abstractions enforced by anything?
04:41amalloyaccel: clojure just has a much looser philosophy about typing
04:41amalloytrying to apply haskell habits is good, but when the language is obviously discouraging you, try to adapt instead of cram the square peg into the round hole
04:42accellol
04:42accelwhat is the right way to build a DOM tree
04:42accelall of whose members are either FooNode, BarNode, CatNode, or DogNode ?
04:42amalloydon't do that. just build a tree whose members are all Nodes
04:43accelI want to then write code that does patern matches on FooNode/BarNode/CatNode/DogNode
04:43amalloyclojure's pattern-matching facilities are much weaker than haskell's
04:44accelAre there cool things we can do with amcros to make up for it?
04:44amalloythe general approach is to make each node a hashmap containing whatever type information you need (which is less than you think, really)
04:45amalloywell, of course
04:46amalloyone problem is pattern-matching is a closed system: if you later add a BlamNode, all the pattern-matching sites need to change
04:47duck1123that's when multimethods are great
04:47amalloybut you're approaching every problem as "I'm building a Haskell program using Clojure, and this line of code doesn't work; how can I do this Haskell thing?"
04:49amalloyinstead, embrace the tools that clojure emphasizes, like ubiquitous and easy hashmaps
04:49accelamalloy: Not everything. I'm not asking for monads + algebraic data types. I used to use scheme; and I do like the ease of detecting errors via types.
04:49amalloyi do too; i've dabbled with haskell and wish we had algebraic data types and optional static typing. but it's not there (yet: you can add it yourself in a library if you have a few months to spare and are a genius)
04:49kumarshantanuaccel: you may like to check out Jim Duvey's experiment with monads
04:50accelI have 72 hours to spare. I am not a genius.
04:50accelkumarshantanu: will look into it
04:52amalloyaccel: you can get basically a generalization of typeclasses, by using multimethods
06:14triyois there a shorthand for something like (or [] [1 2 3]). So thats if vector is empty use the right hand side as the default
06:22licenser,(dropwhile empty? [[] [1 2 3]])
06:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dropwhile in this context, compiling:(NO_SOURCE_PATH:0)>
06:23licenser,(drop-while empty? [[] [1 2 3]])
06:23clojurebot([1 2 3])
06:23licenserthere we go :)
06:24triyoCool, that'll do
06:25amalloy&(or (not-empty []) [1 2 3])
06:25lazybot⇒ [1 2 3]
06:25licenser&(or (not-empty [1]) [1 2 3])
06:25lazybot⇒ [1]
06:26licenserneat
06:26triyoHmm, I'm being stupid here guys. Sorry. I forgot the mention that the first list is the optional arg of a function. Thought that returns an empty [] if no optional args are set mean while its actually a nil.
06:27triyoso in that case its actually (or nil [1 2 3 4])
06:27licenser,(or nil [1 2 3 4])
06:27clojurebot[1 2 3 4]
06:27licenserthat is working great so no need for any of the trickery ;)
06:28triyoexactly :)
06:29triyoNever make assumption
06:29triyoSo I did a quick test in repl
06:29licensertriyo: no making assumptions is OK as long as you are right in the end :P
06:29triyo,((fn [a b & c] c) 1 2)
06:29clojurebotnil
06:29triyo((fn [a b & c] c) 1 2 3)
06:30triyo,((fn [a b & c] c) 1 2 3)
06:30clojurebot(3)
06:30licenser&((fn [a b & c] c) 1 2 3)
06:30lazybot⇒ (3)
06:30triyolicenser: thanks for the words of wisdom. ;-)
06:31licenser^^
06:31licenserthat's what I am here for sharing my experience of years and years being a smartass
06:35triyoalways appreciated :)
06:58osa1does clojure have a function like python's dir, which lists vars, functions, etc. in a namespace?
07:10kawas44osa1: (require '[clojure.repl :as rpl]) (* then load your namespace *) (rpl/dir <your namespace>)
07:11osa1kawas44: thanks. do you know something like repl/dir but for java classes? to browse methods etc.
07:15kawas44osa1: the same question was asked yesterday but I dont have the log :)
07:16kawas44osa1: for consultation you can play with (javadoc <your class>) # see clojure.java.javadoc
07:17kawas44osa1: for prog use you can play with (bean <your obj or class>)
07:17osa1kawas44: looks like I don't have clojure.java.javadoc (clojure 1.3)
07:19kawas44osa1: javadoc is just an helper function to open your browser on java api pages try: (javadoc String)
07:20kawas44osa1: to have more function you should load the namespace (use 'clojure.java.javadoc)
07:22osa1kawas44: javadoc is not what I want actually, I want to work on just REPL and a clean buffer
07:23kawas44osa1: as I said you can play with (bean obj)
07:24osa1kawas44: is there a pretty-printer for output of (bean obj) ?
07:29kawas44osa1: sorry I dont know of one, maybe in a lib, but your can filter the output on keys your are interested in :)
07:53kawas44osa1: If you manage to get repl-utils lib, I think "show" may do what you want : http://clojure.github.com/clojure-contrib/branch-master/repl-utils-api.html#clojure.contrib.repl-utils/show
07:59terom~logs
07:59clojurebotlogs is http://clojure-log.n01se.net/
09:13dmansenhmm. just noticed that my swank-clojure indentation code doesn't work well when you go to other frames..
09:13dmanseni guess i should fix that
10:24wmealinghi, i'm playing with fedora 16's "yum install clojure", the repl doesn't seem to work how i'd think. i expected an "up arrow" to go to the previous input.. am I doing it wrong ? what should I be doing ?
10:28wmealingI expected tab and auto complete to work too..
10:44wmealingjline trickery with a shell script. seems to do most of what i want.
10:46cemerickwmealing: Clojure is a JVM *library*, and so is generally a mismatch for OS-level package managers. *shrug*
10:47wmealingyeah, and java not having a repl and all.
10:47wmealingat least not to my knowledge.
10:48cemerickWell, Java != JVM. And a Java REPL makes as much sense as a "C REPL"
10:49cemerickthough both things do exist :-P
10:52wmealingtoday i learned.
12:15TimMccemerick: I use a very shitty Java REPL every day at work.
12:15cemerickbeanshell, perhaps?
12:16TimMcIt's an Eclipse View called "Display".
12:16cemerickheh, sure
12:16cemerickMy loyal, fucked up little friend. :-P
12:17TimMcThat's an excellent description.
12:18TimMcAlthough I might temper the loyal part -- every once in a while it decides it doesn't wanna.
12:18cemerickI've abused it enough by making it do things you really shouldn't do that I can't fault it too terribly.
12:19TimMcwmealing: If you use Leiningen's REPL, make sure to install rlwrap.
12:19TimMcIt will give you the readline support you want.
12:20TimMcBut yeah, grab Leiningen and run `lein repl` inside or outside of a project directory.
12:44mrevilif I'm debugging and I wanted to print the class name of an object how would I do it?
12:45miniyukimrevil: (println (class o)) ?
12:46TimMc$findfn 5.6 Double
12:46lazybot[clojure.core/class clojure.core/type]
12:47mrevilminiyuki: that was it. thanks
12:57rplevyDerGuteMoritz: I'm looking at clj-oauth2 and trying to figure out if this library has a different or the same purpose as clj-oauth
12:58rplevythe reason is I noticed clj-facebook-graph is not upgraded to 1.3 yet
12:59DerGuteMoritzrplevy: clj-oauth implements OAuth 1.0, at least last time I checked
12:59rplevyI see
12:59DerGuteMoritzthus clj-oauth2 because it implements OAuth 2.0 :-)
12:59rplevyso I'm going to upgrade clj-oauth2 to 1.3
13:00DerGuteMoritzrplevy: cool, feel free to send a pull request
13:00rplevyok, great, thanks
13:01jsnikerisIs it always preferable to use "(:require [a.b.c :as c])" over use?
13:01DerGuteMoritzjsnikeris: I'd say it's a matter of taste and clarity
13:02DerGuteMoritzjsnikeris: e.g. when the namespace you are importing contains some very generic names such as `get' it's clearer to use a prefix
13:02jsnikerisI'm looking at the the sqlkorma library, and it seems like it would be cumbersome to genearte queries if I always had to write (sql/select users (sql/with address) (sql/fields [:firstname]))
13:02DerGuteMoritzlright
13:03jsnikeristhose are pretty generic names though
13:03DerGuteMoritzif you are going to use a certain library a lot in your code I would use `use'
13:03DerGuteMoritzconsider it a DSL then :-)
13:03jsnikerisright
13:03DerGuteMoritzif you only use it in one or two places, then I'd go for the prefix
13:03jsnikerisgotcha
13:03DerGuteMoritzbut there is no hard rule to rely on
13:04jsnikerisya, I mean I can see both sides of the argument
13:04jsnikerisw/ require it makes it clear where fns are coming from
13:04DerGuteMoritzthat's right
13:04DerGuteMoritzunless you choose a bogus prefix, of course :-D
13:05jsnikerisheh, but even then you can look to see what namespace that prefix corresponds to
13:05teromAlso consider using :only in combination with :use so that it's clear what you're really using.
13:06Vinzent+1 for that; i use require only when there is conflicts with clojure.core functions
13:06DerGuteMoritzthat's also a good idea sometimes, indeed
13:09jjcomerDoes anyone happen to know where you can download the source code from Rich's Clojure Concurrency presentation? Here is the link: http://blip.tv/clojure/clojure-concurrency-819147
13:09jsnikerisseems like it could be tedious to manage your 'use only' declarations though
13:10jsnikerisVinzent: although, I can see the merits in using that style
13:11jsnikerisI think that's actually the best strategy
13:12jsnikeris'use only' by default, and if there are conflicts, 'require as'
13:12jsnikerisdoes clojure-mode provide any help for managing one's ns declaration?
13:13Vinzentjsnikeris, as far as i know, it does not; but you should check https://github.com/technomancy/slamhound
13:15VinzentAlthough, I haven't tried that. In fact, it's pretty easy to manage declarations by hand
13:17jsnikerisVinzent: slamhound looks like it does what I want
13:17jsnikerisVinzent: thanks!
13:21Vinzentnp
13:26RazWellesHow's the CLR implementation of clojure in terms of maturity?
13:33travisjefferyi want to define a function takes parameters name and direction given in a hashmap, how do I deconstruct them properly if I call the function like: (my-func {:name "NAME" :direction "DIRECTION"})
13:41mrevilgiven two sequences '(1 2 3) and '(a b c) is there an easy way to get '( '(1 a) '(2 b) '(3 b)) so that i can use it with doseq?
13:42cemerick(map vector [1 2 3]
13:42cemerick,(map vector [1 2 3] '[a b c])
13:42clojurebot([1 a] [2 b] [3 c])
13:42Bronsa,(partition 2 (interleave '(a b c) '(1 2 3)))
13:42clojurebot((a 1) (b 2) (c 3))
13:42dmansenhmm, i'm very close to having this colorization done for swank-clojure
13:43dmanseni just need to somehow indicate to swank that my advice around slime is enabled or not
13:44Vinzentalso ##(zipmap [1 2 3] '(a b c)) is basically the same
13:44lazybot⇒ {3 c, 2 b, 1 a}
13:45Vinzentif ordering isn't important
13:46jjcomerwhat about ##(map-indexed (fn [a b] [(inc a) b]) [:a :b :c :d :e])
13:46lazybot⇒ ([1 :a] [2 :b] [3 :c] [4 :d] [5 :e])
13:46travisjefferyif i deconstruct arguments to a function how can i bind the entire match as well?
13:47mrevilty!
13:47Vinzenttravisjeffery, [[a b c] :as coll]
13:48travisjefferyVinzent: Thanks!
13:49Vinzenttravisjeffery, oh, wait, or is it [a b c :as coll]?
13:58scottjdmansen: colorization done for swank-clojure?
14:03dmansenscottj: almost
14:04dmansenit's all working, i just have to make sure it doesn't use the coloring if this particular advice isn't loaded
14:04scottjdmansen: I meant what do you mean by that?
14:04scottjcoloring in autodoc, in inspector?
14:04dmansenoh oh
14:04dmansenstack traces
14:05scottjhmm, is that a special lib, I don't see any color in sbcl sldb that I don't see in clojure
14:06dmansenit looks like this, the colors come from the clj-stacktrace package:
14:06dmansenhttp://t.co/srsMjNvc
14:07scottjoh I see
14:30gf3sjl: ohai!
14:52priv_cooperI am curious, what blogs do you all like to read?
14:53priv_cooperTrying to refill my rss reader
14:54Vinzentpriv_cooper, http://nakkaya.com
14:55priv_cooperI am new to lisp's, currently loving clojure. Just re-coded my personal website in clojure. Working through sicp and learning more clojure.
14:56priv_cooperVinzent: Is this your blog?
14:57Vinzentpriv_cooper, no, but it's very cool :)
14:58technomancy_dmansen: you could have it triggered by a defproject key
14:58cemerickpriv_cooper: you could do worse than to add Planet Clojure. :-)
14:58technomancy_and then the jack-in task could assoc in that key since it knows the colorization advice is active
14:59jsnikeristechnomancy_: hey, I'm trying to get slamhound.el working with Emacs < 24
15:00technomancy_jsnikeris: hm; yeah that is not very well-tested
15:00technomancy_even on 24, the pretty-printing is kind of crappy
15:00jsnikeristechnomancy_: So I'm looking at slamhound-prettify-subclause, and it looks like it's just removing extra spaces and newlines from a '[net.cgrand.enlive-html :only [html-content]]'
15:01technomancy_yeah, I don't think I got to the point of attempting to keep lines under 80 columns
15:01jsnikeristechnomancy_: are there some times where the slamhound clojure code returns extra spaces?
15:01technomancy_yes, it'll insert line breaks in odd places
15:01technomancy_because it just uses clojure.pprint
15:02jsnikeristechnomancy_: ah, ok. my examples must not have shown that yet
15:02jsnikeristechnomancy_: I think this little tool is great btw
15:02technomancy_jsnikeris: I had tons of fun writing it
15:02technomancy_except for the prettification part; that is a huge pain
15:02jsnikeristechnomancy_: do you still use it to manage your namespaces?
15:03technomancy_I don't use it much, mostly because of the prettification issue
15:03technomancy_also because I've started to do more things like (:require [cheshire.core :as json])
15:03technomancy_and slamhound assumes the :as must be the same as the last segment
15:03jsnikerisright
15:04jsnikerishmm
15:04technomancy_partly that's a problem with cheshire; having .core in the namespace name is lame. but that's a fact of life.
15:04miniyukiwhat would you recommend Midje or Lazytest?
15:04jsnikerisI suppose slamhound could take hints from an existing ns definition
15:04technomancy_yeah. I can't think of a way to portably declare "these are the nonstandard require mappings this project uses", but leveraging what's already there is probably as good as you can get.
15:05technomancy_if you'd like to take a crack at it, I'd love to take a patch
15:05technomancy_I documented the internals fairly thoroughly here: http://technomancy.us/148
15:06jsnikeristechnomancy_: yah, I'll take a look at it after I get the prettification working on Emacs < 24
15:08jsnikeristechnomancy_: I'm not too familiar w/ how clojure-mode works, but would it make more sense for the ns formatting stuff to exist there?
15:08jsnikeristhen you slamhound could just call indent
15:08technomancy_jsnikeris: yeah, that would make a lot of sense
15:08technomancy_anything that can be done statically (without communicating with a running clojure process) can go in clojure-mode
15:09technomancy_but I am also totally unfamiliar with its indentation functionality
15:09jsnikerisI'm guessing that you can only specify rules for indenting one line at a time
15:10technomancy_there's some level of backtracking logic
15:10jsnikerisOK
15:10jsnikerisbut if you've got the whole namespace on a single line, you probably couldn't specify a rule that would split it up and indent it properly
15:12technomancy_actually you might be able to make it work as a reduce over a seq of forms -> a vector of strings in clojure
15:13technomancy_maybe doing it from elisp is the wrong approach?
15:13technomancy_dunno
15:15jsnikeristechnomancy_: well I'd suppose people would be interested in formatting their ns declarations in a standard way even if they're not interested in automatically building them up
15:16jsnikeristechnomancy_: if that is the case, then the namespace formatting stuff should live in clojure-mode, while the namespace generating stuff should live in slamhound
15:17jsnikeristechnomancy_: I'm going to try my hand at a namespace formatter
15:17dmansentechnomancy_: wish i had read all this a few minutes ago
15:17priv_coopercemerick: Thanks!
15:18dmanseni've been trying to figure out how to send a command to emacs that will return whether or not that advice is defined
15:18dmansenit feels like i'm close, but i really don't understand the slime protocol that well
15:24technomancy_dmansen: it doesn't have to check for the advice itself necessarily
15:24technomancy_the file that has the defadvice could provide something, and then you could just check featurep
15:24dmansenoh sure
15:25dmanseni just don't know how to communicate between the processes :)
15:25dmanseni don't know if i should be sending an :eval message, :emacs-return, or what
15:31technomancy_yeah, it may be simpler to set something in the jack-in task instead
15:32dmansenohhhh i see what you mean. that does sound much easier
15:41fielcabralHi. Does the repljs REPL in ClojureScript allow you to call require?
15:42fielcabralHi. Does the repljs REPL in ClojureScript allow you to call require?
15:45dnolenfielcabral: if you mean call require as a function, I don't think that works yet.
15:48y3diin order to use the jvm, do we need to get a liscense from Oracle to avoid being sued? how exactly does that work?
15:49fielcabralCan anybody see this? Pigs fly
15:50cemericky3di: why in the world would you think that's necessary?
15:51y3dino idea... lol so i guess not
15:53technomancy_you only need a license to fork it
15:56fielcabraltest
15:58y3diwhats the difference between an api and a dsl?
16:00technomancy_"dsl" is just a trendy way to say "an api that makes sense"
16:01y3dihaha ok
16:03fielcabral /help SET
16:06fielcabraltest
16:10fielcabral_MSG NickServ IDENTIFY fielcabral 62TJn47kHm6Zt4KNuh4eGNS6AY23Cr9h
16:10dmansentechnomancy_: wow, that's the best way i've heard of distinguishing that
16:11fielcabral__MSG NickServ IDENTIFY fielcabral 62TJn47kHm6Zt4KNuh4eGNS6AY23Cr9h
16:11cemerickfielcabral__: um, might want to not use that password.
16:13gfredericksyeah, it's clearly insecure. Doesn't even have any special characters.
16:14fielcabraltest
16:58gtrak_mPretty impressed clojure has a repl on android and python does not
17:02babilengtrak_m: https://code.google.com/p/android-scripting/ (it does)
17:03gtrak_mAh
17:03dmansenokay...FINALLY
17:04dmansentechnomancy_: i have it working...it feels a bit ugly right now though
17:04samaaroni'm trying to implement IFn within defrecord - has anyone tried this before?
17:07dmanseni stored *color-support?* in a ref, but i don't know if that's necessary
17:07kotaraksamaaron: (defrecord Foo [x] IFn (invoke [this y] (+ x y))) Doesn't sound too scary, no?
17:08samaaronkotarak: sure, if you only want to support one args in your fn
17:08samaaronbut if you want to support varargs it seems you ahve to implement all the different invoke arities
17:08samaaronunless i'm doing something silly
17:08kotaraksamaaron: another example http://clj-me.cgrand.net/2011/10/17/valued-functions/
17:08kotarakAh. varargs.
17:08cemericksamaaron: There was a macro kicking around that would stub out IFn as necessary.
17:09samaaroncemerick: yeah, that's what i was just about to start writing
17:09cemerickAlternatively, you can proxy AFn *very* easily.
17:09gtrak_mIs the array parity more than one arg?
17:09gtrak_mArity *
17:09samaaroncemerick: if I proxy AFn, how easy would it be for me to also implement IObj?
17:10cemerickNot very.
17:10samaaronyeah, that's the position i'm in
17:10samaaronwe already have a proxy version of our 'callable-map'
17:10samaaronbut i can't add metadata to it
17:10samaaronand we wrote it years ago
17:11samaaroni think i'll just implement all the different invoke arities
17:11samaaroni only have to do it once
17:12gtrak_mAh damn, it's 20 plus the array
17:12samaarongtrak_m :-)
17:12cemericksamaaron: The universe demands that you produce a macro and gist it. For the children. ;-)
17:12samaaroncemerick: haha, ok. The younglings shall be considered
17:15kotaraksamaaron cemerick Why is IObj difficult to proxy with AFn? http://paste.pocoo.org/show/522730/
17:15kotarakI'm confused.
17:17cemerickOhhh! I misread samaaron's msg as "how *hard* would it be" :-P
17:17cemericksamaaron: it's very *easy*, not very hard, to implement IObj with proxy.
17:19samaaroncemerick: ah ok
17:20samaaroni wonder if we should just stick with our proxy impl then
17:20samaaronbtw, what's the difference between AFn and IFn?
17:20fridim_Sorry to interrupt, I'm disicovoring clojure, but that is strange to me : user=> (* 12323123213 1231231231312) => ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1374) I thougt, clojure was a lisp :P
17:20kotaraksamaaron: AFn is base class IFn is the interface
17:21fridim_discovering*
17:21samaaronyou can easily tell I never got too dirty with Java :-)
17:22brehautfridim_: its a lisp that has to respect the JVMs tradeoffs as best it can
17:22kotarak,(* 12323123213 1231231231312)
17:22clojurebot#<ArithmeticException java.lang.ArithmeticException: integer overflow>
17:22kotarak,(*12323123213 1231231231312N)
17:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *12323123213 in this context, compiling:(NO_SOURCE_PATH:0)>
17:22brehaut,(*' 12323123213 1231231231312)
17:22clojurebot15172614167151479645456N
17:22dmansenhm, i thought clojure automatically promoted things to bigint?
17:22dmansenah
17:22samaaronok, so why would you proxy AFn rather than IFn?
17:22kotarak,(* 12323123213 1231231231312N)
17:22clojurebot15172614167151479645456N
17:23brehautfridim_: ^ use the star prime op to have auto bignumming
17:23kotaraksamaaron: Because AFn implements stuff like applyTo, but IFn does not?
17:24cemerickdmansen, fridim_: http://dev.clojure.org/display/doc/Enhanced+Primitive+Support
17:24kotaraksamaaron: I haven't looked to close at the source of AFn. But usually stuff like this is the reason.
17:24fridim_ok, thanks
17:24cemerickactually, http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics is a better page
17:24fridim_either +M or *'
17:25samaaronkotarak: interesting, thanks. I just worry that perhaps the default implementations won't work if I don't populate the object properly or override all the fns myself
17:25kotaraksamaaron: Good question.
17:25cemericktechnomancy_: when you write "Invoke M-x clojure-jack-in from a project" does that mean "with a file in the desired project open in the current buffer"?
17:27samaarondmansen: so do i need to do anythign special to get emacs to do the right things with the ansi codes?
17:28samaarondmansen: although a bigger issue was when I switched to 1.3.4-SNAPSHOT of swank-clojure it blew up my emacs
17:28samaaron1.4.0-SNAPSHOT doesn't do that, so i'm sticking with that for the time being
17:30dmansensamaaron: did you get the clj-stacktrace changes i pushed?
17:31dmanseni had to modify that as well
17:31samaarondmansen: i'd never heard of clj-stacktrace before your tweet
17:31dmansenhaha
17:31dmansenactually, if you're just using the 1.3.x branch you shouldn't have to
17:31dmansenthe color stuff isn't merged in yet
17:32samaarondmansen: so i'm using the 1.4.x branch as 1.3.x dies spectacularly for me
17:32dmansendo you have the error?
17:32samaarondmansen: not sure where to find it. Emacs crashed.
17:32dmansenit CRASHED emacs? completely?
17:32dmansenwow
17:32samaaronyup
17:32dmanseni have not seen that one
17:33dmansenemacs 24?
17:33samaaronyup
17:33samaaroni believe it's somethign to do with my auto complete plugin
17:33samaaronit was when auto-completing a java namespace when it died
17:34dmanseninteresting
17:34dmanseni'm not sure...
17:34dmansenwere you at the repl? or a trace
17:34samaarondmansen: i was in a clojure buffer just hacking away
17:35samaaronwhat's the difference between the 1.3.x branch and 1.4.x?
17:35dmansenwhere are you seeing 1.4.x? i don't see that branch
17:35dmansenmy stuff got merged directly into 1.3.x
17:36samaaroni just specify it in my global project.clj file in ~/.cake/
17:36samaaronand pull it as a global dep
17:36samaaronit must be in a maven repo somewhere
17:36dmanseni'm a bit confused. but my stuff isn't in maven yet
17:36dmansenso it's not me
17:37samaaron:-)
17:37samaaroni think all this swank/slime/emacs stuff is just fragile magic
17:37dmansentechnomancy_ said he might try to do a release later this week possibly
17:37dmansenoh man, try messing with the debugger. it's such a strange, meta experience
17:37dmansenthe debugger breaks, and...you can't debug it, cause you broke it
17:37samaaronhaha
17:38dmansenit was a bit painful
17:38samaaroni think i need to switch to lein to get the debugger working properly
17:38dmansenahhh yeah i'm using lein
17:38dmansenhaven't tried cake yet
17:38samaarondon't bother - lein is the future
17:45amalloyyeah, there was a mailing-list thread some time ago about having a defrecord implement IFn by delegating to one of its fields
17:45accelgood morning ladies and gentlemen
17:46accelit's now ~ 3pm and I start coding again
17:46accelclojure is a language, where I can spend 10 hours writing 95 lines of code
17:46accelyet feel it was completely productive for a day's worth of work. :-)
17:47dmanseni spent ALL DAY doing the same thing
17:47dmansenmodify 4 lines, change a ton of stuff - i love it
17:48accelProgramming in Clojure is like modifying DNA. Change 1% of the code, and one jump from monkey to ape.
17:48duck1123it's always so sad, because when you're done hacking on something in clojure, you're left with a handful of functions that are so basic and straightforward that you're left wondering what you did all day.
17:49samaaronamalloy: yeah, i have a version of defrecord which implements *some* of IFn, although I can't get 20+ args to use apply automatically
17:49accelThis is proof that P != NP. It takes exponential work to output a polynomial size program.
17:49dmanseni have to go to work tomorrow and write PHP
17:49dmansenthat's the real sadness
17:50weavejesterI kinda find that as I become more practised at programming, the solutions I come up with become simpler, rather than more complex.
17:50dmansenabsolutely.
17:50dmansenmy usual flow is: write a bunch of code to get it working, then revisit and cut it down as much as possible
17:50dmansenit always goes along this curve
17:51amalloysamaaron: gist or something?
17:52accelholy shit
17:53accelI think I just understood how the zippers work. :-)
17:53fridim_<dmansen> i have to go to work tomorrow and write PHP
17:53samaaronamalloy: https://gist.github.com/1494730
17:53fridim_haha
17:53accelOnce you write it out as "list of" [ntype, left, node, right], ; then moving up/down the tree reallyd oes look like a zipper.
17:53dmansenfridim_: i really despise it.
17:53acceldmansen: Where do you work?
17:53dmansenwww.rjmetrics.com
17:54amalloyoh, i thought you had the macro already
17:54amalloysamaaron: you go do something more interesting, i'll sketch out the macro for you
17:55samaaronamalloy: the macro is something i could do - what i'm unable to do is to get that to work for: (def f (Foo. (fn [& args] (println "args: " args)))) (apply f [1 2 3 4 5 6 7])
17:56samaaronhold on
17:56samaaronmy example was incorrect
17:56samaaronI can't get it to work for this: (f 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22)
17:56samaaronperhaps that's a clojure error though, not a record error
17:57amalloyno, that should work
17:57samaaronalthough this doesn't work either: (apply f [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22])
17:58samaaronwhereas (apply f [1 2 3]) works if i've implemented invoke with three args
17:58weavejesterHmm, leiningen plugins only seem to work if added as a dev-dependency, not as a dependency
17:59amalloysamaaron: well your gisted implementation of applyTo is wrong
18:00amalloyor, i guess it might work as-is. but (applyTo impl args) seems better than (applyTo this args)
18:01amalloyyeah, and that fix makes it work, when i try it
18:02samaaronamalloy: ahh, that's just me being silly
18:03weavejestertechnomancy_: Is it deliberate that lein plugins only work when included in dev-dependencies?
18:05samaaronamalloy: so taht fixes it for applying to a large list of params, but not for (f 1 2 3 .. 22)
18:07samaaroni guess that's just something clojure doesn't allow
18:07amalloysamaaron: but it does, because you can call + that way
18:07amalloyoh, that might just be because + gets inlined. let me check
18:08amalloy&(let [p +] (p 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24))
18:08lazybot⇒ 300
18:08samaaronamalloy: it gets reduced down
18:08samaaronbut the sig is [x y & more] so clojure must be doing somethign to map the long param list to that impl
18:09amalloysamaaron: well, of course that's the implementation of + once it receives a bunch of args. but the difficulty you're having is in getting your function to receive a bunch of args to begin with
18:09samaaronexactly
18:10amalloysamaaron: oh, i think i see what's going on
18:10samaaronso (defn bar [& more] (println more)) works as expected
18:10amalloysamaaron: look at the IFn interface
18:11samaaron Object... args)
18:11samaaronis it something to do with that?
18:11amalloyyes
18:11samaaronwhat does that mean?
18:12amalloywell, the relevant part is that if you pass it 21+ args, then applyToHelper will call that version, passing it the first 20 args explicitly and then an array of the rest of the args
18:12amalloyand since you didn't implement that...
18:12amalloyor rather, not applyToHelper
18:13amalloybut rt, or the compiler, or someone
18:13samaaroni don't really get how this applies to applyToHelper
18:13samaaronah ok
18:14amalloyso you need to emit another body that takes 21 args and forwards all those to the impl
18:15samaaronamalloy: so that totally works
18:15samaaronalthough i still don't quite see why
18:15samaaronwhat does Object... mean?
18:16amalloyit's silly jvm lingo for Object[]
18:16samaaronah ok
18:16amalloyjava lingo, i guess. at the bytecode level it's an Object[], but calling it Object... instead lets java programmers pretend it takes varargs
18:16samaaronhahaha
19:08mbacAWESOME
19:08mbacPLEAC accepted our clojure submission
19:08mbachttp://pleac.sourceforge.net/pleac_clojure/index.html
19:09mbac15.29% complete, already ahead of C, forth, R, factor, smalltalk, obj-c, and go
19:09mbaci'm coordinating development at my github https://github.com/mbacarella/pleac-clojure
19:10mbacit's easier than trying to send piecemeal submissions to the pleac people
19:10mbacfeel free to fork it if you want, but i'm happy to just throw you commit access and do the work of merging it into PLEAC
19:12accel#_ is so cool.
19:13accelit's especially cool in situations where ; would not work, since on the given line, the number of ()'s are not balanced; but #_ just knocks out the next sexp
19:16accelwhat is the right pattern/macro in clojure to use to dispatch on tagged lists or def-types ?
19:17brehautaccel: if you need both? multimethods ?
19:28ibdknoxI'm seeing very strange behavior with UTF8: when I set an atom to a unicode char in the repl, and have it print inside of a ring handler, it prints the char as ?
19:28ibdknoxany thoughts?
19:29ibdknoxif I simply print it at the repl (not in the context of ring) it prints correctly.
19:29jkkrameribdknox: printing to where? the repl or to a webpage?
19:29ibdknoxeither
19:30mindbenderhow to I exit clojure repl in emacs without errors
19:30jkkrameryou using embedded jetty?
19:30mindbender*do
19:30ibdknoxjkkramer: yes
19:30ibdknoxjkkramer: headers are correctly set
19:30jkkrameribdknox: including charset=utf8 in content-type?
19:30ibdknoxyes
19:30ibdknoxit actually prints the value to the console wrong
19:30jkkramer(in actual http header, not in html)
19:31jkkramerhmm
19:31ibdknoxwhich indicates to me that there's some sort of java-level thread setting that is screwed up in the context of jetty
19:33jkkramerI had trouble getting jetty to output using the right charset, which I solved with a middleware hack. not sure if it would help in your case, though
19:35jweisshow do I do set! on my own vars in the repl? Seems to only work within a binding form. is there another way to change a thread-local value permanently?
19:36cemerickibdknox: Make sure your jvm has UTF8 set as its default encoding.
19:36ibdknoxcemerick: how do I do that?
19:36duck1123jweiss: if you're just playing around in the repl, why not just re-def them
19:36brehautyay default encodings :(
19:37ibdknoxthe thing that's weird though
19:37ibdknoxis that in the same repl that is running the jetty instance, it works
19:37cemerickibdknox: either make sure your OS has it set as its default (either via LANG or LOCALE or something), or make sure the JVM is started with -Dfile.encoding=UTF-8
19:37jweissduck1123: ultimately it's going to be multithreaded, so it won't just be done in the repl
19:38duck1123jweiss: alter-var-root, but if you know you're going to be updating this value, why not use a reference type
19:39jweissalter-var-root and atoms, etc are not thread-local. i want a thread-local value
19:39jweissi just want to set it permanently, not just within a binding form
19:41jweissat the repl, i don't want to recalculate the value every time i send an expression to be read
19:44ibdknoxweavejester: ping?
19:45gtrak_mjweiss, if it's threadlocal it's not permanent. That doesn't make sense
19:48duck1123gtrak_m: I think he means for the life of the thread
19:48jweissgtrak_m: (set! *print-meta* true) for all practical purposes, that is permanent
19:48jweissjust asking if i can get similar behavior in the repl with my own vars
19:48duck1123but that's not thread local, which is the big difference
19:49jweisssounds like the answer is no
19:49jweissduck1123: i believe it is
19:49jweissyou can't call set! unless it's already thread local
19:49jweissat least, it doesn't work for me unless it's within a binding form
19:50jweissi assumed *print-meta* must be in a binding form in which the entire repl runs
19:50gtrak_mBut the thread goes back in a pool most likely. Seems like unintended behavior could happen
19:50jweissthe repl is multithreaded? didn't know that
19:51gtrak_mYou don't need to set! if you're binding already
19:51jweissgtrak_m: i know that
19:52gtrak_mJust make the var dynamic
19:52jweissi just want to permanently change a thread-local value until either i change it again or the thread ends
19:53jweissactually i'd be happy just to set a thread local value the shadows the root binding, permanently, in the repl
19:53jweissi know that's not necessary for the repl
19:54gtrak_mWhy not just def?
19:54jweissbut it is for my runtime code, and i'd like to test the code in the repl that i'm actually going to use
19:54jweissi guess i can use 2 different forms - binding for running my program and def at the repl
19:54jweissbut i was hoping there was one waya that would work in both places
19:54samaaroncemerick: for the children: https://gist.github.com/1494980
19:56gtrak_mJweiss just split the function into one that does the binding and an internal version?
19:57cemericksamaaron: hah; I'll have to say that that one's "complected" ;-)
19:57samaaroncemerick: for sure, I never claimed to be a macro whizz
19:57jweissgtrak_m: ok, i thought there might be a straightforward way
19:58gtrak_mYou know how lots of fns in core have fn* versions
19:58samaaroni'd happily take any advice in simplifying it
19:58samaaroni tried pulling out some of the fns into the letfn bindings
20:00cemericksamaaron: so that knocks out the record as a lookup fn; is that intentional?
20:00samaaroncemerick: what do you mean "knocks out"?
20:01samaaronah, you mean clobbers the original behaviour?
20:01cemerickright
20:01samaaronyeah, totally - the old behaviour is boring - we need new spice!
20:02samaaronwell, these things are meant to be used as fns first and maps second
20:02cemerickOK, I see what you're aiming at then
20:02cemerickThe function you pass to CallableMap. should implement all the arities you care about.
20:02samaaroncemerick: exactly, and we don't know that ahead of time
20:02samaaronperhaps this is the wrong kind of datastructure
20:03samaaronbut in overtone we already use something like this quite a bit
20:03samaaronperhaps the map should just be metadata...
20:03samaaronand the fn just be a pure fn
20:05cemerickMaybe, hard to say without knowing the usage.
20:06samaaronfor example, when you create a synth, we return a map which contains all the info for that synth, and the map also serves as a fn to trigger the synth
20:06samaaronrather than having to pass it to a trigger fn
20:07samaaronwhich feels pretty good from a user perspective
20:07cemerickHow often is the data in the map accessed? And, does it ever figure into equality comparisons or used in a map?
20:08samaaroncurrently rarely accessed
20:08samaaronand never used in equality comparisons or used as keys in a map
20:11cemerickSo, I'd say metadata on a function *sounds* reasonable. You have to think about whether that is semantically appropriate though.
20:12samaaronwhen might our unwieldy callable-map approach seam appropriate to you?
20:12samaarons/seam/seem/
20:12cemerickmeh
20:12samaaronb
20:12cemerickI've gone down that road and been burned in various circumstances.
20:13samaarondo you have any handy blog post brimming with wisdom gained from such circumstances?
20:13cemericke.g. passing the fn/map around generically, getting odd results, and it being tough to track down why (was trying to use it as a function or a map when the "wrong" implementation was primary)
20:14cemerickheh, no
20:14samaaronyeah, that's a good point
20:14cemerickIf you *can* characterize the synths as functions with some metadata, that certainly seems cleaner on all fronts. *shrug*
20:15samaaronyeah, that's definitely worth considering prior to 1.0
20:15samaaronmight involve some gutting out
20:15samaaronwhich is always a good thing (generally)
20:17cemerickIn that case, you really do want a lower-level macro that emits a reify for each synth.
20:18cemerick(or a deftype if the synths are top-level forms)
20:20samaaroncemerick: can you expand on your reify example?
20:25cemericksamaaron: I'll see if I can put together a macro in a bit.
20:25samaaroncemerick: that would be lovely
20:25samaaroni'm going to bed now though :-)
20:27cemericksamaaron: feel free to bug me tomorrow if I haven't gotten to it yet :-)
20:27samaaroncemerick: will do :-)
20:28technomancy_cemerick: that's right re: clojure-jack-in from "inside the project"
20:28cemericktechnomancy_: thanks :-)
20:28cemericktechnomancy_: dumped the apropos thing for an inspector demo BTW
20:29technomancy_sounds good
20:30technomancy_weavejester: that's right re: dev-deps and plugins. it will probably change in 2.0 to make plugins distinct from dev-deps though
20:33xrlI'm using noir to build an application and one important dependency appears to be incomplete. the hiccup.form-helpers is missing. when I do an "ls" on classes/hiccup there is no reference to "form_helpers"
20:33xrlany ideas?
20:34xrlI'm using an up to date hiccup
20:34ibdknoxxrl: what happens when you try to require it?
20:41xrlibdknox: so from the repl I'm trying (use 'hiccup.form-builder) and I get a FileNotFound exception
20:41ibdknoxform-builder?
20:41xrlerr
20:42xrlI was trying form-helper earlier... it has an S
20:42ibdknox:)
20:42xrlthanks for the help :)
20:49cemericktechnomancy_: re: lein deps being invoked automatically — when was that added?
20:49cemerickthat doesn't appear to be true, at least for getting a repl on a new project…
20:51ttaxusHow does "contains?" work? (contains? '("jhbadger") "jhbadger") returns false, so I obviously am using it wrong
20:51TimMcttaxus: indeed
20:51ibdknox,(doc contains?)
20:51clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
20:51TimMcclojurebot: contains?
20:51clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
20:51ibdknoxor filter
20:52ttaxusthanks!
20:53TimMcttaxus: It's a poorly-named function.
20:56quizmehow do you get a subset of k-v pairs from a hashmap given a vector of keys ?
20:58quizmeselect-keys
20:58quizmenm
20:59weavejestertechnomancy_: Ah, okay. So currently, if one is using lein to manage a production deployment (as with Heroku), you can't use plugins.
21:00weavejestertechnomancy_: So how far is Leiningen 2.0 off? :)
21:06technomancy_weavejester: are you thinking of lein ring?
21:06weavejestertechnomancy_: Yup
21:07weavejestertechnomancy_: I was thinking I could make "lein ring server" act as a production server as well as a dev server.
21:08technomancy_weavejester: better to use "lein run" or "lein trampoline run" although there is a workaround
21:08weavejestertechnomancy_: Hmm, well, if I use "lein ring server" then I don't have to bother setting up an adapter
21:08technomancy_cemerick: an empty lib/ dir has triggered deps for quite some time, but having a simple change to the :dependencies vector trigger deps is new in 1.6.2
21:09technomancy_weavejester: because it bundles jetty for you?
21:10weavejestertechnomancy_: Yes, and because I don't have to write something like: (run-jetty app {:port (Integer. (System/getenv "PORT"))}) etc.
21:10technomancy_it's only a couple lines to handle jetty yourself; I think there are benefits to being explicit
21:10weavejesterBut "lein ring server" is pretty explicit too
21:10weavejesterAnd I'd rather specify my handler in one place, the project.clj file, than two
21:11technomancy_weavejester: I need to take off; happy to discuss it further tomorrow
21:11weavejesterIt feels like I'm duplicating logic that could be in a standard library.
21:11weavejestertechnomancy_: No problem :)
21:36technomancy_the tl;dr is that the idea of using leiningen in production is very new (~6 months) and that a lot of the design of plugins and such reflect the idea that it's a tool only used in development
22:04tmciverWhere can I find the JavaDocs or source for clojure.lang?
22:05brehauttmciver: https://github.com/clojure/clojure/blob/master/src/
22:06tmciverThanks brehaut
22:27TimMcYou're not going to find javadocs, though -- Clojure/Core is allergic to docs or something.
22:57simardhum wasn't it possible with clojure 1.3 to use a record's constructor as a function ? say, in a map.
22:58simard(map my-record a-list)
23:00brehautsimard: map->recordname
23:00brehautithink
23:00brehautsimard: its not the constructor anyway, its an autogenerated function
23:01brehautsimard: http://dev.clojure.org/display/design/defrecord+improvements is perhaps a good place to look?
23:05simardsounds good, thank you
23:07simardperhaps I should be using maps and multimethods for now..
23:08simardhum. no. ok this works now.