#clojure logs

2009-09-12

04:54LauJensenTop 'o da morning gents
04:59LauJensenOk, lemme try that in #scala and see if I get some love
05:09cgrandcome back Lau!
05:10LauJensenAlright alright - You know I can't leave you guys :)
06:48angermanhow do I add additional jars to the default slime-repl clojure?
08:07raphinou_Hi!
08:10arbschtangerman: customize swank-clojure-extra-classpaths
08:10arbschtangerman: alternately, link your jars in ~/.clojure, if that applies
09:16ChousukeI decided it would help to have my reader development history a bit cleaner, so now I'm splitting, merging and reorganising the commits :P
10:00angermanarbscht: thanks
10:00angermanHmm I have 44700 items and I want to draw 10000 pairs from it, how would I do that?
10:01angermane.g. I have 447000 x 447000 paris. and I want to have 10000 different items from that set
10:09le3f
10:17meredyddHi all.
10:17meredyddIs it just me, or has HTTP header updating in Compojure never worked?
10:18meredyddThe handling method is defined with "(defmethod update-response Map", so it never triggers on Clojure persistent maps
10:18meredyddBut if I hand it an honest-to-goodness Java Map, it complains it can't cast it into an IPersistentHashMap.
10:24duck1123_Is it possible to actually run a repl (or a swank server) to an application on an android phone
10:44le3,(doc alter)
10:44clojurebot"([ref fun & args]); Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref."
11:07triyoAnyone purchased the Alpha Program license for the new, up and coming, book "Practical Clojure"? Just wondering if it'd be worth it.
11:07triyohttp://www.apress.com/book/view/9781430272311
11:30manic12now that you point it out (the book), I may get it
11:30triyo:)
11:31triyoI think I'm gonna join you in on that one.....You get the updates till final release anyway.
11:32manic12I disagree with Hickey's description of clojure as a lisp. I think clojure is definitely a clojure and may be influenced by lisp, but leaves that era behind
11:32manic12or, I guess you could say that if clojure is a lisp, it's pushing the envelope of what it means to be a lisp
11:33Chouser"Clojure: redefining LISP"
11:33manic12sequence processing
11:34manic12lazy sequence processing (LSP)
11:35manic12yesterday I had to make a file in the default package called "user.clj" and in the ns declaration I used com.akw.init namespace...
11:36manic12...init.clj then had to include com.akw.user, and have an "init" defn which called a defn in com.akw.user to load my foreign libs and change the ns
11:37manic12it was the only way I could get the repl to start, where I could type one function (init) and have my foreign code be loaded and work
11:38manic12so it took three files to do one thing, and I'm wondering if I am doing something wrong
11:39Chouseryou can provide multiple options at the clojure.main command line
11:39manic12enclojure definitely needs a dialog box option to pass in a custom init to the clojure.main/repl
11:40manic12I'm really having a hard time with this java package & clojure namespace stuff
11:40Chousersomething like -e "(use 'com.akw.user)" -r ought to do it.
11:41manic12does enclojure have a place to put that?
11:41ChouserI don't know.
11:42manic12I'll ask that one on google groups and/or submit a patch
11:42Chousergood idea
11:42ChouserI really do mean to try enclojure again soon...
11:43manic12it just seemed very "unlispy" for the "project repl" to not have any correspondence to the project main
11:43manic12it knows where the libs are, but it doesn't use them by default
11:44manic12(the project repl that is)
11:45manic12also, the foreign lib I use is quite large
11:46manic12for every namespace I use that lib from, I have to have a huge import list in the ns form
11:47manic12so I will probably make a macro that wraps (ns ...) that is like (smlib-ns ...) that includes the package classnames
11:49manic12just seems weird I can't export the classnames as a whole to any nanespace with just one *short* import
11:55manic12I think that my native calls will only work from the namespace I loaded the libs from, so one is forced to use that namespace, maybe it's my imagination
11:55Chouserhave your macro just generate an appropriate call to the 'import' fn. In fact, you might be able to write a fn instead of a macro.
11:56Chouseroh, 'import' is a macro now, so you'll have to write a macro.
11:58Chouserhowever, it's quite intentional that there's no "import foo.*" -- that makes class names available without it ever being explicit where they're coming from, which can lead to confusion and unexpected conflicts.
11:58manic12(it was my imagination...i think)
11:58ChouserI like 'use' does this too (for fn names), but I wish it didn't. :-)
11:59manic12well in this case, all my classes are explicitly defined to java from swig
11:59manic12so it's not protecting me from anything real
12:00manic12I'll look at the sources to import and see if I can make my own import
12:01manic12(which would break anytime clojure changes, but that's better than putting all these class names in a file)
12:08manic12is there a way to get a sequence of all the classes in a java package?
12:15Chousermanic12: no, you have to examine the .jar itself, or the file system.
12:15Chouseronce you have a list of the classes, your macro can expand to a regular call to 'import' so that it won't break when clojure changes.
12:15manic12yah
13:39ole2h
13:43manic12is there a way to stack allocate instances of java classes inside a clojure function?
13:47ChouserI don't think you can allocate objects on the stack in the JVM at all, in any language
13:48manic12this is tricky
13:48manic12(native call stuff)
13:51manic12i guess it doesn't matter since swig has defined finalizations on the objects
13:52manic12the tricky part is that my native calls will be looking for arrays of structs
13:52manic12and the jvm ain't gonna line-em-up for me
13:55manic12i can work around.
13:56manic12it was just cool with double-float arrays in allegro and displaced arrays and such
14:27manic12so in the form (let [x 1 y 2] ... you cannot rebind x to 3 in there?
14:30ole2,(let [x 1 y 2 x 3] x)
14:30clojurebot3
14:31manic12(let [x 1 y 2] (do-something-with x) (change x) (do-something-with x))
14:32ole2i dont think so, but you can rebind it with a let
14:32ole2,(let [x 9] (let [x 10] x))
14:32clojurebot10
14:32ole2there is no setf or setq
14:33ole2i think
14:33ole2,(doc set!)
14:33clojurebotGabh mo leithscéal?
14:33ole2,(doc set!)
14:33clojurebotTitim gan éirí ort.
14:33ole2,(doc setf)
14:33clojurebotPardon?
14:56Chousernames introduced by 'let' are not variables, their values cannot change
14:56Chouserthe closest you can get it to shadow the old local with a new one of the same name
14:57Chouser,(let [a 1] (prn a) (let [a 2] (prn 2)))
14:57clojurebot1 2
17:33ole3n
19:11kanzenryuHello all. I'm thinking of writing a clojure program for Java coders that would demo language features that are awkward to do in Java.
19:11kanzenryuProbably a visual demo that can demonstrate on-the-fly logic changes, showing shapes that are processed according to various rules
19:11kanzenryu- Realtime code updating via a socket REPL while running
19:11kanzenryu- Macros for simple rule DSL
19:11kanzenryu- Agents/STM for multithreaded behaviour.
19:11kanzenryu- Multimethods, hierarchies and derive
19:11kanzenryu- Maybe error-kit for flexible error handling
19:12kanzenryu- Metadata for extra decision logic
19:12kanzenryu- Maybe the dataflow contrib
19:12kanzenryuAny more suggestions?
19:16Chousersounds interesting
19:17kanzenryuVarious groups of shapes appear on the left, and get handled by some rules and sent to various places on the right
19:17ChouserI like the javadoc and show functions at the REPL.
19:18kanzenryuThe shapes will be sandwiches with various contents. I call it the Edible Sandwich Business
19:22kanzenryuMy plan is to showcase whatever aspects of Clojure would make the average Java guy think "man, how would I code that?"
19:28briancarperIf I do (def x "助") with any Japanese kanji, and then view x at a REPL, it shows "???". Also (count x) gives me 3, should be 1. Any idea where I can begin to debug this?
19:30Chouserthat's a plain terminal repl?
19:30Chouser,(.getEncoding *out*)
19:30clojurebotjava.lang.IllegalArgumentException: No matching field found: getEncoding for class java.io.StringWriter
19:30briancarperPlain REPL, yes.
19:30ChouserI'd look at the encoding of the in and out streams the repl is using, make sure they match what you expect.
19:30hiredmanbriancarper: are you using jline or anything like that?
19:31briancarper.getEncoding returns "ASCII". Probably not right. What's a safe way to change it?
19:31hiredmanhuh
19:31briancarperhiredman: Nope, no jline.
19:32hiredmanI wonder were it gets the ASCII
19:32briancarperNo idea. On one of my systems it's "UTF8" but my server gives me "ASCII".
19:32Chouserbriancarper: that's the encoding of *in* or *out*? Or both?
19:32hiredmanwhat platform is this? which jvm, which os?
19:32Chousukebriancarper: works for me.
19:32Chousukebriancarper: are you using a UTF-8 locale?
19:33Chousukethough hm, the count is still 3
19:33briancarperhiredman: Just *out*, not sure how to inspect it on *in*, no .getEncoding method apparently.
19:33hiredmanChousuke: 1 here
19:34briancarperChousuke: Not sure which encoding the system is using. How could I check? It's a Linux box. Checked for LC* variables but there are none set.
19:35Chousuke(System/getProperty "file.encoding") I guess.
19:35Chousukemine is apparently MacRoman...
19:35briancarper"ANSI_X3.4-1968", bwuh
19:36Chousuketry launchign java with java -Dfile.encoding=UTF8
19:36Chousukethat works for me.
19:37Chousukeuser=> (def foo "テスト") user=> (count foo) -> 3
19:38briancarperAwesome, that worked. Thanks! Thanks everyone else too.
19:39Chousukegenerally everything should be fine unless you try to use characters beyond the basic multilingual plane in your identifiers (I think strings will still work)
19:40briancarperYeah I only need it in strings. Wouldn't try it in identifiers.
19:40Chousukeand even if you were writing code with characters from the higher planes I would have to ask you why you're writing code that maybe a dozen people in the world can read...
19:41hiredman,(let [テ1] テ)
19:41clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
19:41hiredman,(let [テ 1] テ)
19:41clojurebot1
19:42Chousukeテ is not beyond the BMP :)
19:44ChousukeAFAIK any character that can be represented with one UTF-16 character (as opposed to "multibyte encoding" it) is supported by Clojure in identifiers
19:44luisChousuke: come on, writing code with egyptian hieroglyphs should be fun!
19:45Chousukehandling all of unicode is a bit of a chore in java because char is just 16-bit, but for most purposes it works fine.
20:21cschreinerDoes this list channel have a log?
20:21hiredman~logs
20:21clojurebotlogs is http://clojure-log.n01se.net/
20:21cschreinerthx
20:25cschreinerthere is much nice stuff in the logs
20:25cschreinerthought I spend the next week reading them
20:38ChrisPStesting
20:38ChrisPSok good
20:45wtetznerwhat's the reasoning for having peek and pop?
20:45wtetznerare they any different from first and rest?
20:46licoresseI believe they have different semantics
20:47wtetzneryou mean the names just match what you would use with a stack?
20:47wtetzneror are there technical differences?
20:47wtetzneroh
20:47wtetzneri get it
20:48wtetzneron a vector, peek and pop happen at the end of the vector
20:49licoresseright
20:50licoressepop on vector and lists behave differently
20:50licoresse,(doc pop)
20:50clojurebot"([coll]); For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the same as next/butlast."
21:03Chouserpeek and pop are only like first and rest for list. they are different for vectors and queues
21:29wtetznerhow do i create a queue?
21:32Chouser,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2))
21:32clojurebot(1 2)
21:32Chouser,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2) pop class)
21:32clojurebotclojure.lang.PersistentQueue
21:32Chouser,(-> clojure.lang.PersistentQueue/EMPTY (conj 1) (conj 2) rest class)
21:32clojurebotclojure.lang.PersistentQueue$Seq
21:33wtetzneroh, so there's not built-in function for creating them?
21:37Chouserright. I think rhickey is still a bit undecided on the right way to expose queue-like things in general.
21:38wtetzneroh, ok
21:42Chouserbut PersistentQueue works well. More efficient than, say, a finger tree...
21:43hiredman
21:46hiredman=> (h (g "suddenly"))
21:47hiredman"CLABANGO!"
21:48hiredmanso I think maybe sometime in the comming week, if I can disentangle all the factoid code from clojurebot's core, clojurebot will start using derby for storage
21:49durka42why a relational database?
21:50hiredmanbecause it's there?
21:51durka42:)
21:51hiredmanit's just a five column table
21:51durka42it seems to me clojurebot would have more of a fit for a key-value store, but i know much more about RDBs than key-value DBs, so clabango
21:54hiredman"oh look, derby! and what's that? clojureql!"
21:55hiredmanall though I think either I don't understand clojureql, or it has a wart or two
21:56hiredmanclojurebot: how much do you know?
21:56clojurebotI know 352 things
21:56hiredman=> (count (query (derby "/tmp/triples.db") :y "is" :x))
21:56hiredman423
21:57hiredmanso once this gets done, clojurebot should be able to store relations besides "is"
21:58durka42cool
22:07ChrisPS...
23:15miltonsilvahey
23:16JAS415hi :-)
23:16miltonsilvaI'm having a bit of troble understanding his piece of code "(fn [[a b]] [b (+ a b)])"
23:16JAS415ok
23:16JAS415well
23:17JAS415it destructures vector [b a]
23:17JAS415and then makes a vector of
23:17JAS415b and (a + b)
23:17JAS415oh
23:17JAS415and is an anonymous function
23:17miltonsilvawait..
23:18JAS415vector [a b] i mean
23:18JAS415i made a typo
23:18JAS415[[a b]] is a destructuring pattern
23:21miltonsilvathe problem I'm having is that acording to the fn defenition there should be something like this (fn name? [params* ] exprs*) so why is this different?
23:21JAS415the name is optional
23:21JAS415hence the ?
23:22miltonsilva:) yes but why two [...] [...] is the seconde an expression?
23:23miltonsilvasecond*
23:23JAS415yes
23:23JAS415second is an expression
23:23hiredmanthe first is too, btw
23:23JAS415is syntactic sugar
23:24hiredman[] is a vector
23:24JAS415well i guess but i feel like that is confusing the matter
23:24hiredmanfns use a vector to specify the argument list
23:25hiredman(fn [x] x)
23:25JAS415well the vector gets macroexpanded into some sort of bindy-form, so afterwards its no longer really a vector, wholly i guess
23:25hiredmanthe function you pasted is like (fn [x] [x])
23:25hiredmanJAS415: no
23:25JAS415hmm
23:25JAS415are you sure?
23:26hiredmanwhen the function is compiled it is turned into something else
23:26JAS415right...
23:26JAS415but if you look at the destructuring bind macro
23:27JAS415it gets used in the (fn [[a b]] ) thing
23:27hiredmansure
23:27Chouserin (fn [x] [y]) I guess [x] is an s-expression, but it doesn't get evaluated. [y] is a normal expression that gets evaluated in the normal way.
23:27hiredmanbut destucture just emits a more complicated vector
23:27hiredman,(destructure '[[x y] [a b]])
23:27clojurebot[vec__2425 [a b] x (clojure.core/nth vec__2425 0 nil) y (clojure.core/nth vec__2425 1 nil)]
23:27hiredman^- vector
23:28Chouser,(macroexpand '(fn [[x y]]))
23:28clojurebot(fn* ([p__2431] (clojure.core/let [[x y] p__2431])))
23:28Chousernested list, let, and vectors.
23:29hiredman:(
23:29hiredmangnarly
23:29hiredmanthen let calls destrucutre
23:29miltonsilvaok first... I lack some fundamental knowledge what is destructing?
23:29hiredmanmy poor beautiful code
23:29hiredman~destructuring
23:29clojurebotdestructuring is http://clojure.org/special_forms#let
23:30miltonsilvaoh handy bot
23:31hiredmanyou can basically pull apart a datastructure and bind names to parts of it
23:32JAS415its the best for macros
23:32hiredman,(let [[x y] [1 2 3]] (+ 1 2))
23:32clojurebot3
23:32hiredmaner
23:32hiredman,(let [[x y] [1 2 3]] (+ x y))
23:32clojurebot3
23:32hiredmanthat puts 1 and 2 from the vector [1 2 3] and binds them to x and y
23:33miltonsilvaso [[a b]] [b (+ a b)] is actually binding /a to /b and /b to (+ a b) ?
23:34hiredmanno
23:34hiredman(fn [[a b]] … )
23:34JAS415returns new vector
23:34miltonsilva(my... imperative guys sure are dumb :( )
23:34hiredmanit's a function that takes 1 arg
23:34miltonsilvahmm
23:35hiredmanthe one arg is pulled apart and the first element of the arg is bound to a and the second is bound to b
23:35hiredman,((fn [[a b]] a) [1 2])
23:35clojurebot1
23:35miltonsilvahmmmmmmmmmmmm
23:35miltonsilvanow I see
23:36hiredmanso you have a binding form that mirrors the structure of the value you are binding
23:36hiredman,((fn [[a]] a) "hello")
23:36clojurebot\h
23:41miltonsilvaok I understand how these nested forms work... but could you explain again what the second vector does? ] [b (+ a b)] [3 5])
23:42JAS415it makes a new vector
23:43JAS415wait
23:43JAS415can you post the whole form
23:43miltonsilva (fn [[a b]] [b (+ a b)])[1 2] [2 3] [3 5])
23:43miltonsilvaups
23:43miltonsilva (fn [[a b]] [b (+ a b)])
23:44JAS415[b (+ a b)] is like making a new vector with those as contents
23:46miltonsilvaoh... so the declaration of a vector is an expression... that's what confused me... thank you hiredman & JAS415