#clojure logs

2011-02-08

00:44defnfirst madison, WI #clojure meetup, complete.
01:04bartjer, I am not able to understand the difference b/w re-find and re-matches
01:05amalloy##(doc re-find) ##(doc re-matches)
01:05sexpbot(doc re-find) ⟹ "([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."
01:05sexpbot(doc re-matches) ⟹ "([re s]); Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to return the groups."
01:05clojurebot"([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."
01:05clojurebot"([re s]); Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to return the groups."
01:06amalloywhoops. silly bots
01:06defn$(doc re-groups)
01:06defn#(doc re-groups)
01:06defn...
01:06defn,(doc re-groups)
01:06clojurebot"([m]); Returns the groups from the most recent match/find. If there are no nested groups, returns a string of the entire match. If there are nested groups, returns a vector of the groups, the first ...
01:06amalloybartj: re-find lets you reuse a matcher object
01:07amalloyto search the same string multiple times (though usually you'd prefer re-seq)
01:10bartjfor all practical purposes, re-seq seems pretty similar to re-matches
01:10bartjexcept that re-seq puts the whole match in a seq
01:15bytecoloram I correct in assuming there is no way to seed the core random functions? rand, rand-int, and rand-nth
01:16bytecolorsince they use the rand method of Math, which creates an instance of java.util.Random, afaik
01:38defnbytecolor: http://richhickey.github.com/clojure-contrib/probabilities.random-numbers-api.html ???
03:43AreliusExcuse me if this question shows a terriable misunderstanding of how variable bindings work but:
03:43AreliusI have a function that I call a bunch to populate a list, this is only done once at load-time.
03:44AreliusDo I have to wrap it in a ref or atom or some such, or is constantally re (def ...) ing it going to work?
03:44AreliusIt seems to work fine, but I am also running it from SLIME, so I don't know if that's always going to be the case.
03:45brehautArelius: if i understand what you are saying, i think theanswer is no. but can you please give an example of your usage?
03:45Areliusbrehaut: yeah....
03:45brehautam i correct that you are not redefining your list?
03:46AreliusWell, I am, second
03:46brehauteg you are doing something like (def my-list (my-complex operation))
03:48AreliusSomething simple like this: https://gist.github.com/816118
03:48brehautdefun ?
03:48Areliusdefn
03:48Areliussorry
03:48brehautnp
03:49AreliusI come from a Common Lisp background.
03:49brehauti think that will actually work in clj1.2
03:49brehautbut not in 1.3 unless you explicity set the var to dynamic
03:49brehauthowever i wouldnt recommend it
03:50AreliusSo, all the appending to the list will pretty much happen at initialization time. so it seems a bit overkill to wrap it with a ref or something.
03:50DranikArelius, that is awfully not idiomatical
03:51Dranikyou should firstly compute the whole list and only then bind it to L
03:51Draniksince all the data is persistent
03:51Dranikit can't be changed
03:51AreliusDranik: Ideally, yes...
03:51AreliusBut I'd like to be able to create it from Macros littered through the code.
03:51brehautyikes
03:51Areliusand having to constrain all the macros to one place would be less than ideal.
03:52DranikArelius, if you are totally sure you need a mutable variable then use refs
03:52Dranikit's easy
03:52brehautArelius: its not overkill to be explicit about your mutables in clojure
03:52DranikArelius, but your gist seems to me simple and you may use persistent data
03:52brehauteven if they only mutate at load time
03:53AreliusWell, I could solve the problem without mutables by writting a pre-processor that would look for all instances of (add-item ...) and put them into a single place.
03:53AreliusFor instance.
03:53brehautArelius: use use a ref or var
03:53brehauts/use use/just use/
03:53sexpbot<brehaut> Arelius: just use a ref or var
03:54AreliusOk, I can do that. I just figured there would be a better way to do that sort of thing.
03:54brehauts/var/atom/
03:54brehautit denotes clearly to any reader that the var is subject to change
03:54AreliusWould it change it if add-item were a macro?
03:54brehautIMO no
03:54DranikArelius, guess it's ok to use mutables in macross
03:55Dranikbcs it is totally another environment. single-threaded usually
03:55brehautArelius: the other option is using the earmuffs idiom
03:55Areliusearmuffs?
03:56brehaut(def ^:dynamic *my-munged-var* [])
03:56brehautand use set! rather than def
03:56brehautoh
03:56brehauthuh
03:56AreliusHow is that differen't then ref?
03:57brehauta ref is an STM variable
03:57brehautit can only be updated in a transactional context
03:57brehautand it is coordinated with any other transaction editing the same ref, and any other refs in the same transaction
03:58brehautArelius: see http://clojure.org/vars http://clojure.org/refs and http://clojure.org/atoms
03:58AreliusHow are dynamic variables protected?
03:58Areliusbrehaut: I read all those, have no idea how dynamic fits into it.
03:59brehautdynamic is metadata
03:59brehautotherwise your hack is going to stop working in 1.3
03:59Areliushmm...
03:59brehautin clj 1.2 and lower vars are as dynamic as possible by default
03:59brehautin 1.3 they are static by default and dynamic with meta data
03:59AreliusAnyways, I tried to flesh out the example a bit, incase this gives you a better understanding: https://gist.github.com/816134
04:00brehautif you try that code with what you have now split over two files it definately wont work
04:00AreliusBecause of namespaces?
04:00brehautyes
04:01AreliusSure, it's not a compilable example, but I think it otherwise gets the point across?
04:01brehautyes
04:01brehautits not much different to multimethods
04:01AreliusYes
04:02brehauthonestly though, i think an atom is probably simpliest
04:02AreliusHow are the decleration of multi-methods updated?
04:02brehauttheres a mutable object behind the scenes
04:03Areliuswith like dynamic, ref, atom, etc?
04:03brehautclojure.lang.MultiFn
04:03brehautits possible to create something similar using deftype i believe
04:04brehaut(deftype is the low level abstraction implementation feature)
04:05AreliusSure, so deftype, and some sort of mutable object?
04:05brehautdeftype _is_ the mutable object
04:05AreliusOhh, hmm
04:05brehautbut seriously, just use an atom
04:06brehautits much easier, its all you'll need, its thread safe
04:06brehautand its very little overhead
04:06AreliusOk, I can do that
04:07brehaut(def L (atom []) (defn addItem [i] (swap! L #(conj % i)))
04:07AreliusAlso, any links on the dynamic metadata, not sure I understand that yet.
04:07brehautdont worry about it then
04:07brehautits just something you would have to encounter if you went down the var route
04:08Areliusbrehaut: Sure. I still would like to understand what it is, so if I ever encounter, or have a reason to in the future.
04:08brehautits real simple
04:08brehaut^ is the metadata reader macro
04:08brehautit attaches the next form as metadata to the form after
04:08AreliusSure, but about the annotation itself, how that works. and when dynamic variable break.
04:09brehaut:dynamic affects vars, and only vars in clojure 1.3 (currently in alpha)
04:09AreliusI assume they break when I try to touch them in threads. But I'm not very clear why. are they really just fully mutable?
04:09brehautno in 1.3 they are static by default
04:09brehautonce defined, you cannot redefine them
04:09Areliusless I set them as :dynamic.
04:09brehautexactly
04:10AreliusSo, that'd allow me to change the decleration. In what manner does that break when I have threads running.
04:10brehautthreads are different
04:10brehautatoms or refs will provide thread safety
04:11brehautvars do not traverse thread boundaries
04:11AreliusAhh...
04:11brehaut(or more correctly, _changes_ to bindings do not)
04:11AreliusSo, if I have another thread running, it wouldn't catch the variable update?
04:11brehautcorrect
04:12Areliusbut presumablly, if I create another thread after updating the decl. that thread should have the new decl?
04:12Areliusfrom, of course the thread it was updated in.
04:12brehautyes
04:12AreliusOk. that makes sense. thanks.
04:13brehautno worries
04:36TobiasRaedermorning
05:39Jewtaeus_maximusHi, I'm completely and utterly new here, why doesn't clojure support TCO?
05:45AWizzArdJewtaeus_maximus: because the JVM doesn't support this.
05:46AWizzArdJewtaeus_maximus: but for all practical purposes you can use Clojure as if it supported TCO. CLJ has 'recur' and trampolines.
05:46Jewtaeus_maximusAWizzArd, how do trampolines work?
05:52AWizzArdJewtaeus_maximus: http://goo.gl/yuCiO
05:55ejacksonJewtaeus_maximus: also, in Clojure, you rarely want to write in a 'Schemey' style. Rather use the seq abstraction either by constructing your only lazy-seqs or using the myriad built in functions.
05:57ejacksonso you end up not needing TCO
06:18Jewtaeus_maximusSo trampoline is more or less: (defn trampoline [f] (if (Fn? f) (recur (f)) f))), AWizzArd?
06:24clgvJewtaeus_maximus: almost. have a look here: https://github.com/clojure/clojure/blob/b578c69d7480f621841ebcafdfa98e33fcb765f6/src/clj/clojure/core.clj#L5040
06:26Jewtaeus_maximusSo f you do (trampoline 3) it reports an error?
06:26clgv&(trampoline 3)
06:26sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
06:26clgvyes^^
06:28Jewtaeus_maximusWhat if I want the final return value of some mutual recursion to be a funtion?
06:29clgvmaybe, you could wrap into some data. but does it really makes sense that way?
07:44AWizzArd$seen rhickey
07:44sexpbotrhickey was last seen quitting 18 hours and 20 minutes ago.
07:47AWizzArdBtw, to the +/- 50 german users: There is also a #Clojure.de channel.
08:19Vinzentflatten always saves order of the elements in coll, right? e.g. things like (flatten [[1 2][3 4]]) always results in (1 2 3 4)?
08:44opqdonutVinzent: that's the idea, yes
08:44MoUsSoRhi, can somebody help me here about a jreality pb ... ?
08:46Vinzentopqdonut, ok, i just wanted to make sure
09:04rahcolaare sorted-sets homogeneous only?
09:05rahcola&(sorted-set :a 1 :b)
09:05sexpbotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number
09:06ejacksonrahcola: if you use a sorted-set-by you can pass a Comparator that can handle inhomogenous sets, otherwise, no.
10:02khaliI'm putting a jar in lib/ and calling lein uberjar doesn't include it in the final jar. Any ways around this?
10:04mefestokhali: you probably have to install that jar first then include it as a dependency in your project.clj. just my guess.
10:05mefestokhali: is this a jar that isn't available on any repository (clojars, maven) ?
10:06khaliyes it is available but it's a newer version than those
10:07mefestokhali: this is probably the long way around of doing this (i'm not too familiar with all lein's features) but if you have maven installed you can update your local repository with the jar yourself (e.g. mvn install:install-file)
10:08mefestoonce you do that and specify the groupId, artifact, etc then you can depend on that specific version in your project
10:09mefestothat's what we do here with some proprietary libs (like oracle's jdbc driver) that aren't available on maven
10:09khalimefesto, cool thanks, i'll try that!
10:22clgvkhali: but putting a jar in the lib directory should work to. it does here. maybe your project.clj specified a different directory name?
10:23khaliwell when i put it into libs after calling lein it actually gets deleted, and that's without mentioning it in the project.clj file..
10:23mefestoany ring users around?
10:25clgvkhali: ah well I know that behaviour. add the following to your project.clj: :disable-implicit-clean true
10:28khaliclgv, oh that did the trick, cheers.
10:36khalihm, final question. im slime how do i change to a given namespace?
10:38raekkhali: C-c M-p
10:39TimMcSo, I'm going to try to write a Swing app in Clojure. I know a little about Refs and a reasonable amount about threading in Java. Where should I start?
10:39TimMc(I.e. I have no idea how to use Clojure's concurrency idioms for this.)
10:40khaliTimMc, i'm attempting the same thing :)
10:40khaliraek, legend, now i'm set!
10:46TimMckhali: Have you made progress on it?
10:50bartjis there a light-weight Clojure library to do mean/median computations other than incanter ?
10:50bartj*are
10:51khaliTimMc, kind of, i first wrote it using netbeans with enclojure, and did the gui using matisse. now i'm trying to do using clojure only and laying it out using miglayout
10:53khaliTimMc, but i'm very new to clojure.. only started learning it a few days ago :)
10:56TimMckhali: Roughly the same here.
10:57TimMcI've written a graphics app in Clojure before, but not one with interactivity or concurrency.
10:57TimMcJust one big window with a non-animated (but dynamically generated) drawing.
10:58khaliTimMc, have you looked at the ants example? wonder if that would give some clues..
10:58odyssomayTimMc, khali http://www.dreamincode.net/code/snippet3252.htm
10:59khaliodyssomay, cheers!
11:00TimMcodyssomay: Ah, that looks helpful -- it has explicit global state, which the temperature converter example does not.
11:01TimMcI see that there are some dosync blocks with side-effects -- is that kosher?
11:01Chousukehmm
11:01Chousukeprobably not
11:03ChousukeI doubt that code is correct in the general case
11:04khalichouser, whats the general principle to obey?
11:04khaliChousuke, rather
11:04Chousukeno side-effects whatsoever in dosync blocks :P
11:05dnolenClojure + Swing using agents - http://stuartsierra.com/2010/01/08/agents-of-swing
11:05Chousukethe event handlers won't probably get executed in multiple threads simultaneously but you might get retries at the very least
11:06Chousukeso you'd get a number of redundant .grabFocus and .setText calling.
11:07Chousukeintegrating a stateful UI library with Clojure's STM and functional programming unfortunately isn't trivial :(
11:07ChousukeI guess agents are a good bet
11:07Chousukeupdate data in a functional way, send UI updates to an agent which then applies them.
11:09TimMcMy program will have a drawing canvas and some buttons, with user interaction constrained by global state.
11:09Chousukethough if you absolutely must never have the UI go out of sync with the data model even for a moment, even that might not work :/
11:09raekkhali: TimMc: check out c.c.swing-utils (especially the do-swing fn) for executing gui code in the swing thread (which swing requires)
11:09TimMcThe most difficult interaction will be when the user is dragging stuff on the canvas.
11:09Chousukeyeah.
11:11raekthis is how I do it for a small project: https://github.com/raek/thiudinassus/blob/master/src/thiudinassus/graphics.clj#L168
11:11TimMcThis will be a double-buffered canvas. If I keep updating the state of some global Ref from the event thread, could I use an agent to update the canvas image?
11:11raekpics: http://raek.se/thiudinassus/
11:11raek(*very* basic, though)
11:14gfrlogis there a function in the core libraries or contrib for getting a list of files in the filesystem?
11:15clgvjava.io?
11:15gfrloglike (clojure.contrib.shell-out/sh "ls")
11:15fliebelmorning
11:15gfrlogyes of course java -- that's what I was trying to avoid
11:16hoeckgfrlog: maybe file-seq ? was once there as an example of using tree-seq
11:16gfrlog,(doc file-seq)
11:16clojurebot"([dir]); A tree seq on java.io.Files"
11:17gfrloghoeck: that looks quite promising, thank
11:17gfrlogs
11:17clojurebotI don't understand.
11:17raekgfrlog: the File class has a method for that
11:18raekah, just read "that's what I was trying to avoid"
11:18gfrlogyeah -- it seemed like the sort of thing that is common enough to have been wrapped already
11:18hoeckraek: how is that colortheme called? (on those screenshots)
11:18raekclojure tends to not add something when a working version exists in java-land
11:19raekhoeck: tangotango
11:19hoeckraek: thx
11:19raekdon't have the URL atm. there exists multiple versions, I think.
11:20raekit is problably this one: http://orgmode.org/worg/color-themes/color-theme-tangotango.el
11:21hoeckraek: just found a one on github too, looks nice and I need some change :)
11:21khalihm, swank-clojure-project hangs on 'Polling "/tmp/slim.10147" .. (Abort with
11:21khaliM-x slime-abort connection')
11:22khalii've started swank using lein swank in the project directory though
11:24fliebelHas anyone in here followed the async ring discussion( http://groups.google.com/group/ring-clojure/browse_thread/thread/243f452c915356c8/ ) a bit? I would like to understand what is proposed here, since Ring does already support OutputStreams and lazy seqs. There was one short message that mentioned this, and talked about duplex, what is meant by this?
11:26raekkhali: if you have started swank manually, connect to it with slime-connect
11:27khaliraek, i tried that but it cant 'see' the namespace of my app (in the repl)
11:27raekkhali: have you loaded it?
11:28raeki.e. pressed C-c C-k in the source file buffer or executed (require 'the-ns)
11:29raekor, what do you mean by "see"?
11:30gfrlogisn't there a macro-thing like (let) that lets all the bindings refer to eachother?
11:30pdkbinding probably does that
11:31pdkletfn if it's all functions and you need them to refer to each other
11:31gfrlogmaybe "...that allows all the bindings..." is a less confusing way to say that
11:31fliebelgfrlog: letfn might be useful.
11:31gfrlogthanks
11:31raekgfrlog: in let, a binding can refer to previously letted values
11:31gfrlograek: I have a pair that are mutually dependent
11:31gfrlogmy first solution was to use an atom, which is terrible
11:31raekgfrlog: but letfn allows you to let a number of functions that are mutually recursive
11:32khaliraek, require worked
11:32khaliraek, im ok now
11:32raekgravity: let is works immutably, and immutable values cannot be mutually referring
11:33fliebelgfrlog: If you feel hacky, you can try #'symbol, or let one of them as nil first, or whatever.
12:04willtimhi guys, is this a bug in clojure?
12:04KirinDavewilltim: This irc message?
12:05willtimfor [:let [xs [1 2 3]] x xs] x)
12:06willtimi.e. :let does not work as the first binding
12:06willtimwhich can be useful sometimes and saves nesting
12:08jkkramerwilltim: :let, :while, and :when are modifiers of the binding (you can have different modifiers for each binding), so no
12:17willtim@jkkramer, yes makes sense, thanks
12:20khaliit was painful to setup but now that i have, slime+clojure rules for swing programming.. :)
12:20odyssomayDoes 'send' spawn a new thread?
12:24odyssomayHmm, it seems like it uses a thread from a thread pool
12:24ejacksonodyssomay: send-off starts a new thread entirely, I believe
12:25odyssomayejackson, ok, thanks
12:29willtim@jkkramer, interestingly, haskell does not have this limitation and guards can be at the top of a comprehension (checking input)
12:35jkkramerwilltim: i think using (let [xs ...] (for [x xs] ...)) is clearer anyway. your way messes with my internal dialog: "for let something x in xs ..."
12:36TimMcwilltim: macro time! :-P
12:53weilaweihttp://pastie.org/1541676 < I get "java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn" when attempting to run iter-fib (on anything, seemingly). It's an exercise from SICP. What am I missing?
12:54weilaweiNever mind, got it.
12:55weilaweiTried to evalulate a value. >_<
12:55TimMcOK, what's the difference between ^String and #^String in the arguments to a function?
12:56jkkramerTimMc: #^String is the old, deprecated way of type hinting
12:57TimMcGotcha.
13:25jweissthis page seems to be out of date: http://clojure.org/protocols
13:25jweisstalks about 1.2 being unreleased
13:31khaliam i missing something or is there no function to find the length of a sequence?
13:31odyssomaykhali, count
13:31khaliooh
13:32odyssomay;) it was the same for me
13:32khaliit makes sense, i guess sometimes you need to compute it, and count is more precise
13:34{aaron}hi. what does a - in front of a function name mean?
13:34{aaron}e.g. http://codingkata.org/katas/unit/hello-world/solutions/view/8
13:35amalloy{aaron}: by default, gen-class causes -foo to become MyClass.foo, i believe
13:36{aaron}ah
13:36{aaron}that makes sense, thanks
13:36amalloykhali: you can also use ##(counted? (range 10)) to determine whether the count will be fast or not
13:36sexpbot⟹ false
13:39khaliamalloy, over my head atm, but i'll jot it down for later
13:40TimMckhali: counted? tells you whether a collection computes its count in constant time.
13:40amalloykhali: lists and vectors store their count in every node, so that (count some-vec) takes constant time; lazy sequences can't do that of course
13:40khalioh understood :)
13:41khalii meant the usage of ## there
13:41amalloyoh that just triggers sexpbot
13:41khaliah
13:41TimMcso ##3 should give me...
13:41amalloyTimMc: nope, sorry
13:41TimMcmaybe ##(+ 2 3) then
13:41sexpbot⟹ 5
13:41TimMcah
13:42amalloy&3 though, of course
13:42sexpbot⟹ 3
13:42TimMcWhy of course?
13:42amalloywell
13:42amalloystarting a message with & is an unambiguous "sexpbot do this for me" command
13:42TimMcGot it.
13:42amalloythe ##hashmarks might be referring to ##java, for example, so he only wakes up if the thing you're trying to eval is a sequence of some kind
13:43TimMcGood point. And I see that clojurebot responds to , as a command trigger.
13:43amalloyindeed
13:44amalloywell, an eval trigger, anyway. sexpbot has a separate "command" structure starting with $, and clojurebot treats ~ as command
13:44amalloy$seen cemerick
13:44sexpbotcemerick was last seen quitting 16 hours and 59 minutes ago.
13:45TimMcBack to type hints... I have a vector (currently of known length) of Point2D$Double that I am decomposing in a let and using in Java graphics calls.
13:45TimMcI'd like to get rid of reflection here. Is there a way to mark the whole vector as only containing Point2D$Double, or will I have to hint that each thing I take out is an instance of that?
13:46amalloyTimMc: the latter
13:46amalloyor you can copy it all into a native java array and type-hint that
13:46TimMcAh, I'll keep that in mind!
13:47amalloythough the syntax for type-hinting it will be pretty gross iirc
13:47amalloy&(import java.awt.Point2D$Double)
13:47sexpbotjava.lang.ClassNotFoundException: java.awt.Point2D$Double
13:48amalloy&(import java.awt.geom.Point2D$Double)
13:48sexpbot⟹ java.awt.geom.Point2D$Double
13:48khaliis there a way to treat a struct as an array of values?
13:48amalloykhali: (vals struct)
13:48amalloy&(class (into-array [(Point2D$Double. 10 10)]))
13:48sexpbot⟹ [Ljava.awt.geom.Point2D$Double;
13:49khaliperfect amalloy
13:50amalloyso TimMc, your type-hint would look like (let [^"[Ljava.awt.geom.Point2D$Double" hinted-val (into-array ...)] (use hinted-val))
13:50TimMceep
13:51amalloyheh, indeed. hinting arrays and/or primitives is a pain
13:51TimMc...and then I'd still have to use Java interop calls to pull stuff out of the array.
13:51amalloyTimMc: well, aget isn't so bad
13:52TimMcCan I destructure arrays?
13:52amalloyTimMc: sure, but then you've lost the type-hinting
13:52TimMcurgh
13:53TimMcIs that something that could be changed?
13:54amalloyummmmm, i don't know
13:54TimMcIt *seems* reasonable, but then I'm not the one writing Clojure's compiler.
13:54amalloyTimMc: well, if it is possible it shouldn't have to involve java at all
13:55amalloy$source let
13:55sexpbotlet is http://is.gd/DlvwkU
13:56amalloylet and/or destructure might be able to get at the :tag metadata and inspect it for arrays
13:56TimMcOh right, it's the macro that would have to do this.
13:57TimMcI was still in non-macro-language land.
13:57TimMcI've been thinking about fancy whole-program stuff like type-inference.
13:59amalloyTimMc: if you've ever written (defmacro ...), then you were wrong when you said you're not the one writing clojure's compiler :)
14:01TimMchaha
14:21hiredman,(namespace 'foo/bar)
14:22clojurebot"foo"
15:07brehautdoes anyone know if fogus's core.unify is in clojars?
15:08rrc7czwhy might I still be getting a "WARNING: alias already refers to..." even though I have a (:refer-clojure :exclude [...]) in my ns?
15:18kencauseyWell, I'm on day two of trying to download Brian Marick's robozzle.mov midge demo/tutorial from github with little progress. Again, has anyone a mirror by chance?
15:22phenom_hey anyone interested in helping me build out a queueing system? i'm doing it more to learn clojure than to compete in the market ... no standards or complexities, just a simple thing
15:22odyssomaykencausey, http://www.vimeo.com/19404746
15:22Raynesdefn: Ping.
15:23phenom_anyone interested, get in touch with me ... github.com/djunforgetable
15:23kencauseyodyssomay: Yeah, vimeo is a problem for me with screencasts because flash won't fullscreen for me and I see no option to popout a resizable window like I would with say youtube
15:24kencauseyI have a dual-head setup which flash is not happy about
15:24odyssomaykencausey, so don't fullscreen?
15:24kencauseythen it's too small to read
15:25odyssomaywhich flash version do you have?
15:25kencauseyLinux 10.2 d161
15:25kencauseythe problem may be with the nvidia driver
15:25kencauseysome applications full screen fine, others don't, flash is not the only one that doesn't
15:28odyssomaykencausey, the flash is streamed to ~/.mozilla/firefox/*.default/Cache/
15:28odyssomayyou can use mplayer or similar to view it
15:29kencauseyodyssomay: cool, that's an idea, although for some reason today the flash viewer is not working at all, I see the default view but no option to start the video, the html5 player works though
15:30kencauseyoh, except I'm not using moz ;) but the idea still holds merit
15:30fliebelbrehaut: It's core.unify, so it ships with Clojure, right?
15:40odyssomaykencausey, If you happen to have flashblock, it doesn't work with vimeo
15:41kencauseyI don't have any blocking of any kind
15:41odyssomayok
15:41kencauseyflash is working fine on other sites
15:41kencauseythis is all rather irrelevant/off-topic at this point
15:42odyssomayyes, you're right, but it's pretty quiet here anyway
15:43kencauseysure
15:46kencauseyActually, this is all moot now, I find that vimeo's html5 viewer 'fullscreens' within the browser boundary (of course) so it works fine and hopefully the quality will be sufficient for my purposes
15:46kencauseybut thanks odyssomay
15:47kencauseyand then I can full-screen chrome and all is still good, enough about that ;)
15:47odyssomayheh, yeah np
16:40rata_hi
16:42ohpauleezDoes anyone know how to select something with enlive that has a space in it
16:45dnolenohpauleez: like a text node?
16:46ohpauleezdnolen: something like: (map html/text (html/select (scrape/fetch-url scrape/*base-url*) [:div.inner :ul.topiclist forums]))
16:46ohpauleezwhere the ul I'm going for is "topiclist forums"
16:46dnolenthe className is topiclist-forums ?
16:47dnolener I mean, 'topiclist forums'
16:48brehautohpauleez: in css, that is actually two classes
16:48dnolen:ul.topiclist.forums
16:48dnolen^ should work
16:48ohpauleezahhh cool
16:48ohpauleezright tight
16:48ohpauleezthanks guys, I really need to focus
16:48ohpauleez:)
16:49brehautdnolen: is the unifier in logos usable outside the context of your miniKanren imp?
16:51dnolenbrehaut: it is, logos.unify/unifier and unifier'. It uses logos.minikanren under the hood, but it provides the same interface as fogus's core.unify
16:51brehautdnolen: sweet :)
16:52dnolenbrehaut: unifier takes prepped sexprs, that is sexprs where the location of the logic vars have already been determined. unifier' can take un-prepped sexprs, but its *dog-slow* cause of post-walk
16:52brehautdnolen: im fine with dog slow ;)
16:53brehautim writing a series of monkey and banana implementations (pg 46 of bratko)
16:53brehautgradually moving from functional to logical
16:53brehauti want to eventually end up with a logos implementation
16:54dnolenbrehaut: nice! there's a pretty wacky critical bug I need to fix ASAP in logos, fingers crossed you don't run into it.
16:54brehauthah cheers :)
16:54brehautim still 2 steps away from the logos imp so hopefully i'll not run into it
17:02lancepantzdoes anyone know how keyword lookups are optimized on records?
17:02lancepantzare they converted to method calls at compile time or runtime?
17:02brehautlancepantz: roughly i think? theres a callsite cache that does that
17:03lancepantzbrehaut: so keywords are hashed and cached at runtime?
17:03brehauti dont know if its hashed or what, but there is a runtime optimsation at the callsite
17:03lancepantzi've got a record lookup in an innerloop and my profiler says a lot of time is being spent hashing keywords
17:04brehautbeyond that i dont know any of the details
17:04lancepantzi had expected that to be converted to a method call at compile time
17:05chouserkeyword lookups are compiled as method calls in case the target changes type
17:05chouserare NOT, :-P
17:06lancepantzi added a type hint expecting that to take care of it, didn't seem to change anything though
17:06lancepantzso if i want full optimization i should just call the methods using interop?
17:06chouseryes
17:06lancepantzgreat
17:06lancepantzthanks chouser :)
17:06chouserthough I think the keyword should get hashed at compile time, so I'm not sure what you're seeing.
17:07lancepantzmost of the activity is in clojure.lang.Keyword.hashCode
17:07lancepantz22% of my execution time
17:08chouserthat method just returns a field of the keyword object
17:09lancepantzso that should be really fast?
17:09chouserone would think, yeah
17:10lancepantzmy loop is calling it alot, i'm going to try interop and see if that helps
17:10chouserbut regardless if you want maximum performance, use sufficiently hinted interop on the record.
17:10lancepantzcool
17:10lancepantzi'll report back :)
17:11jkdufaircan i do interactive debugging in emacs?
17:12jkdufairfound (i think) a bug in appengine-magic and want to step into it
17:14raekjkdufair: haven't tried this myself, but could be worth checking out: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml
17:23jkdufairraek: thanks! i'll check it out
17:28amalloyjkdufair: see also george jahad's cdt
17:28jkdufairamalloy: super. thx!
17:59rseniorI'm hitting a snag with AOT compiling some code. I'm invoking multimethod (based on class) from inside a macro, during AOT compilation, it's treating the defrecord constructor as a list (i.e. (new-foo ...)). If I do not AOT compile, it's treating that same code as the defrecord type (Foo) instead of the persistent list, and it works fine.
18:00rseniorI'm trying to dig a little deeper to see if I'm hitting a bug or if it's just bad macro code, but I'm having difficulty figuring out what's different from AOT and the normal compile/load from the REPL
18:02jweissthis page seems to be out of date: http://clojure.org/protocols - probably just needs to reference to 1.2 being unreleased taken off. reason i bring this up is i'm trying to sell clojure to coworkers and this looks bad
18:03rseniorjweiss: send an email to alex@puredanger.com with that
18:03jweissrsenior: ok will do, thanks
18:06rata_rsenior: have you a gist of that?
18:07rata_*with that code
18:07rata_macro I mean
18:08rseniorrata_: there's several, I could try to isolate it for a gist
18:08rseniorrata_: *there are several
18:08rata_give me one to look at the macro
18:11rseniorrata_: will do, one minute
18:11brehautanyone here familiar with jim duey's state-t from c.c.monads ?
18:14rseniorrata_: https://gist.github.com/817497
18:17rseniorrata_: in that code snippit, record that is being destructured off of the first argument, is being interpreted as a list and the REPL as a record
18:18amalloyrsenior: this doesn't look to me like it should work
18:18rseniorrata_: not sure that tells you much
18:18rata_I think you want to eval the record constructor at compile time
18:19rata_why are you doing it with a macro?
18:20amalloy(record-matcher '(new-baz {:bar ?e})) is what your macro is doing at compile time (note the quote), and i don't see how it ever works at the repl
18:20rseniorthat's a good question
18:21rata_what's record-matcher?
18:21rseniorrecord matcher is the multi-method that is being invoked based on type of record
18:22rsenioramalloy: I agree, not sure why it works at the REPL
18:23rseniorI stumbled on this today when I was switching a piece of previous not AOT compiled code to AOT
18:23rseniorahh, now I remember why it needs to be a macro
18:24rseniorif-match is actually a macro in matchure (https://github.com/dcolthorp/matchure)
18:25rsenior(new-baz {:bar ?e}) has a symbol, ?e that the if-match macro is finding a replacing with a gensym'd symbol behind the scenes
18:25rseniorif the above code is a function, it will try and eval that ?e which will cause problems
18:26rseniorand is actually the error that happens at AOT compile time (and not at the REPL)
18:27rata_do you want to print those two lines at compile time?
18:27rseniorjust for debugging
18:27rata_ok
18:27rseniorI put that there to try and find out what's going on
18:27rseniorand the (class record) part is what's returning a persistent list vs. a proper defrecord type
18:28amalloyrsenior: i don't really know what matchure tries to do, but you might find my article at http://hubpages.com/hub/Clojure-macro-writing-macros useful, regarding what should be a function and what should be a macro
18:33rsenioramalloy: nice entry, what solidified it for me was On Lisp, I found a lot of what was discussed relating to macros carried over pretty well to Clojure
18:34amalloyyeah, most of it applies pretty equally to any lisp
18:35arohnerisn't there a built-in fn to convert a String to byte[]?
18:35amalloy&(.getBytes "test")
18:35sexpbot⟹ #<byte[] [B@1b220a3>
18:35arohneramalloy: thanks
18:35amalloy&(seq (.getBytes "test"))
18:35sexpbot⟹ (116 101 115 116)
18:36amalloyjust checking :P
18:36ninjuddcan type hints use an interface instead of a class?
18:37arohnerninjudd: I think so
18:37amalloyninjudd: i don't see why not
18:37amalloyyeah, there are type-hints on j.u.Collection somewhere in core, i think
18:38rata_rsenior: when you remove those println, does it work?
18:39amalloyrata_: if that fixes it he should probably call an exorcist
18:41rata_hahahaha... the thing is, I don't see why the `(if-match ...) shouldn't work, he's unquoting everything in that expression
18:42rata_I suppose he's checked that (if-match [(record-matcher (new-baz {:bar ?e})) nil] (some ...)) works as he expects
18:42amalloyrata_: that's not what his code expands to
18:43rata_why not? what am I missing?
18:43amalloyi think he may actually mean `(if-match [(record-matcher ~record) ...])
18:43rata_yes... probably
18:43amalloybecause he's trying to do the record-matcher call in the macro context instead of the expansion context
18:43rata_yes... that was what I was missing =P
18:47amalloyi don't know if that will fix his problem because he's trying to have compile-time access to the run-time information contained in (new-baz ...)
19:24amalloyargh, clojure has poisoned my mind. i find myself trying to implement lazy sequences for php just so i can generalize existing code
19:32brehautamalloy: lol :)
19:32brehautits when you start trying to write point free PHP that you know you have lost it
19:34amalloybrehaut: surely someone out there has written a haskell=>php compiler
19:34amalloyit's just such a natural combo of languages...
19:34brehauthaha
19:34brehautone of the most academic languages wobbling along ontop of one of the least
20:17phenom_anyone else getting a small list for elpa package-list-packages command in emacs ?
20:35amalloyphenom_: i get 134
20:45brehauthas anybody used matchure?
20:45TimMcI AM A GOLDEN GOD
20:46TimMcahem, sorry
20:46amalloybrehaut: rsenior was having trouble with it earlier, maybe send him a $mail?
20:46TimMcJust figured out the change of coordinates math for some graphics stuff.
20:46brehautamalloy: cheers
20:47TimMcAnybody have recommendations for a matrix lib?
20:47amalloyTimMc: http://download.oracle.com/javase/1.4.2/docs/api/java/awt/geom/AffineTransform.html is probably useful?
20:48TimMcamalloy: Unfortunately, this is for a Computer Graphics homework assignment, and I think we're supposed to do the math ourselves on this one.
20:49TimMcamalloy: My breakthrough was in understanding the order in which all the component transforms need to happen.
20:52TimMc...but I really should ask the prof if I can use the Java2D math classes.
20:54amalloyTimMc: yeah, if you are going to use a matrix library, you might as well use the one designed for graphics, it seems to me
20:54TimMcTrue.
20:54amalloyand trust me, getting the order right will still matter with affinetransform :)
20:55TimMcindeed
20:55amalloyi vaguely remember similar issues when i was in college
20:55TimMcThis is the first time I've needed to do anything more than flipping the y coordinates and translating the origin.
20:55amalloyah. fitting to a window, i bet?
20:57TimMcWell, anything where I wanted standard (integer) Cartesian coordinates.
20:58TimMcOh man, I remember writing stuff for my TI-89 graphing calculator... wrote a Mandelbrot fractal program that took 6 hours to run.
20:58TimMcANyway.
20:59amalloyhaha good old ti
20:59amalloymy early programs were for the 83
21:00TimMcI still have that 89. It's about 13 years old now.
21:01TimMcMaybe I'll write a Scheme interpreter for it some day. The parentheses are easy to reach on that keyboard.
21:19pppaulhey dudes
21:19pppauli'm using lein, and i want to slurp a file: "file.txt" where should i put the file so (slurp "file.txt") works?
21:22pppaulgot it
21:22pppaulthanks guys!
21:22pppaul:D
22:40phenom_how to you stop a cake swank server?
22:40amalloycake kill
22:53anthony__The docs for the logging functions say that log4j is supported, and I'm able to get it to work when running my program from the REPL, but log4j doesn't seem to work after compiling with lein. Is there a better logging library, or am I doing something terribly wrong?
22:58amalloyanthony__: well, usually you shouldn't need to compile
22:59amalloybut you need log4j.properties in your classpath, which probably isn't making it into the jar
22:59anthony__amalloy: What's the recommended way of running clojure programs? I've always used lein jar (or uberjar).
22:59foxupahello
23:00anthony__Yeah, I want it outside of my jar in case I need to change it. But it's in my pwd. I'll mess around with it some more.
23:00amalloyanthony__: i think lein run should work without compiling
23:00amalloyanthony__: your cwd isn't included in the classpath when running a jar
23:00anthony__amalloy: Oh, gotcha. You mean straight to "lein jar"?
23:00amalloyyou probably want to add a resources directory
23:00foxupaI was wondering if anyone could show me how to redefine the eval function (I want to write metacircular evaluators)
23:01amalloythere's an entry in project.clj to specify directories to include straight in the jar
23:01anthony__amalloy: Gotcha. I was hoping to be able to run log4j.properties outside of the jar, so I could change it without re-packaging. But including it won't hurt. Thanks for the help.
23:02scottjfoxupa: maybe call it something different?
23:02amalloyanthony__: you shouldn't need to package at all while you're developing
23:03scottjfoxupa: there is some form I think you put in (ns) that will exclude stuff from clojure.core I think
23:04anthony__amalloy: Yeah, I'm not. Logging worked just fine during development. I'm packaging it up to send to a friend to use, and he might want his logging path to be somewhere different than mine. He's smart enough to change the file in the JAR, though, so no biggie.
23:04amalloyscottj: :refer-clojure
23:04foxupawell what I want is to be able to do (def eval [x] (eval (do (print x) x)))
23:04foxupafor example
23:04foxupaso that any call to the eval function prints out the argument
23:05amalloyfoxupa: maybe robert.hooke?
23:05amalloyi haven't used it but that sounds like an appropriate tool
23:06amalloyi think it's one of technomancy's toys
23:07foxupathanks amalloy, I think this will do the trick
23:08foxupaamalloy: although it is a bit dissappointing that this can't be done more naturally... is clojure.core somehow protected from redefinition?
23:08scottjwaht about going into clojure.core and evaling (defn eval [form] (println form) (. clojure.lang.Compiler (eval form)))
23:09foxupascottj, how do I go into clojure.core? Do I just some kind of (use-namespace clojure.core) call to step into it?
23:09scottjslime?
23:09clojurebotslime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72
23:09foxupascottj, sorry, I'm just giving Clojure a test drive coming from a scheme background
23:09pdki think the idea is clojure.core is imported automatically at start
23:10pdktry doing say (doc print) or something
23:10pdknotice "clojure.core/print"
23:10scottjin slime ,clojure.core, in repl (ns clojure.core) I think, in code maybe (in-ns..
23:10pdkso it's auto :use-ing the names out of core
23:11pdkpractical clojure has a chapter on namespaces and the funky handful of ways to import stuff
23:11foxupascottj: awesome I got it to work... thanks a lot, I was scared for a bit that I wouldn't be able to do this (or have to go through some obscure hack to get it to work)
23:12foxupascottj, I suppose now I can dive into clojure!
23:12scottjlike a true schemer!
23:12tomojcan't wait until lamina's async works :D
23:12scottj(by fiddling with evaluators instead of "real" projects :)
23:12technomancyclojurebot: shut up man; that is a terrible link
23:12clojurebot'Sea, mhuise.
23:12technomancyclojurebot: forget slime-install
23:12clojurebotI don't understand.
23:12technomancy...
23:13foxupascottj, the main pull was that clojure nearly quarters my scheme code base having elegantly implemented most of my machinery into the language
23:15foxupascottj, just one last question but as clojure is a lisp, I really should be able to completely redefine whatever part of the language I want correct? or are there any subtle limits I should be aware of?
23:16scottjfoxupa: I don't know but I'd guess there are some
23:16headlessClownno custom reader macros
23:16scottjheadlessClown: easily anyway
23:59no_mindis there a way I can identify the datatype of a var ?