#clojure log - May 03 2011

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

2:53 matthias__: 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?

2:54 i had to use (into-array (...stuff that makes a new keytrigger...)) before

2:56 clgv: matthias__: do you ask for the implementing part?

2:56 matthias__: if so, you can do it via proxy, see http://clojure.org/java_interop#Java%20Interop-Implementing%20Interfaces%20and%20Extending%20Classes

2:57 matthias_: you might also implement it via defrecord, deftype or reify

2:57 matthias__: no, they are already implemented

2:57 im just making new instances of keytrigger and mousebuttontrigger

2:58 clgv: for example?

2:59 matthias__: hmm, here's some of my code

2:59 (.addMapping "Pause" (into-array [(KeyTrigger. KeyInput/KEY_P)]))

2:59 (.addMapping "Left" (into-array [(KeyTrigger. KeyInput/KEY_J)]))

2:59 (.addMapping "Right" (into-array [(KeyTrigger. KeyInput/KEY_K)]))

2:59 (.addMapping "Rotate" (into-array ^Trigger [(cast ^Trigger (KeyTrigger. KeyInput/KEY_SPACE))

2:59 (cast ^Trigger (MouseButtonTrigger. MouseInput/BUTTON_LEFT))]))

2:59 (im just trying to get it to work, so its probably nonsense)

3:00 the first three work

3:00 amalloy: matthias__: the type hint on the fourth is nonsense

3:00 drop the ^ and you'll be fine

3:00 &(into-array Object ["string" 'symbol])

3:00 sexpbot: ⟹ #<Object[] [Ljava.lang.Object;@1b15d6a>

3:01 amalloy: &(into-array ^Object ["string" 'symbol])

3:01 sexpbot: java.lang.IllegalArgumentException: array element type mismatch

3:01 matthias__: oh

3:01 i thought that's how you used types in clojure :S

3:01 thanks

3:02 clgv: amalloy: is cast really necessary or just to get a fail-fast behavior?

3:02 amalloy: matthias__: Object is a symbol which maps to java's Object.class

3:02 clgv: not the latter, i hope, since i don't think it does that

3:02 ~source cast

3:03 clgv: amalloy: it throw an exception if the type does not match - that was what I meant with "fail-fast" ;)

3:03 amalloy: oh, i had it backwards

3:03 tbh the cast expression always confuses me

3:03 matthias__: cast wasnt necessary. just something i tried randomly which didnt help

3:04 amalloy: anyway 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

3:04 clgv: lol the code does indeed. java has a method called "cast"? or is it a special symbol from clojure?

3:04 amalloy: ok thats what I thought as well ;)

3:05 amalloy: clgv: java has one

3:05 clgv: amalloy: I only knew the operator

3:05 amalloy: clgv: java has a whole raft of reflection stuff

3:06 &(let [the-class String the-obj 'a-symbol] (.cast the-Class the-obj))

3:06 sexpbot: java.lang.Exception: Unable to resolve symbol: the-Class in this context

3:06 clgv: ah. you are right. it's called on the class and not the object. now it does make sense

3:06 amalloy: &(let [the-class String the-obj 'a-symbol] (.cast the-class the-obj))

3:06 sexpbot: java.lang.ClassCastException: Cannot cast clojure.lang.Symbol to java.lang.String

3:17 matthias__: 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

3:18 amalloy: it'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"

3:23 matthias__: well, turns out im actually not ;)

3:24 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

3:24 i just used (def bla (proxy.....)) to make those listeners

3:25 now i dont know how to access speed

3:31 amalloy: augh

3:32 do not attempt a literal translation from java. you'll only bring pain to yourself and everyone around you

3:35 anyway, judging from the quality of HelloInput, i imagine SimpleApplication.speed is protected, in which case you can't access them from a proxy

3:35 but it should be possible from a reify? i'm not sure, i don't deal with this nonsense

3:38 raek: ,(doc proxy)

3:38 clojurebot: "([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...

3:38 amalloy: raek: http://gist.github.com/952956

3:39 raek: matthias__: 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

3:40 "As it says in the docs for proxy, you can't access protected members

3:40 from a proxy. "

3:40 "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."

3:41 seems to be a limitation of the proxy feature in java

3:43 matthias__: 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

4:14 solar_sea: Hi. Can the reader be made to cache & reuse functions with equal definitions ?

4:18 From 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 :)

4:23 ejackson: solar_sea: (defn my-function [_] nil) will store that function in my-function

4:23 its shorthand for (def my-function (fn [_] nil))

4:29 solar_sea: ejackson: I know that, I was just thinking of dynamicaly defining functions on the fly and to reuse the ones already defined.

4:30 ejackson: ok

4:30 solar_sea: From 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 ?

5:10 julian37: hi, 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?

5:10 fwiw I'm a clojure newbie but I know my way around emacs pretty well

5:11 I'm after slime/swank setup specifically

5:12 raek: julian37: It's more simple nowadays. these instructions are up to date: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs

5:12 julian37: perfect, thanks raek!

5:13 raek: basically, 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

5:13 and then you use swank-clojure in your leiningen or cake project

5:15 julian37: I have recently updated these instructions, so I'm happy for any feedback (e.g. if something is not clear or does not work)

5:17 julian37: raek: I'll let you know if I notice anything missing, thanks again

5:22 raek: 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"

5:23 I'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?

5:23 Fossi: waiting and getting linked helps

5:24 julian37: right now the first result for "clojure emacs" is http://clojure.org/getting_started , maybe a link could be added to that page?

5:35 solar_sea: How 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)

5:38 raek: solar_sea: can you explain what problem you are trying to solve with this?

5:38 (def is a special form, that's why the first argument does not follow usual evaluation rules)

5:40 solar_sea: I'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

5:41 so far I've come up with this: http://pastebin.com/dMQggELk but it's not exactly working yet

5:42 raek: so you're trying to extend the Clojure language with some caching functionality?

5:43 solar_sea: precisesly ;)

5:43 raek: if you are in control of the code, you could always do (let [f (fn [] nil)] ...)

5:44 so how will this be used?

5:44 solar_sea: the 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 :)

5:45 raek: solar_sea: my-def needs to be a macro if you want to override normal evaluation rules

5:45 solar_sea: just as it is in my code, a closure closing over a defmacro

5:46 raek: solar_sea: you need to deref the atom before you send it to contains?

5:47 solar_sea: and I think you're confusing macro expand time and runtime

5:48 solar_sea: raek: thanks, the atom deref was the problem, it's working as intended now :D

5:49 hell, I didn't know that contains? is implemented over atoms ..

5:55 raek: fwiw, I would probably solve the problem something like this:

5:55 analyze the rules and collect those that are unique

5:55 give each unique rule a name using gensym and construct a map from rules to names of the unique rules

5:56 and generate a defn for each unique rule

5:56 generate the code that uses the rules and where a rule is referenced use the name of the unique rule instead

5:56 as you probably can tell, I'm not much for "magic"... :-)

5:58 no_mind: how do I calculate the current timestamp in clojure ?

5:59 solar_sea: no_mind: (System/currentTimeMillis)

5:59 raek: yes, but I'm still euphoric about clojure's flexibility and I'm going to probably abuse it for some time :)

6:13 no_mind: how do I get today's date in dd/mm/yyyy format ?

6:14 ejackson: no_mind: check out the clj_time library in the getwoven repo on GitHub

6:15 i think it has a (today) or (now)

6:15 fliebel: ejackson: Is that the Yoda wrapper?

6:15 ejackson: yeah

6:25 no_mind: ejackson: clj-time has formatters for date tiem but ot generators

6:25 ejackson: no_mind: 1 sec...

6:26 line 77 of core.clj defines the now function

6:26 https://github.com/getwoven/clj-time/blob/master/src/clj_time/core.clj#L77

6:27 if you pass that through a formatter for your desired format you'll get what you want

6:28 so (unparse my-formatter (now))

6:53 fortxun: $seen rhickey

6:53 sexpbot: rhickey was last seen quitting 3 days and 15 hours ago.

8:46 clgv: I 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?

8:50 from scratch means using JTable and implementing custom renderers...

8:51 fliebel: clgv: Seesaw maybe? Or Incanter?

8:53 clgv: incanter can display it's own matrices as far as I saw. have to lookup seesaw

8:54 fliebel: clgv: How are its own matrices any greener than yours?

8:54 clgv: I didn't check ;) but I dont think it is able to do the color thing ;)

8:55 fliebel: I think it is.

8:56 ejackson: clgv: there's a java matrix lib that does this....

8:56 clgv: ejackson: interesting. which?

8:56 ejackson: Bradford Cross referenced it when he compared the various java mtarix libraries in he blog

8:56 trying to remember...

8:57 http://measuringmeasures.com/blog/2010/3/28/matrix-benchmarks-fast-linear-algebra-on-the-jvm.html

8:58 there: http://www.ujmp.org/

8:59 fliebel: AH, colt is the one used by incanter.

8:59 clgv: yep. colt it is

9:00 fliebel: So according to their home page, you could use ujmp to visualize a Incanter matrix

9:00 … maybe

9:01 solar_sea: What's the proper meaning of "Can't eval locals" in clojure ? :)

9:01 fliebel: solar_sea: Where are you seeing that?

9:02 &(let [x 1] (eval '(+ x 1)))

9:02 sexpbot: java.lang.SecurityException: You tripped the alarm! eval is bad!

9:02 solar_sea: In a rather weird macro scenario, I've sent a mail to the ML about it

9:03 when I call a defmacro from the body of another defmacro

9:03 fliebel: solar_sea: Probably something about quoting then.

9:03 oh...

9:04 solar_sea: I 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

9:16 clgv: ejackson: ok, I am working on a UJMP solution. looks promising. thx!

9:17 ejackson: np, just remembered the 'predator view' matrices from that blog post ;)

9:17 clgv: just their documentation is a bit like some of the matrices they support - sparse ;(

9:18 ejackson: ;)

9:18 clgv: maybe I find something in the forum

9:18 to get started faster

9:37 ok. It's easier to get to see something that I thought: (doto (DefaultDenseDoubleMatrix2D. 120, 120) (.showGUI))

9:37 ejackson: that's cute

9:38 clgv: now I only need to set the data and try to findout how to influence the displayed colors

9:52 dpritchett: every 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:26 clgv: ejackson: hmm standard colors seem to be black to green...

10:26 ejackson: old skool

10:36 clgv: lol yeah

11:14 semperos: trying 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:14 while working in slime/swank at the REPL

11:14 anyone else experience these issues?

12:06 figured it out; incanter was pulling in old versions of congomongo and the database driver for mongodb...

12:10 ejackson: naughty Incanter !

12:10 semperos: :)

12:10 nah, naughty me for not paying attention to the granular jar files David provides for the different parts of incanter

12:12 actually 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:41 ejackson: that is fast

12:49 dnolen: wow this is hilarious, http://bugs.sun.com/view_bug.do?bug_id=4262078

12:49 10 years of people complaining.

12:51 amalloy: dnolen: if i were getting complaints with such atrocious grammar and spelling, i'd wait ten years too

12:51 clgv: can't incanter.core/dataset handle lazyseqs?

12:53 ejackson_: Check it out: Chas's ClojureAtlas just got released: http://cemerick.com/2011/05/03/clojure-atlas-now-available/

13:09 choffstein: If 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:09 amalloy: zipmap

13:09 KirinDave: choffstein: zipmap

13:09 shit

13:10 dakrone: ,(zipmap [:a :b :c] [1 2 3])

13:10 clojurebot: {:c 3, :b 2, :a 1}

13:10 KirinDave: come on amalloy you can't go cutting corners. ;)

13:10 amalloy: KirinDave: where do i go for my ninja badge?

13:10 choffstein: vunderful!

13:10 Thanks ever so much

13:12 ejackson: redis is freaking amazing

13:13 semperos: ejackson: what are you using it for specifically?

13:14 ejackson: semperos: as a silly fast store of data.

13:14 choffstein: what is a sorted-map?

13:15 ejackson: i'm using its native datastructures

13:15 choffstein: a map which is sorted by its keys

13:15 semperos: choffstein: maps by default are not sorted, i.e. the keys aren't in order

13:15 choffstein: so when you pull the keys, they are sorted?

13:15 By the order you insert them in? Or can you provide a sort method?

13:15 semperos: what do you mean by "pull"?

13:16 choffstein: e.g. (keys map)

13:16 semperos: ,(hash-map :a "foo" :b "woops" :c "bar")

13:16 clojurebot: {:a "foo", :c "bar", :b "woops"}

13:16 ejackson: choffstein: when you assoc new key-vals, the datastructure retains its order

13:16 semperos: ,(keys (hash-map :a "foo" :b "woops" :c "bar"))

13:16 clojurebot: (:a :c :b)

13:17 semperos: ,(sorted-map :a "foo" :b "woops" :c "bar")

13:17 clojurebot: {:a "foo", :b "woops", :c "bar"}

13:17 semperos: ,(keys (sorted-map :a "foo" :b "woops" :c "bar"))

13:17 clojurebot: (:a :b :c)

13:18 choffstein: ,(assoc (sorted-map :a "foo" :b "whoops" :d "bar") :c "test")

13:18 clojurebot: {:a "foo", :b "whoops", :c "test", :d "bar"}

13:18 choffstein: ,(keys (assoc (sorted-map :a "foo" :b "whoops" :d "bar") "test"))

13:18 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$assoc

13:18 choffstein: ,(keys (assoc (sorted-map :a "foo" :b "whoops" :d "bar") :c "test"))

13:18 clojurebot: (:a :b :c :d)

13:18 choffstein: hmm, interesting.

13:18 Tristam: Oooh...that bot is neat

13:19 semperos: sexpbot is very nice as well

13:19 with lots o' features

13:19 my favorite is find-fn

13:19 miner49r: use array-map if you want the insertion order; sorted-map maintains the sorted order (not necessarily the insertion (time) order)

13:19 Tristam: I'm brand new to clojure, so I dunno what you're talking about...haha

13:21 So far all I've done in clojure is hello world. Hehe

13:22 semperos: then everyone envies you your first dive into Clojure :)

13:22 choffstein: miner49r: but by what definition of 'order' ?

13:22 Tristam: Haha

13:22 I 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:24 miner49r: choffstein: the insertion order is the order defined by the call to array-map. assoc will add the key as first in order.

13:24 ,(array-map :a 1 :b 2)

13:24 clojurebot: {:a 1, :b 2}

13:24 jarpiain: ,(sorted-map [2 2] :a, [1 2] :b, [2 1] :c)

13:24 clojurebot: {[1 2] :b, [2 1] :c, [2 2] :a}

13:24 choffstein: miner49r: I mean for sorted-map

13:24 ataggart: miner49r: not true once the map size > 8

13:24 miner49r: assoc an array-map with 8 entries and you'll get back a hash-map

13:25 semperos: Tristam: you can message sexpbot privately and play around

13:25 jarpiain: ,(sorted-map-by > 1 :a, 2 :b, 3 :c)

13:25 clojurebot: {3 :c, 2 :b, 1 :a}

13:25 miner49r: attagart: 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:25 semperos: but the findfn lets you say "given an input and an output, show me which function(s) can perform this change"

13:25 ataggart: miner49r: correct

13:25 semperos: $findfn "foo" "FOO"

13:26 sexpbot: [clojure.string/upper-case clojure.contrib.string/swap-case clojure.contrib.string/upper-case]

13:26 Tristam: semperos, that almost sounds dirty...haha

13:26 semperos: it's pretty useful if both the name of a function or even a related word escape you, so you need smth beyond docs

13:27 Tristam: That's sweet

13:27 miner49r: By 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:27 Tristam: I need a bot like that for everyday conversation when I forget stuff!

13:27 semperos: heh

13:27 the code is hosted on github: https://github.com/Raynes/sexpbot

13:28 Tristam: What's it written in?

13:28 semperos: oops

13:28 wrong repo

13:28 Tristam: I'll give you two guesses

13:28 :)

13:28 Tristam: Haha

13:28 semperos: http://github.com/cognitivedissonance/sexpbot is the right repo

13:28 Tristam: clojure?

13:28 clojurebot: "[Clojure ...] feels like a general-purpose language beamed back from the near future."

13:28 semperos: yes

13:28 look at the repo, the *.clj files are all Clojure source files

13:28 Tristam: Woo! I only needed one guess!

13:28 semperos: :)

13:29 Tristam: where are you coming from, in terms of current programming language(s)?

13:29 (always curious how/why folks come to Clojure)

13:30 Tristam: I'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:30 Someone mentioned clojure to me when we were jabbering about lisp

13:31 So I checked it out

13:31 semperos: gotcha

13:31 Tristam: I've got a potential job opportunity that involves some amount of java...so maybe I can lispify it and make it work better.

13:32 semperos: "it's just a jar, boss"

13:33 Tristam: Beyond that, I like programming languages, so I look into them just for kicks when one interests me.

13:33 * Tristam writes that down. "It's just a jar boss. You don't need to know what's in it. It just works!"

13:33 semperos: :)

13:35 amalloy: semperos: findfn has a newish feature, btw

13:35 semperos: amalloy: oui?

13:35 amalloy: $findarg map % [1 2 3] [2 3 4]

13:35 sexpbot: [clojure.core/unchecked-inc clojure.core/inc]

13:36 semperos: I like it!

13:36 $findfn [1 2 3] [2 4 6]

13:36 sexpbot: []

13:36 semperos: what am I missing there, amalloy?

13:36 oh, nm

13:36 amalloy: um, there's no "double this" function in the core libs

13:36 * semperos laughs at self

13:37 Tristam: You'd need apply or mapcar or something that that wouldn't you?

13:37 * Tristam is a bit rusty on lispy goodness.

13:37 amalloy: $findfn #(* 2 %) [1 2 3] [2 4 6]

13:37 sexpbot: [clojure.core/map clojure.core/keep]

13:37 semperos: ,(map #(* 2 %) [1 2 3])

13:37 clojurebot: (2 4 6)

13:37 Tristam: There ya go

13:38 semperos: I have a habit of asking obviously stupid quesitons

13:38 amalloy: like what? (har har, get it? what a stupid question)

13:38 semperos: :)

13:38 keeps me in my place

13:38 Tristam: We all have random brain shutdowns

13:39 Some of us more often than others.

13:39 semperos: ,(let [times-2 (partial * 2)] (map times-2 [1 2 3]))

13:39 clojurebot: (2 4 6)

13:39 Tristam: What were we talking about again?

13:39 semperos: example of currying, if I'm not mixing up my terms

13:39 Tristam: Is [] shorthand for a lambda?>

13:39 amalloy: Tristam: 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:40 Tristam: no, it's a literal vector

13:40 #() is shorthand for a lambda

13:40 semperos: with % as the implicit param

13:40 Tristam: I remember going insane with the car/cdr stuff

13:40 ataggart: % == %1

13:41 amalloy: to be fair, we do have mapcat, which is basically just (apply concat (map ...))

13:42 * Tristam decides he needs a Clojure for Dummies book.

13:42 semperos: Tristam: 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:43 Tristam: I'm used to fried brains

13:43 semperos: :)

13:43 the videos for Clojure on blip are really good, if you haven't checked them out, you should

13:43 Tristam: Though I really like Head First books for new programming languages...that minimizes brain frying a lot of times.

13:44 amalloy: Tristam: if you learn a new language and your brain still works, you're doing it wrong

13:44 Tristam: amalloy, Quite true

13:45 semperos: Tristam: but if you already have the JVM ecosystem experience and CL, perhaps it'll just be a mild simmering...

13:47 Tristam: Flash fry

13:51 fcek: there's a core/contrib function that does this? ((fn [m] (zipmap (map keyword (keys m)) (vals m))) {"a" "b" "c" "d"})

13:51 ,((fn [m] (zipmap (map keyword (keys m)) (vals m))) {"a" "b" "c" "d"})

13:51 clojurebot: {:c "d", :a "b"}

13:52 fcek: ops, it's wrong

13:52 it should be {:a "b" :c "d"}

13:53 ataggart: hash-map isn't sorted

13:54 ,(reduce (fn [m [k v]] (assoc m (keyword k) v)) {"a" "b" "c" "d"})

13:54 clojurebot: java.lang.IllegalArgumentException: Key must be integer

13:55 dpritchett: Neat, jeresig left Mozilla and now works for Khan Academy.

13:55 ataggart: ,(reduce (fn [m [k v]] (assoc m (keyword k) v)) {} {"a" "b" "c" "d"})

13:55 clojurebot: {:c "d", :a "b"}

13:56 fcek: i 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:56 semperos: ataggart's reduce does the trick nicely

13:58 fcek: i'll use it as a starting point to handle nested maps, thanks

14:03 MayDaniel: fcek: There's clojure.walk/keywordize-keys.

14:06 fcek: MayDaniel: perfect, thanks!

14:47 ordnungswidrig: ,(dotimes [i (range 3)] (inc i))

14:47 clojurebot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Character

14:47 ordnungswidrig: ?

14:48 miner49r: ,(dotimes [i 3] (inc i))

14:48 clojurebot: nil

14:48 ordnungswidrig: argl

14:48 however the exception is somewhat misleading :-)

14:49 miner49r: yes, there's a bug somewhere collecting misleading error messages so that they can be improved

15:03 edw: Hmm, is there a way to kill the motion-sickness inducement feature of Clojure Atlas?

15:05 cemerick: edw: I'm working on it :-)

15:05 ataggart: ,(doc dotimes)

15:05 clojurebot: "([bindings & body]); bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1."

15:06 ataggart: ,(dotimes [i 3] (println i))

15:06 clojurebot: 0

15:06 1

15:06 2

15:06 amalloy: &(doseq [i (range 3)] (prn i))

15:06 sexpbot: ⟹ 0 1 2 nil

15:07 ataggart: skinning cats is fun

15:09 Tristam: Everytime I look into this channel, the Chevelle song "Closure" pops into my head.

15:10 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:10 cemerick: edw: 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:11 edw: s/procedure./procedure.\)/

15:11 sexpbot: <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:11 edw: D'oh.

15:12 cemerick: edw: where would the "usage frequency" come from, if not github?

15:12 amalloy: cemerick: he suggests highlighting which ones the user looks at most often, i think

15:12 edw: Clickstream data from your users. Most grequently-consulted...

15:12 cemerick: ah

15:14 edw: 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:14 edw: 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:15 edw: Also, 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:17 This 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:17 ataggart: -> is for working with a single value/object, ->> is for working with sequences of values/objects

15:18 so sayeth rhickey

15:18 likewise 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:18 cemerick: edw: The ontology is *far* from complete. -> - suitable vs. ->> - suitable will be two distinct concept nodes that get linked up appropriately.

15:18 ejackson: which I think is due to the convention of putting arguments to functions which are seqs at the last position

15:19 cemerick: Yeah, those are just idioms.

15:19 I've switched -> to ->> when some java method needed my single object as the last arg plenty of times.

15:20 hsuh: i've been getting errors like http://paste.factorcode.org/paste?id=2264 from time to time, any idea what could that be?

15:20 edw: Crazy idea here, but imagine this: someone can annotate the documentation and people can enable/load/whatever sets of annotations.

15:23 amalloy: cemerick: (-> foo (.thing1 x) (.thing2 y z) (->> (.method otherObject)))?

15:23 edw: Oh, 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:24 amalloy: hsuh: stop making so many keywords :P

15:24 ataggart: cemerick: yes sometimes expediency takes backseat to semantic clarity

15:24 Plertrood: How can I join two lists together?

15:24 cemerick: amalloy: You can do that, but just (->> foo .blah .bar (.baz arg1 arg2)) too, assuming .baz takes .bar's result last.

15:25 ataggart: ,(doc concat)

15:25 clojurebot: "([] [x] [x y] [x y & zs]); Returns a lazy seq representing the concatenation of the elements in the supplied colls."

15:25 dnolen: ,(concat [1 2] [3 4])

15:25 clojurebot: (1 2 3 4)

15:25 amalloy: &(into [1 2] [3 4])

15:25 sexpbot: ⟹ [1 2 3 4]

15:25 Plertrood: Ah lovely! Thanks been looking throguh the docs all afternoon!

15:25 cemerick: edw: 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:26 amalloy: cemerick: 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:27 dnolen: Plertrood: 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:27 edw: cemerick: I'm done with the irritating suggestions. For now.

15:27 amalloy: that said, it's remarkable how rarely you actually need to concatenate lists at all

15:28 cemerick: edw: 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:28 Plertrood: Ah ok yes I think I looked at concat and saw it was lazy and it didn't do what I wanted.

15:36 ordnungswidrig: to 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:36 when data data at :foo-1 and :foo-2 is updated indepentently.

15:38 nickik: it works anyway, its kind of hard to say when what is better

15:39 ordnungswidrig: in 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:39 nickik: it 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:39 i think so.

15:51 Tristam: semperos, you're in NoVA?

15:52 semperos: Tristam: yes

15:52 Tristam: I miss Cox

15:52 semperos: it's the best I've ever had

15:52 Tristam: I used to live near Springfield Mall

15:52 semperos: gotcha

15:52 nice area

15:52 Tristam: Up until mid 2009

15:53 Yeah, we liked it...the commute into DC was crap of course.

15:53 semperos: of course

15:53 I don't work in the city

15:53 Tristam: My wife worked at the Navy Yard

15:53 So it didn't matter if she took 395 or 495/295, it was utter crap

15:53 semperos: yep

15:53 understatement of the century

15:53 :)

15:54 Tristam: Super tech people work in Herndon/Reston...heh

15:54 semperos: seems that way

15:54 Tristam: Unfortunately, we'll be back there in 3-5 years/.

15:55 semperos: but you'll have one of hte best Clojure groups to look forward to

15:55 Tristam: Yay

15:55 pjstadig: i used to hate Northern Virginia...until i started working from home

15:55 semperos: yep

15:56 Tristam: We'll probably end up living in a shack somewhere when we move back...real estate is WAY lower here than down there.

15:56 pjstadig: my verizon dsl contract is expiring, and i'm thinking of switching back to cox for internet

15:57 Tristam: values are still a little depressed, i'd like to sell my house and move, but the prices are too low

15:57 but relatively speaking ...

15:58 Tristam: pjstadig, we sold our condo and bought a 4 bedroom house with 1000 more sq feet for $10k less than we sold

15:58 pjstadig: yeah...*sigh*...i know

15:59 Tristam: We bought the condo in 2001 though, so we still have some decent amount of equity.

15:59 raek: dnolen_: 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:02 dnolen_: raek: SWEEEEEEEEET

16:02 raek: seriously that's really great, any feedback?

16:02 raek: that's nice looking code.

16:03 raek: I'm still a newbie with this syntax for logic programming

16:04 dnolen_: raek: do you have a twitter handle?

16:04 raek: @raekmannen

16:04 semperos: raek: very cool indeed

16:04 dnolen_: worked through your brief logic-tutorial, my first experience with that type of programming

16:05 +1 for continuing to flesh it out as you have time :)

16:05 raek: I was really astonished when I learned how natural these things are in logic programming

16:05 dnolen_: semperos: yes it needs a lot of work.

16:05 Tristam: logic programming gives me scary flashbacks to prolog...

16:05 semperos: dnolen_: that's ok, it got me going

16:05 dnolen_: you've done great work

16:06 dnolen_: semeperos: thx!

16:06 raek: dnolen_: when I have gotten myself more familiar with core.logic, I was thinking about writing macros for the more compact DCG syntax

16:07 dnolen_: do you know any syntax guide for miniKanren for those who are used to prolog?

16:07 but I guess the books you mentioned contains it all...

16:07 dnolen_: raek: yes, The Reasoned Schemer and Byrd's thesis are really the two main references.

16:08 raek: the defne syntax is my own design, based on their more Scheme-ish syntax for that, glad you ran w/ that.

16:09 raek: it would be nice to have a small reference that explains what kinds of expressions there are and "what can be put where"

16:09 dnolen_: raek: like a quick reference or something? might make sense for a wiki.

16:09 raek: the first form of each defne clause should unify with the arguments, right?

16:09 yeah

16:10 definitely

16:10 dnolen_: raek: yes.

16:10 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:11 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:11 raek: is there another way of writing my ([_ ['the . ?x] ?x] (== d (make-d 'the))) clause?

16:12 Touqen: that kind of makes my head hurt

16:12 raek: obviosly, it didn't work to write ([(make-d 'the) ['the . ?x] ?x])

16:13 dnolen_: 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:13 raek: please feel free to open issues.

16:13 raek: I'm still struggling with wrapping my head around this, you know :-)

16:14 dnolen_: raek: still, that's a very inspiring gist, thanks for sharing that!

16:15 raek: dnolen_: is [foo . bar] and ?var only valid in pattern matching expressions?

16:15 dnolen_: raek: yes, detecting vars in the bodies would be much more complicated. not saying I'm not interested in that tho.

16:19 raek: there is also matche

16:19 (matche [x y] ([ ... ] ...) ([ ... ] ...))

16:21 raek: all this -e and -o makes it sounds like french and spanish... :-)

16:22 dnolen_: so, defne is basically defn + matche ?

16:23 dnolen_: 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:29 kaw_: 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:30 technomancy: kaw_: 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:33 kaw_: So no way to get around the need to have the namespace name in the directory structure?

16:33 amalloy: it also wouldn't be totally unfair to say that it's a limitation of java, which clojure has to live with

16:34 kaw_: no, clojure depends on the namespace to match the directory structure

16:34 so whatever your classpath is, namespace foo.bar.whatever needs to be in CLASSPATH/foo/bar/whatever.clj

16:35 Ramblurr: is there an irc channel for enlive?

16:35 kaw_: Okay, thanks.. I guess I'll just choose a simple and short namespace name

16:35 pjstadig: remember when it used to be foo/bar/whatever/whatever.clj

16:35 semperos: Ramblurr: your best bet is probably here

16:35 pjstadig: those were the days...

16:35 semperos: or the enlive google group

16:35 Ramblurr: semperos: thanks

16:36 semperos: 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:37 semperos: for simple things, you can write the enlive node directly as a map

16:37 you can insert a string as HTML

16:37 Ramblurr: semperos: what function do you pass the map too?

16:37 semperos: or 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:38 Ramblurr: do you have some code I can look at? you doing this with a page template, a snippet?

16:38 might be easier in context

16:38 Ramblurr: sure

16:39 semperos: http://pastie.org/1861807

16:39 * semperos looks

16:40 Ramblurr: I 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:40 semperos: you're not going to get as nice a way as hiccup for creating new HTML

16:41 enlive specializes in the selection process

16:41 let me pull up a repl with enlive so I don't mistake the fn's, two secs

16:44 Ramblurr: you can get the Enlive data structure by passing a string of HTML to the html-snippet fn

16:44 (html/html-snippet "<a href='http://example.com'>Example</a>")

16:44 will get you this

16:44 ({:tag :a, :attrs {:href "http://example.com"}, :content ("Example")})

16:45 Ramblurr: ah interesting

16:45 and then pass that to html/content ?

16:45 semperos: yep

16:45 see this blog post: http://www.bestinclass.dk/index.clj/2011/01/building-a-social-media-site.html

16:45 good examples

16:46 Ramblurr: semperos: ah fantastic

16:47 semperos: look at this example here http://pastie.org/1861836

16:48 notice how i had to add the extra <div id=message> just to select the h2 and p?

16:48 is there a beter way to do this without that extraneous <div> and maybe with less code?

16:50 dnolen_: Ramblurr: enlive can match ranges.

16:53 chouser: & '(a ~b ~@c)

16:53 sexpbot: ⟹ (a (clojure.core/unquote b) (clojure.core/unquote-splicing c))

16:53 chouser: did unquote go away in recent versions of Clojure

16:53 ?

16:54 in 1.3.0-alpha3 I'm getting just ~b instead of unquote

16:55 hiredman: you need syntax-quote to unquote?

16:58 raek: dnolen_: here's a bonus for you ;-) https://gist.github.com/954222

17:00 dnolen_: raek: heh, nice.

17:02 chouser: works for me in alpha5

17:04 chouser: dnolen_: hm, ok.

17:04 dnolen_: 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:19 will probably do that since seq destructuring in Clojure is only done with [] as well.

17:25 raek: dnolen_: 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:25 my workaround was to remove that last nil

17:26 dnolen_: raek: that's probably a legitimate bug, can you open a issue with link to your code and the snippet to reproduce?

17:27 raek: dnolen_: sure :)

17:27 dnolen_: chouser: btw, your unquote bit worked for me on 1.3.0 master as well.

17:28 raek: thx.

17:28 raek: dnolen_: on core.logic or logos?

17:34 dnolen_: Issue with code example: https://github.com/swannodette/logos/issues/24

17:36 dnolen_: raek: oops sorry, please only on core.logic thx.

17:36 raek: I don't push to Logos anymore.

17:45 raek: actually now that I think about it, I suppose the clojure team probably wants me to use JIRA...

17:49 zrilak: amalloy 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:50 ( `symbol# of course not being relevant here)

17:50 amalloy: &`foo#

17:50 sexpbot: ⟹ foo__40772__auto__

17:50 zrilak: ah, so it works *inside* quoted sexp too?

17:50 gotcha

17:50 amalloy: it is ONLY useful inside syntax-quote forms

17:50 zrilak: I thought it had to be `symbol#, not `(... sym# ...)

17:51 thanks :)

17:51 amalloy: &`(let [x 1] x)

17:51 sexpbot: ⟹ (clojure.core/let [clojure.core/x 1] clojure.core/x)

17:51 amalloy: this will fail because you can't let a qualified symbol

17:51 &`(let [x# 1] x#)

17:51 sexpbot: ⟹ (clojure.core/let [x__40787__auto__ 1] x__40787__auto__)

17:51 zrilak: wasn't immediately obvious to me that it works at an arbitrary place inside a quote

17:56 and this: (defmacro foo [... & body] ~@body) is an idiom for passing multiple forms as body, I take it

17:57 (forgot `)

17:59 chouser: zrilak: right

17:59 & body accepts remaining args as a lazy seq, and ~@ splices a seqable into the syntex-quoted form

17:59 sexpbot: java.lang.Exception: Unable to resolve symbol: body in this context

18:00 zrilak: cool, good to see things finally starting to fall together in my head

18:00 thanks :)

18:32 semperos: anyone used the alternative memoize fn on Meikel Brandmeyer's blog? http://kotka.de/blog/2010/03/memoize_done_right.html

18:32 trying out the ttl-cache-strategy and getting some errors I can't quite make sense of

19:43 Ramblurr: using lein, whats the best way to get /usr/share/java into my classpath?

19:45 hiredman: don't, put whatever it is you want in your project.clj and stop using whatever distros inevitably broken java library installations

19:45 Ramblurr: ah

19:46 hiredman: 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:47 technomancy: Ramblurr: what's the library?

19:49 hiredman: Ramblurr: no, you should read the lein readme

19:49 Ramblurr: hiredman: heh good idea, will do

19:49 hiredman: you 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:50 Ramblurr: oh herm, i just made this library, so i doubt it will be able to be downloaded :\

19:51 technomancy: the java bindings for kyoto cabinet

19:52 technomancy: Ramblurr: if the developers know what they're doing, they will make the jar available from a maven repository.

19:52 hiredman: http://clojars.org/org.clojars.lapax/kyotocabinet-java-native-deps

19:53 technomancy: ... and if the devs don't know what they're doing, sometimes someone else does ^

19:53 Ramblurr: oh cool, everything on clojars.org lein can install?

19:53 technomancy: aye

19:54 man... are there really people out there who think it's fine and dandy to write java libraries without publishing them?

19:54 I am disappoint. ಠ_ಠ

19:56 Ramblurr: anyway if you ever get the chance you should chastise them for their oversight; that would be super.

19:56 Ramblurr: hehe, will do, though I doubt they will.. mikio (the author) is an odd fellow

19:57 technomancy: it would be cool if clojars made you give a reason before agreeing to create org.clojars.foo group-ids

19:58 Ramblurr: technomancy: 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:58 technomancy: Ramblurr: it's just a warning and should only happen on the first run.

19:59 I mean, as far as I can tell, "install rlwrap for optimum experience." implies using your distro package.

19:59 Ramblurr: hmm, i didn't see that warning: http://pastie.org/1862411

20:00 technomancy: whoa dang

20:00 weird

20:00 what lein version?

20:00 amalloy: Ramblurr: what command did you type to start the repl?

20:00 Ramblurr: amalloy: lein repl

20:01 technomancy: Leiningen 1.5.2

20:01 technomancy: Ramblurr: huh; must be a bug. thanks for the heads-up.

20:01 Ramblurr: technomancy: no problem, want me to submit a ticket (do you even use githubs issues?)

20:02 * hiredman calls using bash instead of sane shell

20:02 technomancy: hiredman: it's /bin/sh these days

20:02 but that's dash on my system

20:03 Ramblurr: that'd be great

20:03 hiredman: I retract then

20:03 technomancy: I have no idea if dash qualifies as sane?

20:04 it's not That Original Flavour that your Mom used to Make at least.

20:14 Ramblurr: hiredman: technomancy: herm, that library on clojars isn't normal i think.. see the contents http://pastie.org/1862451

20:15 the actual java library is inside another jar

20:16 zrilak: dash is quite insane actually, don't use it

20:17 brehaut: serious question: is there a sane shell?

20:17 technomancy: brehaut: excellent point

20:17 zrilak: :)

20:18 technomancy: even eshell and scsh have their downsides

20:18 zrilak: well, some swore by scsh... but you asked for "sane"

20:20 technomancy: anything in particular to watch for with dash?

20:20 zrilak: I can't remember now, but it breaks bash compatibility in some quite non-obvious ways

20:21 which can bite bad if writing shell scripts

20:21 technomancy: oh, I'm not aiming for bash compatibility, but presumably it breaks bourne compatibility too?

20:21 zrilak: I'd have to go through my old scripts to see exactly why

20:21 I admit I don't know where the boundary between Bourne and Bourne Again lies

20:22 hiredman: zrilak: well, everyone should be targeting sh, regardless, if they are using /bin/sh

20:22 technomancy: well if anything breaks I'm sure I will heard from the solaris users; they are good at making themselves heard. =)

20:22 zrilak: yes, but then your distro slips a link to /bin/dash in place of /bin/sh

20:23 hiredman: zrilak: dash was written to be more like 'sh' than bash is, from what I understand

20:23 zrilak: technomancy: those are the cries for help coming from under the rubble :)

20:23 technomancy: zrilak: sounds about right

20:24 zrilak: hiredman: you could be right -- I might have been targeting bash all this time

20:24 hiredman: well, knock it off

20:25 zrilak: oh well

20:27 <rant>why should we support 40-year old shells</rant>

20:28 hiredman: because bash is not good enough to replace them

21:00 miketee: hi 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:01 => (class (cast java.lang.Number dbl))

21:01 java.lang.Double

21:02 hiredman: none of that has anything to do with casting

21:02 miketee: well, i'm actually trying to do this: (binding [bing-service-stub (cast com.microsoft.adcenter.v7.BasicHttpBinding_ICampaignManagementServiceStub bing-campaign-management)])

21:03 here's my bing-campaign-management binding: bing-campaign-service-locator (new com.microsoft.adcenter.v7.CampaignManagementServiceLocator)

21:03 (binding [bing-campaign-management (.getBasicHttpBinding_ICampaignManagementService bing-campaign-service-locator)])

21:03 hiredman: why are you casting it?

21:03 and why are you using binding so much?

21:03 miketee: http://msdn.microsoft.com/en-us/library/cc728898.aspx

21:04 campaignServiceLocator = new

21:04 CampaignManagementServiceLocator();

21:04 campaignServiceLocator.setBasicHttpBinding_ICampaignManagementServiceEndpointAddress(url);

21:04 campaignManagement =

21:04 campaignServiceLocator.getBasicHttpBinding_ICampaignManagementService();

21:04 stub = (BasicHttpBinding_ICampaignManagementServiceStub)

21:04 campaignManagement;

21:04 hiredman: miketee: that is a url, not an answer

21:04 and please don't paste that in here

21:04 use a pastebin

21:04 miketee: sorry

21:04 ok

21:05 so 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:05 i just want to know how to replicate it

21:06 hiredman: ignore 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:07 miketee: so how do i refer to the methods of that class for the given object?

21:07 hiredman: and stop using binding so much

21:07 miketee: if it's not yet that object type?

21:07 i need some side effects... should i be using set! ?

21:07 hiredman: jsut ignore the type and do waht you want

21:07 casting does not change the type of an object at all

21:07 miketee: ok, from my understanding it changes what you can do to the object

21:08 it exposes more methods possibly?

21:08 hiredman: no

21:09 miketee: what should i be doing if i want a global variable from the scope of a function?

21:09 set! bitches when i declare using def

21:09 amalloy: binding?

21:09 clojurebot: :|

21:09 hiredman: that is not what set! is for, please don't complain that nothing works if you don't know what you are doing

21:10 miketee: i'm not complaining

21:10 i'm asking you what i should be doing if you're telling me to stop using binding

21:10 i've tried using set! but it's incompatible with def

21:11 hiredman: you should read the docs and read some clojure code to get a sense of style

21:11 miketee: i've looked through mire and they use bindings and set!

21:12 to some extent i do need global state

21:12 er, global, mutable state

21:12 hiredman: binding and set! do not create global state

21:12 ,(doc binding)

21:12 clojurebot: "([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:12 * amalloy regrets suggesting binding before reading the whole backlog

21:13 hiredman: ugh, seriously?

21:13 miketee: me?

21:13 clojurebot: namespaces 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:13 miketee: hiredman: me?

21:13 hiredman: the docstring for binding is not very good

21:14 miketee: oh ok. well if i define a variable in a global context, how would you suggest re-set!ting it?

21:14 in scheme i could do this as define and set!

21:15 hiredman: miketee: http://clojure.org/vars

21:15 "Per-thread bindings for one or more Vars can be established via the macro binding and within-thread they obey a stack discipline:"

21:15 "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:15 "

21:16 if you really need global mutable state you want one of the reference types

21:16 miketee: so it would be something like (set! #x 1) ?

21:18 hiredman: miketee: 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:18 have you read the docs for set!?

21:19 miketee: yes

21:19 hiredman: and what makes you think that is correct?

21:19 http://wiki.gungfu.de/Main/ClojureReferenceTypes

21:20 miketee: i don't think it is correct, that's why i'm here.

21:21 well, in the land of scheme it would be correct, but it's not in the land of clojure

21:21 hiredman: then based on reading the docs, and what I have said, what do you think is correct?

21:24 if, 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:25 miketee: def / ref-set

21:25 and deref

21:25 hiredman: ref-set with what?

21:26 miketee: (def r (ref nil)) \n (dosync (ref-set r 5)) \n (deref r)

21:27 imo there should be a scheme to clojure habit-breaking document floating around

21:44 amalloy: miketee: now's your chance to write that document

21:45 miketee: can anyone comment if clojure will add first class continuations if java supports closures?

21:46 hiredman: the two are orthogonal

21:47 closures and continuations are not the samething andhave little to do with each other

21:47 miketee: so java just has to allow first class continuations for clojure to implement?

21:47 or is it a political thing?

21:48 hiredman: not java the jvm

21:48 political?

21:48 miketee: you really like semantics.

21:48 Derander: miketee: java way way way ≠ jvm

21:48 miketee: why doesn't clojure have first class continuations?

21:48 is it a limitation of the JVM, or is it some other reason?

21:48 Derander: no idea

21:49 brehaut: because its not a continuations based language?

21:49 hiredman: because implementing continuations generally requires more control of the stack then the jvm provides

21:50 I mean, you can implement continuations on the jvm, they just aren't going to be performant, and won't work with java interop

21:50 two of clojure's main goals

21:52 the other stumbling point with continuations is lack of tco on the jvm

22:06 clizzin: what's the equivalent of Class.class in clojure?

22:09 Ramblurr: when interoping with java, how do you pass enum flags like FOO | BAR ? (bit-or FOO BAR) works

22:09 is that the idiomatic way?

22:10 alandipert: Ramblurr: that's how i've done it

22:10 amalloy: clizzin: Class

22:10 clizzin: amalloy: ahh yeah figured it out after mucking about a bit. thanks!

22:11 amalloy: &(nth (iterate class 1) 100)

22:11 sexpbot: ⟹ java.lang.Class

22:11 amalloy: also works :P

22:12 Ramblurr: alandipert: looks like (+ FOO BAR) works too

22:13 alandipert: Ramblurr: and it would also work in java

22:13 Ramblurr: yup

22:13 alandipert: i guess it depends if the enums are powers of 2

22:14 amalloy: well, none none of this would

22:15 ie, if bit-or works, it's because these ints (NOT enums) are powers of two, so + will work too

22:15 alandipert: right

22:36 semperos: I'm using this memoize function from Meikel Brandmeyer's blog:

22:36 https://gist.github.com/954663

22:36 I'm calling it like this, on a function foo

22:37 (def memoized-foo (memoize foo (ttl-cache-strategy 500)))

22:37 I'm getting an arity exception, whereby it says the assoc-in on line 66 of the gist is being past 4 arguments

22:37 anyone care to look and see what I might be doing wrong?

22:39 amalloy: well, you are passing four arguments to assoc-in

22:39 semperos: :)

22:39 amalloy: no joke, it's true

22:39 semperos: I understand that

22:39 amalloy: &(macroexpand '(-> state (assoc-in [:x] args now)))

22:39 sexpbot: ⟹ (assoc-in state [:x] args now)

22:40 amalloy: where you probably want (assoc-in state [:x args] now)

22:40 semperos: yeah

22:41 I htought I was missing something else, bc it was on kotka's blog and folks had been using this code...

22:41 I don't get the use of args

22:41 in this context

22:41 well, nm, I'll fiddle

22:42 yep, that works

22:42 amalloy: thanks

22:42 I need to start trusting my reading of the code more

22:42 amalloy: args is the arguments passed to the function. i assume he's using it as the key in the memoization cache lookup

22:43 semperos: makes sense now that it's corrected

22:52 * technomancy facepalms realizing mire actually uses set! =\

22:52 technomancy: anyway, you guys should all use http://clojars.org/org.clojars.technomancy/lein-search

22:52 because it's awesome

23:00 amalloy: technomancy: 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:01 technomancy: hm; probably true

23:02 lein plugin install org.clojars.technomancy/lein-search 1.0.0-SNAPSHOT && lein help search is the way to go

23:03 for the record, weavejester's clucy lib is pretty handy

23:08 amalloy: technomancy: with lein 1.5.2 that command yields nothing more than a NoSuchMethodError

Logging service provided by n01se.net