#clojure logs

2011-05-03

02:53matthias__there's a java method that expects "Trigger..." and i want to pass it two new instances of classes that implement trigger. (keytrigger and mousebuttontrigger). how do i do that?
02:54matthias__i had to use (into-array (...stuff that makes a new keytrigger...)) before
02:56clgvmatthias__: do you ask for the implementing part?
02:56clgvmatthias__: if so, you can do it via proxy, see http://clojure.org/java_interop#Java%20Interop-Implementing%20Interfaces%20and%20Extending%20Classes
02:57clgvmatthias_: you might also implement it via defrecord, deftype or reify
02:57matthias__no, they are already implemented
02:57matthias__im just making new instances of keytrigger and mousebuttontrigger
02:58clgvfor example?
02:59matthias__hmm, here's some of my code
02:59matthias__ (.addMapping "Pause" (into-array [(KeyTrigger. KeyInput/KEY_P)]))
02:59matthias__ (.addMapping "Left" (into-array [(KeyTrigger. KeyInput/KEY_J)]))
02:59matthias__ (.addMapping "Right" (into-array [(KeyTrigger. KeyInput/KEY_K)]))
02:59matthias__ (.addMapping "Rotate" (into-array ^Trigger [(cast ^Trigger (KeyTrigger. KeyInput/KEY_SPACE))
02:59matthias__ (cast ^Trigger (MouseButtonTrigger. MouseInput/BUTTON_LEFT))]))
02:59matthias__(im just trying to get it to work, so its probably nonsense)
03:00matthias__the first three work
03:00amalloymatthias__: the type hint on the fourth is nonsense
03:00amalloydrop the ^ and you'll be fine
03:00amalloy&(into-array Object ["string" 'symbol])
03:00sexpbot⟹ #<Object[] [Ljava.lang.Object;@1b15d6a>
03:01amalloy&(into-array ^Object ["string" 'symbol])
03:01sexpbotjava.lang.IllegalArgumentException: array element type mismatch
03:01matthias__oh
03:01matthias__i thought that's how you used types in clojure :S
03:01matthias__thanks
03:02clgvamalloy: is cast really necessary or just to get a fail-fast behavior?
03:02amalloymatthias__: Object is a symbol which maps to java's Object.class
03:02amalloyclgv: not the latter, i hope, since i don't think it does that
03:02amalloy~source cast
03:03clgvamalloy: it throw an exception if the type does not match - that was what I meant with "fail-fast" ;)
03:03amalloyoh, i had it backwards
03:03amalloytbh the cast expression always confuses me
03:03matthias__cast wasnt necessary. just something i tried randomly which didnt help
03:04amalloyanyway it's not necessary for him, for functionality or for fail-fast-ness. if you put something that's not a Trigger into a Trigger[] it bombs out
03:04clgvlol the code does indeed. java has a method called "cast"? or is it a special symbol from clojure?
03:04clgvamalloy: ok thats what I thought as well ;)
03:05amalloyclgv: java has one
03:05clgvamalloy: I only knew the operator
03:05amalloyclgv: java has a whole raft of reflection stuff
03:06amalloy&(let [the-class String the-obj 'a-symbol] (.cast the-Class the-obj))
03:06sexpbotjava.lang.Exception: Unable to resolve symbol: the-Class in this context
03:06clgvah. you are right. it's called on the class and not the object. now it does make sense
03:06amalloy&(let [the-class String the-obj 'a-symbol] (.cast the-class the-obj))
03:06sexpbotjava.lang.ClassCastException: Cannot cast clojure.lang.Symbol to java.lang.String
03:17matthias__soo... how do i access the fields of a java class? i'm within one if its methods. there's a field called speed in that class. there is no getSpeed method
03:18amalloyit's a long shot, but have you tried (.speed the-object)? also, i don't understand what you mean by "i'm within one of its methods"
03:23matthias__well, turns out im actually not ;)
03:24matthias__i'm trying to translate thise java code http://jmonkeyengine.org/wiki/doku.php/jme3:beginner:hello_input_system to clojure. and there are two anonymous classes made, one of them uses speed in onAnalog which is a field of simpleapplication
03:24matthias__i just used (def bla (proxy.....)) to make those listeners
03:25matthias__now i dont know how to access speed
03:31amalloyaugh
03:32amalloydo not attempt a literal translation from java. you'll only bring pain to yourself and everyone around you
03:35amalloyanyway, judging from the quality of HelloInput, i imagine SimpleApplication.speed is protected, in which case you can't access them from a proxy
03:35amalloybut it should be possible from a reify? i'm not sure, i don't deal with this nonsense
03:38raek,(doc proxy)
03:38clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, mus...
03:38amalloyraek: http://gist.github.com/952956
03:39raekmatthias__: I found this thread and it seems that it is not possible from clojure using proxy: http://groups.google.com/group/clojure/browse_thread/thread/41f52d8eec812b04
03:40raek"As it says in the docs for proxy, you can't access protected members
03:40raekfrom a proxy. "
03:40raek"You best bet is to create a stub class in Java that derives from SimpleGame and exposes any protected members you want to access via public methods. Then in Clojure proxy that stub."
03:41raekseems to be a limitation of the proxy feature in java
03:43raekmatthias__: with leiningen, it's quite simple to have java source code in the project. just add :java-source-path "src" to the project.clj and do a lein javac to compile the java sources before you start
04:14solar_seaHi. Can the reader be made to cache & reuse functions with equal definitions ?
04:18solar_seaFrom the repl executing (fn [_] nil) twice gives me two separate function objects, is there a ready-made functionality to cache them, to put my question otherwise :)
04:23ejacksonsolar_sea: (defn my-function [_] nil) will store that function in my-function
04:23ejacksonits shorthand for (def my-function (fn [_] nil))
04:29solar_seaejackson: I know that, I was just thinking of dynamicaly defining functions on the fly and to reuse the ones already defined.
04:30ejacksonok
04:30solar_seaFrom what I understand with my limited clojure exposure, a macro can work here, comparing the form with some previously defined, returning the already defined one if it exists, or passing it to the compiler and caching it if it doesn't ?
05:10julian37hi, I'm trying to find instructions on how to setup clojure in emacs. the ones I found are a few years old and I'm not sure they're applicable anymore. any pointers?
05:10julian37fwiw I'm a clojure newbie but I know my way around emacs pretty well
05:11julian37I'm after slime/swank setup specifically
05:12raekjulian37: It's more simple nowadays. these instructions are up to date: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
05:12julian37perfect, thanks raek!
05:13raekbasically, the steps are 1) make sure you have package.el 2) make sure you use the Marmalade repo 3) install clojure-mode, slime and slime-repl using M-x package-list-packages
05:13raekand then you use swank-clojure in your leiningen or cake project
05:15raekjulian37: I have recently updated these instructions, so I'm happy for any feedback (e.g. if something is not clear or does not work)
05:17julian37raek: I'll let you know if I notice anything missing, thanks again
05:22julian37raek: maybe the most important thing would be to get this page on the first page of google results for queries like "clojure emacs" or "clojure slime"
05:23julian37I'm not much of an SEO guy so no idea really why it doesn't turn up. maybe putting the words "clojure" and "emacs" closer together in the title would help?
05:23Fossiwaiting and getting linked helps
05:24julian37right now the first result for "clojure emacs" is http://clojure.org/getting_started , maybe a link could be added to that page?
05:35solar_seaHow can I call def with a dynamic name ? For example (defn mydef [name args] (def (symbol name) args)) says java.lang.Exception: First argument to def must be a Symbol (NO_SOURCE_FILE:0)
05:38raeksolar_sea: can you explain what problem you are trying to solve with this?
05:38raek(def is a special form, that's why the first argument does not follow usual evaluation rules)
05:40solar_seaI'm trying to implemented something to cache function definitions-objects pairs, so (my-def f1 (fn [] nil) and (my-def f2 (fn [] nil)) - f1 an f2 will point to the same function object
05:41solar_seaso far I've come up with this: http://pastebin.com/dMQggELk but it's not exactly working yet
05:42raekso you're trying to extend the Clojure language with some caching functionality?
05:43solar_seaprecisesly ;)
05:43raekif you are in control of the code, you could always do (let [f (fn [] nil)] ...)
05:44raekso how will this be used?
05:44solar_seathe code is going to be dynamically generated, from some written conditions/rules. I know I can cache the values there, but doing it on the clojure side seemed more interesting and more general :)
05:45raeksolar_sea: my-def needs to be a macro if you want to override normal evaluation rules
05:45solar_seajust as it is in my code, a closure closing over a defmacro
05:46raeksolar_sea: you need to deref the atom before you send it to contains?
05:47raeksolar_sea: and I think you're confusing macro expand time and runtime
05:48solar_searaek: thanks, the atom deref was the problem, it's working as intended now :D
05:49solar_seahell, I didn't know that contains? is implemented over atoms ..
05:55raekfwiw, I would probably solve the problem something like this:
05:55raekanalyze the rules and collect those that are unique
05:55raekgive each unique rule a name using gensym and construct a map from rules to names of the unique rules
05:56raekand generate a defn for each unique rule
05:56raekgenerate the code that uses the rules and where a rule is referenced use the name of the unique rule instead
05:56raekas you probably can tell, I'm not much for "magic"... :-)
05:58no_mindhow do I calculate the current timestamp in clojure ?
05:59solar_seano_mind: (System/currentTimeMillis)
05:59solar_searaek: yes, but I'm still euphoric about clojure's flexibility and I'm going to probably abuse it for some time :)
06:13no_mindhow do I get today's date in dd/mm/yyyy format ?
06:14ejacksonno_mind: check out the clj_time library in the getwoven repo on GitHub
06:15ejacksoni think it has a (today) or (now)
06:15fliebelejackson: Is that the Yoda wrapper?
06:15ejacksonyeah
06:25no_mindejackson: clj-time has formatters for date tiem but ot generators
06:25ejacksonno_mind: 1 sec...
06:26ejacksonline 77 of core.clj defines the now function
06:26ejacksonhttps://github.com/getwoven/clj-time/blob/master/src/clj_time/core.clj#L77
06:27ejacksonif you pass that through a formatter for your desired format you'll get what you want
06:28ejacksonso (unparse my-formatter (now))
06:53fortxun$seen rhickey
06:53sexpbotrhickey was last seen quitting 3 days and 15 hours ago.
08:46clgvI want to render a big matrix in a swing window with each entry represented as a square with a truncated number and a color from the "interval" white to red. is there anything in clojure or java that might help me with that or do I have to do it completely from scratch?
08:50clgvfrom scratch means using JTable and implementing custom renderers...
08:51fliebelclgv: Seesaw maybe? Or Incanter?
08:53clgvincanter can display it's own matrices as far as I saw. have to lookup seesaw
08:54fliebelclgv: How are its own matrices any greener than yours?
08:54clgvI didn't check ;) but I dont think it is able to do the color thing ;)
08:55fliebelI think it is.
08:56ejacksonclgv: there's a java matrix lib that does this....
08:56clgvejackson: interesting. which?
08:56ejacksonBradford Cross referenced it when he compared the various java mtarix libraries in he blog
08:56ejacksontrying to remember...
08:57ejacksonhttp://measuringmeasures.com/blog/2010/3/28/matrix-benchmarks-fast-linear-algebra-on-the-jvm.html
08:58ejacksonthere: http://www.ujmp.org/
08:59fliebelAH, colt is the one used by incanter.
08:59clgvyep. colt it is
09:00fliebelSo according to their home page, you could use ujmp to visualize a Incanter matrix
09:00fliebel… maybe
09:01solar_seaWhat's the proper meaning of "Can't eval locals" in clojure ? :)
09:01fliebelsolar_sea: Where are you seeing that?
09:02fliebel&(let [x 1] (eval '(+ x 1)))
09:02sexpbotjava.lang.SecurityException: You tripped the alarm! eval is bad!
09:02solar_seaIn a rather weird macro scenario, I've sent a mail to the ML about it
09:03solar_seawhen I call a defmacro from the body of another defmacro
09:03fliebelsolar_sea: Probably something about quoting then.
09:03fliebeloh...
09:04solar_seaI can see that those errors are thrown from LocalBindingExpr java class in the compiler.java, but I haven't made a deep inspection about it yet
09:16clgvejackson: ok, I am working on a UJMP solution. looks promising. thx!
09:17ejacksonnp, just remembered the 'predator view' matrices from that blog post ;)
09:17clgvjust their documentation is a bit like some of the matrices they support - sparse ;(
09:18ejackson;)
09:18clgvmaybe I find something in the forum
09:18clgvto get started faster
09:37clgvok. It's easier to get to see something that I thought: (doto (DefaultDenseDoubleMatrix2D. 120, 120) (.showGUI))
09:37ejacksonthat's cute
09:38clgvnow I only need to set the data and try to findout how to influence the displayed colors
09:52dpritchettevery time i update coffeescript it shadows my "cake" executable and then i have to go rename the new one to coffee-cake to fix it. anyone else deal with this regularly?
10:26clgvejackson: hmm standard colors seem to be black to green...
10:26ejacksonold skool
10:36clgvlol yeah
11:14semperostrying out congomongo, using 0.1.3-SNAPSHOT off Clojars; I see functions in the source "make-connection", "with-mongo" and several others in the congomongo namespace that I don't have access to
11:14semperoswhile working in slime/swank at the REPL
11:14semperosanyone else experience these issues?
12:06semperosfigured it out; incanter was pulling in old versions of congomongo and the database driver for mongodb...
12:10ejacksonnaughty Incanter !
12:10semperos:)
12:10semperosnah, naughty me for not paying attention to the granular jar files David provides for the different parts of incanter
12:12semperosactually forced me to start using the latest version of congomongo and the db driver, and it performs a lot better (getting the count for 800,000 records is instanteous, instead of taking up to a minute)
12:41ejacksonthat is fast
12:49dnolenwow this is hilarious, http://bugs.sun.com/view_bug.do?bug_id=4262078
12:49dnolen10 years of people complaining.
12:51amalloydnolen: if i were getting complaints with such atrocious grammar and spelling, i'd wait ten years too
12:51clgvcan't incanter.core/dataset handle lazyseqs?
12:53ejackson_Check it out: Chas's ClojureAtlas just got released: http://cemerick.com/2011/05/03/clojure-atlas-now-available/
13:09choffsteinIf I have two lists, one representing keys and one representing vals, is there an function to create a hash-map from them? I could theoretically do a reduce after doing something like (map vector list-one list-two) -- but I was wondering if there was already something built in that I am missing
13:09amalloyzipmap
13:09KirinDavechoffstein: zipmap
13:09KirinDaveshit
13:10dakrone,(zipmap [:a :b :c] [1 2 3])
13:10clojurebot{:c 3, :b 2, :a 1}
13:10KirinDavecome on amalloy you can't go cutting corners. ;)
13:10amalloyKirinDave: where do i go for my ninja badge?
13:10choffsteinvunderful!
13:10choffsteinThanks ever so much
13:12ejacksonredis is freaking amazing
13:13semperosejackson: what are you using it for specifically?
13:14ejacksonsemperos: as a silly fast store of data.
13:14choffsteinwhat is a sorted-map?
13:15ejacksoni'm using its native datastructures
13:15ejacksonchoffstein: a map which is sorted by its keys
13:15semperoschoffstein: maps by default are not sorted, i.e. the keys aren't in order
13:15choffsteinso when you pull the keys, they are sorted?
13:15choffsteinBy the order you insert them in? Or can you provide a sort method?
13:15semperoswhat do you mean by "pull"?
13:16choffsteine.g. (keys map)
13:16semperos,(hash-map :a "foo" :b "woops" :c "bar")
13:16clojurebot{:a "foo", :c "bar", :b "woops"}
13:16ejacksonchoffstein: when you assoc new key-vals, the datastructure retains its order
13:16semperos,(keys (hash-map :a "foo" :b "woops" :c "bar"))
13:16clojurebot(:a :c :b)
13:17semperos,(sorted-map :a "foo" :b "woops" :c "bar")
13:17clojurebot{:a "foo", :b "woops", :c "bar"}
13:17semperos,(keys (sorted-map :a "foo" :b "woops" :c "bar"))
13:17clojurebot(:a :b :c)
13:18choffstein,(assoc (sorted-map :a "foo" :b "whoops" :d "bar") :c "test")
13:18clojurebot{:a "foo", :b "whoops", :c "test", :d "bar"}
13:18choffstein,(keys (assoc (sorted-map :a "foo" :b "whoops" :d "bar") "test"))
13:18clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$assoc
13:18choffstein,(keys (assoc (sorted-map :a "foo" :b "whoops" :d "bar") :c "test"))
13:18clojurebot(:a :b :c :d)
13:18choffsteinhmm, interesting.
13:18TristamOooh...that bot is neat
13:19semperossexpbot is very nice as well
13:19semperoswith lots o' features
13:19semperosmy favorite is find-fn
13:19miner49ruse array-map if you want the insertion order; sorted-map maintains the sorted order (not necessarily the insertion (time) order)
13:19TristamI'm brand new to clojure, so I dunno what you're talking about...haha
13:21TristamSo far all I've done in clojure is hello world. Hehe
13:22semperosthen everyone envies you your first dive into Clojure :)
13:22choffsteinminer49r: but by what definition of 'order' ?
13:22TristamHaha
13:22TristamI did a bit of Common Lisp in several AI classes in college. Never could find an outlet for my fondness for lisp. Clojure might just be that outlet.
13:24miner49rchoffstein: the insertion order is the order defined by the call to array-map. assoc will add the key as first in order.
13:24miner49r,(array-map :a 1 :b 2)
13:24clojurebot{:a 1, :b 2}
13:24jarpiain,(sorted-map [2 2] :a, [1 2] :b, [2 1] :c)
13:24clojurebot{[1 2] :b, [2 1] :c, [2 2] :a}
13:24choffsteinminer49r: I mean for sorted-map
13:24ataggartminer49r: not true once the map size > 8
13:24ataggartminer49r: assoc an array-map with 8 entries and you'll get back a hash-map
13:25semperosTristam: you can message sexpbot privately and play around
13:25jarpiain,(sorted-map-by > 1 :a, 2 :b, 3 :c)
13:25clojurebot{3 :c, 2 :b, 1 :a}
13:25miner49rattagart: I think array-map itself will keep the order, but assoc will give you the hash-map when things get too big to be efficient (not sure it's 8 or 10 elements)
13:25semperosbut the findfn lets you say "given an input and an output, show me which function(s) can perform this change"
13:25ataggartminer49r: correct
13:25semperos$findfn "foo" "FOO"
13:26sexpbot[clojure.string/upper-case clojure.contrib.string/swap-case clojure.contrib.string/upper-case]
13:26Tristamsemperos, that almost sounds dirty...haha
13:26semperosit's pretty useful if both the name of a function or even a related word escape you, so you need smth beyond docs
13:27TristamThat's sweet
13:27miner49rBy the way, array-map is only a good idea for small maps since the search is linear. That's why assoc doesn't return an array-map when it gets too big.
13:27TristamI need a bot like that for everyday conversation when I forget stuff!
13:27semperosheh
13:27semperosthe code is hosted on github: https://github.com/Raynes/sexpbot
13:28TristamWhat's it written in?
13:28semperosoops
13:28semperoswrong repo
13:28semperosTristam: I'll give you two guesses
13:28semperos:)
13:28TristamHaha
13:28semperoshttp://github.com/cognitivedissonance/sexpbot is the right repo
13:28Tristamclojure?
13:28clojurebot"[Clojure ...] feels like a general-purpose language beamed back from the near future."
13:28semperosyes
13:28semperoslook at the repo, the *.clj files are all Clojure source files
13:28TristamWoo! I only needed one guess!
13:28semperos:)
13:29semperosTristam: where are you coming from, in terms of current programming language(s)?
13:29semperos(always curious how/why folks come to Clojure)
13:30TristamI've got a ridiculous mixture of languages gleaned from two CS degrees worth of education, c++, Java, and Common Lisp are the ones I know best.
13:30TristamSomeone mentioned clojure to me when we were jabbering about lisp
13:31TristamSo I checked it out
13:31semperosgotcha
13:31TristamI've got a potential job opportunity that involves some amount of java...so maybe I can lispify it and make it work better.
13:32semperos"it's just a jar, boss"
13:33TristamBeyond that, I like programming languages, so I look into them just for kicks when one interests me.
13:33semperos:)
13:35amalloysemperos: findfn has a newish feature, btw
13:35semperosamalloy: oui?
13:35amalloy$findarg map % [1 2 3] [2 3 4]
13:35sexpbot[clojure.core/unchecked-inc clojure.core/inc]
13:36semperosI like it!
13:36semperos$findfn [1 2 3] [2 4 6]
13:36sexpbot[]
13:36semperoswhat am I missing there, amalloy?
13:36semperosoh, nm
13:36amalloyum, there's no "double this" function in the core libs
13:37TristamYou'd need apply or mapcar or something that that wouldn't you?
13:37amalloy$findfn #(* 2 %) [1 2 3] [2 4 6]
13:37sexpbot[clojure.core/map clojure.core/keep]
13:37semperos,(map #(* 2 %) [1 2 3])
13:37clojurebot(2 4 6)
13:37TristamThere ya go
13:38semperosI have a habit of asking obviously stupid quesitons
13:38amalloylike what? (har har, get it? what a stupid question)
13:38semperos:)
13:38semperoskeeps me in my place
13:38TristamWe all have random brain shutdowns
13:39TristamSome of us more often than others.
13:39semperos,(let [times-2 (partial * 2)] (map times-2 [1 2 3]))
13:39clojurebot(2 4 6)
13:39TristamWhat were we talking about again?
13:39semperosexample of currying, if I'm not mixing up my terms
13:39TristamIs [] shorthand for a lambda?>
13:39amalloyTristam: anyway, clojure uses a more abstract notion of "sequences" rather than car/cdr cells, so we don't really have/need the million different mapcar/mapcan/mapcdr functions. just map
13:40amalloyTristam: no, it's a literal vector
13:40amalloy#() is shorthand for a lambda
13:40semperoswith % as the implicit param
13:40TristamI remember going insane with the car/cdr stuff
13:40ataggart% == %1
13:41amalloyto be fair, we do have mapcat, which is basically just (apply concat (map ...))
13:42semperosTristam: when I started, I got a couple of the books and went from books to Rich Hickey's videos on Blip.tv as my brain fried in different ways
13:43TristamI'm used to fried brains
13:43semperos:)
13:43semperosthe videos for Clojure on blip are really good, if you haven't checked them out, you should
13:43TristamThough I really like Head First books for new programming languages...that minimizes brain frying a lot of times.
13:44amalloyTristam: if you learn a new language and your brain still works, you're doing it wrong
13:44Tristamamalloy, Quite true
13:45semperosTristam: but if you already have the JVM ecosystem experience and CL, perhaps it'll just be a mild simmering...
13:47TristamFlash fry
13:51fcekthere's a core/contrib function that does this? ((fn [m] (zipmap (map keyword (keys m)) (vals m))) {"a" "b" "c" "d"})
13:51fcek,((fn [m] (zipmap (map keyword (keys m)) (vals m))) {"a" "b" "c" "d"})
13:51clojurebot{:c "d", :a "b"}
13:52fcekops, it's wrong
13:52fcekit should be {:a "b" :c "d"}
13:53ataggarthash-map isn't sorted
13:54ataggart,(reduce (fn [m [k v]] (assoc m (keyword k) v)) {"a" "b" "c" "d"})
13:54clojurebotjava.lang.IllegalArgumentException: Key must be integer
13:55dpritchettNeat, jeresig left Mozilla and now works for Khan Academy.
13:55ataggart,(reduce (fn [m [k v]] (assoc m (keyword k) v)) {} {"a" "b" "c" "d"})
13:55clojurebot{:c "d", :a "b"}
13:56fceki did read {:a "d" :c "d"}, i want to convert string keys to keywords and i thought there was a core or contrib function
13:56semperosataggart's reduce does the trick nicely
13:58fceki'll use it as a starting point to handle nested maps, thanks
14:03MayDanielfcek: There's clojure.walk/keywordize-keys.
14:06fcekMayDaniel: perfect, thanks!
14:47ordnungswidrig,(dotimes [i (range 3)] (inc i))
14:47clojurebotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Character
14:47ordnungswidrig?
14:48miner49r,(dotimes [i 3] (inc i))
14:48clojurebotnil
14:48ordnungswidrigargl
14:48ordnungswidrighowever the exception is somewhat misleading :-)
14:49miner49ryes, there's a bug somewhere collecting misleading error messages so that they can be improved
15:03edwHmm, is there a way to kill the motion-sickness inducement feature of Clojure Atlas?
15:05cemerickedw: I'm working on it :-)
15:05ataggart,(doc dotimes)
15:05clojurebot"([bindings & body]); bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1."
15:06ataggart,(dotimes [i 3] (println i))
15:06clojurebot0
15:06clojurebot1
15:06clojurebot2
15:06amalloy&(doseq [i (range 3)] (prn i))
15:06sexpbot⟹ 0 1 2 nil
15:07ataggartskinning cats is fun
15:09TristamEverytime I look into this channel, the Chevelle song "Closure" pops into my head.
15:10edwcemerick: Thanks. I think there's some interesting potential for having the atlas keep track of what you're looking at, so it can incorporate usage frequency into the way it presents modules and symbols. (Hell, it could even be collaborative. Or could look through public repos on Github and see which symbols are used in the same procedure as a given procedure.
15:10cemerickedw: actually, my quick solution will probably to make it so you can halt the visualization when you're satisfied with its arrangement. A generalized solution will probably take a couple days' work.
15:11edws/procedure./procedure.\)/
15:11sexpbot<edw> cemerick: Thanks. I think there's some interesting potential for having the atlas keep track of what you're looking at, so it can incorporate usage frequency into the way it presents modules and symbols. (Hell, it could even be collaborative. Or could look through public repos on Github and see which symbols are used in the same procedure.)as a given procedure.)
15:11edwD'oh.
15:12cemerickedw: where would the "usage frequency" come from, if not github?
15:12amalloycemerick: he suggests highlighting which ones the user looks at most often, i think
15:12edwClickstream data from your users. Most grequently-consulted...
15:12cemerickah
15:14cemerickedw: Certainly possible. As it stands right now, the atlas is entirely static (i.e. there's no server IO), but it needn't stay that way.
15:14cemerickedw: If you could drop that idea into a UserVoice thread, that'd be great. It'd be good to hear other people's perspective on that one.
15:15edwAlso, another brain fart: many procedures have resemblances e.g. ones that are suited to being used with -> vs ->> and it would be nice to know what idioms lead to most effective use of this procedure. Or usage notes a la "fewer vs. less" in a dictionary.
15:17edwThis is the sort of stuff that'll produce reams of armchair philosophizing and ui designing. I think you just need to try this stuff out and see which ideas have legs.
15:17ataggart-> is for working with a single value/object, ->> is for working with sequences of values/objects
15:18ataggartso sayeth rhickey
15:18ataggartlikewise fns that work on a single value/object take their subject as the first arg, whereas fns that work on sequences take the subject last
15:18cemerickedw: The ontology is *far* from complete. -> - suitable vs. ->> - suitable will be two distinct concept nodes that get linked up appropriately.
15:18ejacksonwhich I think is due to the convention of putting arguments to functions which are seqs at the last position
15:19cemerickYeah, those are just idioms.
15:19cemerickI've switched -> to ->> when some java method needed my single object as the last arg plenty of times.
15:20hsuhi've been getting errors like http://paste.factorcode.org/paste?id=2264 from time to time, any idea what could that be?
15:20edwCrazy idea here, but imagine this: someone can annotate the documentation and people can enable/load/whatever sets of annotations.
15:23amalloycemerick: (-> foo (.thing1 x) (.thing2 y z) (->> (.method otherObject)))?
15:23edwOh, and let people "write in the margin" and add their own notes. (But don't let it become some karma-whoring clusterfuck like Hacker News or Stackoverflow.com.)
15:24amalloyhsuh: stop making so many keywords :P
15:24ataggartcemerick: yes sometimes expediency takes backseat to semantic clarity
15:24PlertroodHow can I join two lists together?
15:24cemerickamalloy: You can do that, but just (->> foo .blah .bar (.baz arg1 arg2)) too, assuming .baz takes .bar's result last.
15:25ataggart,(doc concat)
15:25clojurebot"([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."
15:25dnolen,(concat [1 2] [3 4])
15:25clojurebot(1 2 3 4)
15:25amalloy&(into [1 2] [3 4])
15:25sexpbot⟹ [1 2 3 4]
15:25PlertroodAh lovely! Thanks been looking throguh the docs all afternoon!
15:25cemerickedw: Something like that using localStorage for personal use would be fine. I'm not at all equipped to handle what would almost surely become a clusterfuck tho. :-)
15:26amalloycemerick: sure. but there's no easy way to go from ->> to -> (anonymous function fiddling is gross), whereas going from -> to ->> is easy on a form-by-form basis
15:27dnolenPlertrood: as the documentation says, concat is lazy. amalloy suggestion is better if you want the operation to be strict and to preserve the vector type.
15:27edwcemerick: I'm done with the irritating suggestions. For now.
15:27amalloythat said, it's remarkable how rarely you actually need to concatenate lists at all
15:28cemerickedw: Please keep 'em coming. Definitely focus your fire on UserVoice though -- I'll never be able to keep track of ideas proposed in irc. ;-)
15:28PlertroodAh ok yes I think I looked at concat and saw it was lazy and it didn't do what I wanted.
15:36ordnungswidrigto improve concurrence is a datastructure like (ref {:foo-1 (ref {:a 1 :b 2}), :foo-2 (ref {:a 22 :c 5})}) better than (ref {:foo-1 {:a 1 :b2} :foo-2 {:a 22 :c 5}}) ?
15:36ordnungswidrigwhen data data at :foo-1 and :foo-2 is updated indepentently.
15:38nickikit works anyway, its kind of hard to say when what is better
15:39ordnungswidrigin the latter case the one ref will be a hotspot. I think having each value a ref itself improves on concurrency but I'm not sure.
15:39nickikit you offten update both then you would use one ref if you use them on there own most of the time you can split them
15:39nickiki think so.
15:51Tristamsemperos, you're in NoVA?
15:52semperosTristam: yes
15:52TristamI miss Cox
15:52semperosit's the best I've ever had
15:52TristamI used to live near Springfield Mall
15:52semperosgotcha
15:52semperosnice area
15:52TristamUp until mid 2009
15:53TristamYeah, we liked it...the commute into DC was crap of course.
15:53semperosof course
15:53semperosI don't work in the city
15:53TristamMy wife worked at the Navy Yard
15:53TristamSo it didn't matter if she took 395 or 495/295, it was utter crap
15:53semperosyep
15:53semperosunderstatement of the century
15:53semperos:)
15:54TristamSuper tech people work in Herndon/Reston...heh
15:54semperosseems that way
15:54TristamUnfortunately, we'll be back there in 3-5 years/.
15:55semperosbut you'll have one of hte best Clojure groups to look forward to
15:55TristamYay
15:55pjstadigi used to hate Northern Virginia...until i started working from home
15:55semperosyep
15:56TristamWe'll probably end up living in a shack somewhere when we move back...real estate is WAY lower here than down there.
15:56pjstadigmy verizon dsl contract is expiring, and i'm thinking of switching back to cox for internet
15:57pjstadigTristam: values are still a little depressed, i'd like to sell my house and move, but the prices are too low
15:57pjstadigbut relatively speaking ...
15:58Tristampjstadig, we sold our condo and bought a 4 bedroom house with 1000 more sq feet for $10k less than we sold
15:58pjstadigyeah...*sigh*...i know
15:59TristamWe bought the condo in 2001 though, so we still have some decent amount of equity.
15:59raekdnolen_: core.logic / Logos is really cool. I played around with it and used Definite Clause Grammars to parse natural language: https://gist.github.com/954080
16:02dnolen_raek: SWEEEEEEEEET
16:02dnolen_raek: seriously that's really great, any feedback?
16:02dnolen_raek: that's nice looking code.
16:03raekI'm still a newbie with this syntax for logic programming
16:04dnolen_raek: do you have a twitter handle?
16:04raek@raekmannen
16:04semperosraek: very cool indeed
16:04semperosdnolen_: worked through your brief logic-tutorial, my first experience with that type of programming
16:05semperos+1 for continuing to flesh it out as you have time :)
16:05raekI was really astonished when I learned how natural these things are in logic programming
16:05dnolen_semperos: yes it needs a lot of work.
16:05Tristamlogic programming gives me scary flashbacks to prolog...
16:05semperosdnolen_: that's ok, it got me going
16:05semperosdnolen_: you've done great work
16:06dnolen_semeperos: thx!
16:06raekdnolen_: when I have gotten myself more familiar with core.logic, I was thinking about writing macros for the more compact DCG syntax
16:07raekdnolen_: do you know any syntax guide for miniKanren for those who are used to prolog?
16:07raekbut I guess the books you mentioned contains it all...
16:07dnolen_raek: yes, The Reasoned Schemer and Byrd's thesis are really the two main references.
16:08dnolen_raek: the defne syntax is my own design, based on their more Scheme-ish syntax for that, glad you ran w/ that.
16:09raekit would be nice to have a small reference that explains what kinds of expressions there are and "what can be put where"
16:09dnolen_raek: like a quick reference or something? might make sense for a wiki.
16:09raekthe first form of each defne clause should unify with the arguments, right?
16:09raekyeah
16:10raekdefinitely
16:10dnolen_raek: yes.
16:10dnolen_raek: there are something that I didn't consider with defne, i.e. it's idiomatic clojure to be able to take different arities.
16:11dnolen_been heads down with predicate dispatch, so I haven't looked into that much, however would gladly take simple fixes like that (the matching code needs some love anyhow).
16:11raekis there another way of writing my ([_ ['the . ?x] ?x] (== d (make-d 'the))) clause?
16:12Touqenthat kind of makes my head hurt
16:12raekobviosly, it didn't work to write ([(make-d 'the) ['the . ?x] ?x])
16:13dnolen_raek: yet another thing to think about. allowing functions in the match, that would make the matching stuff closer to the level of Prolog power.
16:13dnolen_raek: please feel free to open issues.
16:13raekI'm still struggling with wrapping my head around this, you know :-)
16:14dnolen_raek: still, that's a very inspiring gist, thanks for sharing that!
16:15raekdnolen_: is [foo . bar] and ?var only valid in pattern matching expressions?
16:15dnolen_raek: yes, detecting vars in the bodies would be much more complicated. not saying I'm not interested in that tho.
16:19dnolen_raek: there is also matche
16:19dnolen_(matche [x y] ([ ... ] ...) ([ ... ] ...))
16:21raekall this -e and -o makes it sounds like french and spanish... :-)
16:22raekdnolen_: so, defne is basically defn + matche ?
16:23dnolen_raek: exactly. yeah I debated the convention,s but in the end I decided to stick to the miniKanren conventions. Makes it easier for now if somebody really wants to understand the core.logic implementation and help me improve things, I can refer them to good materials.
16:29kaw_Newbie leiningen question; is it possible to get a slightly simpler directory structure (e.g. source in ./src/ and tests in ./test/ instead of ./src/projectname/ and ./test/projectname/test/) for a smaller project, by say setting some option in project.clj?
16:30technomancykaw_: source is already in src/; it's a limitation of Clojure that you can't have single-segment namespaces (so src/myproject.clj is discouraged)
16:33kaw_So no way to get around the need to have the namespace name in the directory structure?
16:33amalloyit also wouldn't be totally unfair to say that it's a limitation of java, which clojure has to live with
16:34amalloykaw_: no, clojure depends on the namespace to match the directory structure
16:34amalloyso whatever your classpath is, namespace foo.bar.whatever needs to be in CLASSPATH/foo/bar/whatever.clj
16:35Ramblurris there an irc channel for enlive?
16:35kaw_Okay, thanks.. I guess I'll just choose a simple and short namespace name
16:35pjstadigremember when it used to be foo/bar/whatever/whatever.clj
16:35semperosRamblurr: your best bet is probably here
16:35pjstadigthose were the days...
16:35semperosor the enlive google group
16:35Ramblurrsemperos: thanks
16:36Ramblurrsemperos: i was wondering how to create new elements with enlive. e.g., if i've selected an :h2 element, how can I put a totally new <a> inside?
16:37semperosfor simple things, you can write the enlive node directly as a map
16:37semperosyou can insert a string as HTML
16:37Ramblurrsemperos: what function do you pass the map too?
16:37semperosor if you have really complex HTML, you want to format it as Clojure datastrucures and re-re-doing work isn't an issue, you can actually combine hiccup and enlive
16:38semperosRamblurr: do you have some code I can look at? you doing this with a page template, a snippet?
16:38semperosmight be easier in context
16:38Ramblurrsure
16:39Ramblurrsemperos: http://pastie.org/1861807
16:40RamblurrI could just edit the html file and insert an a, but in general I'd like to know how to make html on the fly, sort of like hiccup
16:40semperosyou're not going to get as nice a way as hiccup for creating new HTML
16:41semperosenlive specializes in the selection process
16:41semperoslet me pull up a repl with enlive so I don't mistake the fn's, two secs
16:44semperosRamblurr: you can get the Enlive data structure by passing a string of HTML to the html-snippet fn
16:44semperos(html/html-snippet "<a href='http://example.com'>Example</a>")
16:44semperoswill get you this
16:44semperos({:tag :a, :attrs {:href "http://example.com&quot;}, :content ("Example")})
16:45Ramblurrah interesting
16:45Ramblurrand then pass that to html/content ?
16:45semperosyep
16:45semperossee this blog post: http://www.bestinclass.dk/index.clj/2011/01/building-a-social-media-site.html
16:45semperosgood examples
16:46Ramblurrsemperos: ah fantastic
16:47Ramblurrsemperos: look at this example here http://pastie.org/1861836
16:48Ramblurrnotice how i had to add the extra <div id=message> just to select the h2 and p?
16:48Ramblurris there a beter way to do this without that extraneous <div> and maybe with less code?
16:50dnolen_Ramblurr: enlive can match ranges.
16:53@chouser& '(a ~b ~@c)
16:53sexpbot⟹ (a (clojure.core/unquote b) (clojure.core/unquote-splicing c))
16:53@chouserdid unquote go away in recent versions of Clojure
16:53@chouser?
16:54@chouserin 1.3.0-alpha3 I'm getting just ~b instead of unquote
16:55hiredmanyou need syntax-quote to unquote?
16:58raekdnolen_: here's a bonus for you ;-) https://gist.github.com/954222
17:00dnolen_raek: heh, nice.
17:02dnolen_chouser: works for me in alpha5
17:04@chouserdnolen_: hm, ok.
17:04dnolen_raek: yeah I see you could really benefit from being allowed to use fns in the match. the main issue is distinguishing them from matching lists I think ... perhaps only support brackets for that ?
17:19dnolen_will probably do that since seq destructuring in Clojure is only done with [] as well.
17:25raekdnolen_: also, I got a "IllegalArgumentException No implementation of method: :occurs-check-term of protocol: #'clojure.core.logic.minikanren/IOccursCheckTerm found for class: nil" when I did this: (== s (list 'S aux np1 vp np2 nil))
17:25raekmy workaround was to remove that last nil
17:26dnolen_raek: that's probably a legitimate bug, can you open a issue with link to your code and the snippet to reproduce?
17:27raekdnolen_: sure :)
17:27dnolen_chouser: btw, your unquote bit worked for me on 1.3.0 master as well.
17:28dnolen_raek: thx.
17:28raekdnolen_: on core.logic or logos?
17:34raekdnolen_: Issue with code example: https://github.com/swannodette/logos/issues/24
17:36dnolen_raek: oops sorry, please only on core.logic thx.
17:36dnolen_raek: I don't push to Logos anymore.
17:45dnolen_raek: actually now that I think about it, I suppose the clojure team probably wants me to use JIRA...
17:49zrilakamalloy gave me a template for a macro yesterday with this in it: ... (foo [argmap#] (let ... ; I looked at http://clojure.org/reader and couldn't find any special meaning for the "symbol#" syntax, so I just need to verify: is "symbol#" simply convention for naming maps?
17:50zrilak( `symbol# of course not being relevant here)
17:50amalloy&`foo#
17:50sexpbot⟹ foo__40772__auto__
17:50zrilakah, so it works *inside* quoted sexp too?
17:50zrilakgotcha
17:50amalloyit is ONLY useful inside syntax-quote forms
17:50zrilakI thought it had to be `symbol#, not `(... sym# ...)
17:51zrilakthanks :)
17:51amalloy&`(let [x 1] x)
17:51sexpbot⟹ (clojure.core/let [clojure.core/x 1] clojure.core/x)
17:51amalloythis will fail because you can't let a qualified symbol
17:51amalloy&`(let [x# 1] x#)
17:51sexpbot⟹ (clojure.core/let [x__40787__auto__ 1] x__40787__auto__)
17:51zrilakwasn't immediately obvious to me that it works at an arbitrary place inside a quote
17:56zrilakand this: (defmacro foo [... & body] ~@body) is an idiom for passing multiple forms as body, I take it
17:57zrilak(forgot `)
17:59@chouserzrilak: right
17:59@chouser& body accepts remaining args as a lazy seq, and ~@ splices a seqable into the syntex-quoted form
17:59sexpbotjava.lang.Exception: Unable to resolve symbol: body in this context
18:00zrilakcool, good to see things finally starting to fall together in my head
18:00zrilakthanks :)
18:32semperosanyone used the alternative memoize fn on Meikel Brandmeyer's blog? http://kotka.de/blog/2010/03/memoize_done_right.html
18:32semperostrying out the ttl-cache-strategy and getting some errors I can't quite make sense of
19:43Ramblurrusing lein, whats the best way to get /usr/share/java into my classpath?
19:45hiredmandon't, put whatever it is you want in your project.clj and stop using whatever distros inevitably broken java library installations
19:45Ramblurrah
19:46Ramblurrhiredman: so if i have somejavalib-1.1.3.jar in /usr/share/java i should copy it into lib/ and add [somejavalib "1.2.3" to me :dependencies?
19:47technomancyRamblurr: what's the library?
19:49hiredmanRamblurr: no, you should read the lein readme
19:49Ramblurrhiredman: heh good idea, will do
19:49hiredmanyou never copy stuff manually, if you put the proper entry in project.clj the correct version will be downloaded for you and placed in the correct place
19:50Ramblurroh herm, i just made this library, so i doubt it will be able to be downloaded :\
19:51Ramblurrtechnomancy: the java bindings for kyoto cabinet
19:52technomancyRamblurr: if the developers know what they're doing, they will make the jar available from a maven repository.
19:52hiredmanhttp://clojars.org/org.clojars.lapax/kyotocabinet-java-native-deps
19:53technomancy... and if the devs don't know what they're doing, sometimes someone else does ^
19:53Ramblurroh cool, everything on clojars.org lein can install?
19:53technomancyaye
19:54technomancyman... are there really people out there who think it's fine and dandy to write java libraries without publishing them?
19:54technomancyI am disappoint. ಠ_ಠ
19:56technomancyRamblurr: anyway if you ever get the chance you should chastise them for their oversight; that would be super.
19:56Ramblurrhehe, will do, though I doubt they will.. mikio (the author) is an odd fellow
19:57technomancyit would be cool if clojars made you give a reason before agreeing to create org.clojars.foo group-ids
19:58Ramblurrtechnomancy: on linux, if you dont have the rlwrap tool installed, you get a long error everytime you start the repl with lein... maybe you could catch the error and nudge the user to install their distro package?
19:58technomancyRamblurr: it's just a warning and should only happen on the first run.
19:59technomancyI mean, as far as I can tell, "install rlwrap for optimum experience." implies using your distro package.
19:59Ramblurrhmm, i didn't see that warning: http://pastie.org/1862411
20:00technomancywhoa dang
20:00technomancyweird
20:00technomancywhat lein version?
20:00amalloyRamblurr: what command did you type to start the repl?
20:00Ramblurramalloy: lein repl
20:01Ramblurrtechnomancy: Leiningen 1.5.2
20:01technomancyRamblurr: huh; must be a bug. thanks for the heads-up.
20:01Ramblurrtechnomancy: no problem, want me to submit a ticket (do you even use githubs issues?)
20:02technomancyhiredman: it's /bin/sh these days
20:02technomancybut that's dash on my system
20:03technomancyRamblurr: that'd be great
20:03hiredmanI retract then
20:03technomancyI have no idea if dash qualifies as sane?
20:04technomancyit's not That Original Flavour that your Mom used to Make at least.
20:14Ramblurrhiredman: technomancy: herm, that library on clojars isn't normal i think.. see the contents http://pastie.org/1862451
20:15Ramblurrthe actual java library is inside another jar
20:16zrilakdash is quite insane actually, don't use it
20:17brehautserious question: is there a sane shell?
20:17technomancybrehaut: excellent point
20:17zrilak:)
20:18technomancyeven eshell and scsh have their downsides
20:18zrilakwell, some swore by scsh... but you asked for "sane"
20:20technomancyanything in particular to watch for with dash?
20:20zrilakI can't remember now, but it breaks bash compatibility in some quite non-obvious ways
20:21zrilakwhich can bite bad if writing shell scripts
20:21technomancyoh, I'm not aiming for bash compatibility, but presumably it breaks bourne compatibility too?
20:21zrilakI'd have to go through my old scripts to see exactly why
20:21zrilakI admit I don't know where the boundary between Bourne and Bourne Again lies
20:22hiredmanzrilak: well, everyone should be targeting sh, regardless, if they are using /bin/sh
20:22technomancywell if anything breaks I'm sure I will heard from the solaris users; they are good at making themselves heard. =)
20:22zrilakyes, but then your distro slips a link to /bin/dash in place of /bin/sh
20:23hiredmanzrilak: dash was written to be more like 'sh' than bash is, from what I understand
20:23zrilaktechnomancy: those are the cries for help coming from under the rubble :)
20:23technomancyzrilak: sounds about right
20:24zrilakhiredman: you could be right -- I might have been targeting bash all this time
20:24hiredmanwell, knock it off
20:25zrilakoh well
20:27zrilak<rant>why should we support 40-year old shells</rant>
20:28hiredmanbecause bash is not good enough to replace them
21:00miketeehi guys, having trouble casting one class to another ... as a quick example how can i cast a java.lang.Double to a java.lang.Number ?
21:01miketee=> (class (cast java.lang.Number dbl))
21:01miketeejava.lang.Double
21:02hiredmannone of that has anything to do with casting
21:02miketeewell, i'm actually trying to do this: (binding [bing-service-stub (cast com.microsoft.adcenter.v7.BasicHttpBinding_ICampaignManagementServiceStub bing-campaign-management)])
21:03miketeehere's my bing-campaign-management binding: bing-campaign-service-locator (new com.microsoft.adcenter.v7.CampaignManagementServiceLocator)
21:03miketee (binding [bing-campaign-management (.getBasicHttpBinding_ICampaignManagementService bing-campaign-service-locator)])
21:03hiredmanwhy are you casting it?
21:03hiredmanand why are you using binding so much?
21:03miketeehttp://msdn.microsoft.com/en-us/library/cc728898.aspx
21:04miketeecampaignServiceLocator = new
21:04miketee CampaignManagementServiceLocator();
21:04miketeecampaignServiceLocator.setBasicHttpBinding_ICampaignManagementServiceEndpointAddress(url);
21:04miketee campaignManagement =
21:04miketee campaignServiceLocator.getBasicHttpBinding_ICampaignManagementService();
21:04miketee stub = (BasicHttpBinding_ICampaignManagementServiceStub)
21:04miketee campaignManagement;
21:04hiredmanmiketee: that is a url, not an answer
21:04hiredmanand please don't paste that in here
21:04hiredmanuse a pastebin
21:04miketeesorry
21:04miketeeok
21:05miketeeso i'm following the msdn docs on how to talk to their adcenter, and they are doing a cast of an object to another type
21:05miketeei just want to know how to replicate it
21:06hiredmanignore it, unless they do something weird, casting is an artifact of the java type system, this being a dynamic language you should be able to ignore it
21:07miketeeso how do i refer to the methods of that class for the given object?
21:07hiredmanand stop using binding so much
21:07miketeeif it's not yet that object type?
21:07miketeei need some side effects... should i be using set! ?
21:07hiredmanjsut ignore the type and do waht you want
21:07hiredmancasting does not change the type of an object at all
21:07miketeeok, from my understanding it changes what you can do to the object
21:08miketeeit exposes more methods possibly?
21:08hiredmanno
21:09miketeewhat should i be doing if i want a global variable from the scope of a function?
21:09miketeeset! bitches when i declare using def
21:09amalloybinding?
21:09clojurebot:|
21:09hiredmanthat is not what set! is for, please don't complain that nothing works if you don't know what you are doing
21:10miketeei'm not complaining
21:10miketeei'm asking you what i should be doing if you're telling me to stop using binding
21:10miketeei've tried using set! but it's incompatible with def
21:11hiredmanyou should read the docs and read some clojure code to get a sense of style
21:11miketeei've looked through mire and they use bindings and set!
21:12miketeeto some extent i do need global state
21:12miketeeer, global, mutable state
21:12hiredmanbinding and set! do not create global state
21:12hiredman,(doc binding)
21:12clojurebot"([bindings & body]); binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before. The new bindings are made in parallel (unlike let); all init-exprs are evaluated before the vars are bound to their new values."
21:13hiredmanugh, seriously?
21:13miketeeme?
21:13clojurebotnamespaces 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
21:13miketeehiredman: me?
21:13hiredmanthe docstring for binding is not very good
21:14miketeeoh ok. well if i define a variable in a global context, how would you suggest re-set!ting it?
21:14miketeein scheme i could do this as define and set!
21:15hiredmanmiketee: http://clojure.org/vars
21:15hiredman"Per-thread bindings for one or more Vars can be established via the macro binding and within-thread they obey a stack discipline:"
21:15hiredman"Bindings created with binding cannot be seen by any other thread. Bindings created with binding can be assigned to, which provides a means for a nested context to communicate with code before it on the call stack.
21:15hiredman"
21:16hiredmanif you really need global mutable state you want one of the reference types
21:16miketeeso it would be something like (set! #x 1) ?
21:18hiredmanmiketee: if you are just going to guess over and over I am not going to sit here and say "no" until you guess correctly
21:18hiredmanhave you read the docs for set!?
21:19miketeeyes
21:19hiredmanand what makes you think that is correct?
21:19hiredmanhttp://wiki.gungfu.de/Main/ClojureReferenceTypes
21:20miketeei don't think it is correct, that's why i'm here.
21:21miketeewell, in the land of scheme it would be correct, but it's not in the land of clojure
21:21hiredmanthen based on reading the docs, and what I have said, what do you think is correct?
21:24hiredmanif, as I pasted, binding creates thread-local mutable bindings for a global var, the mutations of which are only visible on a single thread, and set! can only mutate bindings create with binding, does using binding at all make sense?
21:25miketeedef / ref-set
21:25miketeeand deref
21:25hiredmanref-set with what?
21:26miketee(def r (ref nil)) \n (dosync (ref-set r 5)) \n (deref r)
21:27miketeeimo there should be a scheme to clojure habit-breaking document floating around
21:44amalloymiketee: now's your chance to write that document
21:45miketeecan anyone comment if clojure will add first class continuations if java supports closures?
21:46hiredmanthe two are orthogonal
21:47hiredmanclosures and continuations are not the samething andhave little to do with each other
21:47miketeeso java just has to allow first class continuations for clojure to implement?
21:47miketeeor is it a political thing?
21:48hiredmannot java the jvm
21:48hiredmanpolitical?
21:48miketeeyou really like semantics.
21:48Derandermiketee: java way way way ≠ jvm
21:48miketeewhy doesn't clojure have first class continuations?
21:48miketeeis it a limitation of the JVM, or is it some other reason?
21:48Deranderno idea
21:49brehautbecause its not a continuations based language?
21:49hiredmanbecause implementing continuations generally requires more control of the stack then the jvm provides
21:50hiredmanI mean, you can implement continuations on the jvm, they just aren't going to be performant, and won't work with java interop
21:50hiredmantwo of clojure's main goals
21:52hiredmanthe other stumbling point with continuations is lack of tco on the jvm
22:06clizzinwhat's the equivalent of Class.class in clojure?
22:09Ramblurrwhen interoping with java, how do you pass enum flags like FOO | BAR ? (bit-or FOO BAR) works
22:09Ramblurris that the idiomatic way?
22:10alandipertRamblurr: that's how i've done it
22:10amalloyclizzin: Class
22:10clizzinamalloy: ahh yeah figured it out after mucking about a bit. thanks!
22:11amalloy&(nth (iterate class 1) 100)
22:11sexpbot⟹ java.lang.Class
22:11amalloyalso works :P
22:12Ramblurralandipert: looks like (+ FOO BAR) works too
22:13alandipertRamblurr: and it would also work in java
22:13Ramblurryup
22:13alandiperti guess it depends if the enums are powers of 2
22:14amalloywell, none none of this would
22:15amalloyie, if bit-or works, it's because these ints (NOT enums) are powers of two, so + will work too
22:15alandipertright
22:36semperosI'm using this memoize function from Meikel Brandmeyer's blog:
22:36semperoshttps://gist.github.com/954663
22:36semperosI'm calling it like this, on a function foo
22:37semperos(def memoized-foo (memoize foo (ttl-cache-strategy 500)))
22:37semperosI'm getting an arity exception, whereby it says the assoc-in on line 66 of the gist is being past 4 arguments
22:37semperosanyone care to look and see what I might be doing wrong?
22:39amalloywell, you are passing four arguments to assoc-in
22:39semperos:)
22:39amalloyno joke, it's true
22:39semperosI understand that
22:39amalloy&(macroexpand '(-> state (assoc-in [:x] args now)))
22:39sexpbot⟹ (assoc-in state [:x] args now)
22:40amalloywhere you probably want (assoc-in state [:x args] now)
22:40semperosyeah
22:41semperosI htought I was missing something else, bc it was on kotka's blog and folks had been using this code...
22:41semperosI don't get the use of args
22:41semperosin this context
22:41semperoswell, nm, I'll fiddle
22:42semperosyep, that works
22:42semperosamalloy: thanks
22:42semperosI need to start trusting my reading of the code more
22:42amalloyargs is the arguments passed to the function. i assume he's using it as the key in the memoization cache lookup
22:43semperosmakes sense now that it's corrected
22:52technomancyanyway, you guys should all use http://clojars.org/org.clojars.technomancy/lein-search
22:52technomancybecause it's awesome
23:00amalloytechnomancy: a link to the github repo would be a bit more compelling. the clojars page just tells me that you can use lein to search for...something, somehow, and there's no stable 1.0 release yet
23:01technomancyhm; probably true
23:02technomancylein plugin install org.clojars.technomancy/lein-search 1.0.0-SNAPSHOT && lein help search is the way to go
23:03technomancyfor the record, weavejester's clucy lib is pretty handy
23:08amalloytechnomancy: with lein 1.5.2 that command yields nothing more than a NoSuchMethodError