#clojure logs

2012-05-02

00:02devnarohner_: thanks. I'm using (line-seq (io/reader (io/file filename)))
00:02devnarohner_: does that look "new" and shiny?
00:03arohner_devn: yes, but you should use with-open on that reader
00:03devnarohner: ah! right. thanks.
00:04devnarohner: (with-open [f (io/file filename)] (line-seq (io/reader f)))), yeah?
00:04mefesto(line-seq f)
00:05mefestoerr...
00:05mefestodevn: open the reading in the with-open bindings
00:05arohner(with-open [r (io/reader (io/file filename))] (line-seq r))
00:05mefesto(with-open [rdr (io/reader (io/file filename))] ...)
00:06arohnerand you'll want to force that lazy-seq before the with-open closes
00:06arohnerso doall, or doseq or along those lines
01:07felideonif lein deps brings in a lib for my project
01:07felideonwhat's the best way to modify that lib? caan i just edit the code in the jar and recompile?
01:22felideonhmm i guess i'm looking for :java-source-path ?
01:32felideonmeh i have no idea how this works
01:33raekfelideon: editing the jars is not a good idea
01:34felideonraek: yeah, that's what i figure. it's that that's where M-. takes me so it's so tempting
01:34raekfelideon: do you want to modify the source of a library that you are using? or do you just want to have java source code in your project?
01:34felideonraek: the former
01:34_KY_What format escape code should I use to printf a clojure term?
01:35felideonraek: i.e. i am have a korma dependency, and i want to modify korma
01:36felideons/am//
01:36raekfelideon: then you need to clone the korma git repo, make the changes, and run lein install in your clone
01:36felideonoh ok lein install
01:36raekfelideon: you can also use the "checkouts" feature of Leiningen
01:36felideonand then from my project, I just recompile?
01:37raekno, you have to run lein deps and restart your repl
01:37felideonwat
01:37raekbut with checkouts you don't have to run install and deps
01:37felideonand what about the :dependencies part of project.clj, that stays the sam?
01:38raekyes
01:38raekbut it's probably wise to change the group name of korma in your own modified version
01:39felideongroup name?
01:39felideonraek: so when is :source-paths used?
01:40raekalways, but you need to restart your repl for it to work
01:40raekfelideon: I think checkouts is what you want here
01:40felideonraek: yeah looking into tha
01:40raekfelideon: it is explained here https://github.com/technomancy/leiningen
01:40raek(search for "checkouts" on that page)
01:40felideoni see what it means by 'install/switch/deps/restart' now
01:41felideonraek: yeah thanks
01:41raekit will add the correct source path for the korma project to your other project
01:42felideonwhat about if i want to use a newer jdbc driver for postgres? that's a jar, how would I use that?
01:42raekthe group identifier is the optional part before the slash in a dependency name
01:42raekdoes that version exist in the maven repos?
01:43raekusing "free floating jars" is discouraged
01:43raekit is motivated here https://github.com/technomancy/leiningen/wiki/Repeatability
01:45felideonoh i see
01:46felideonraek: well thank yoiu
01:48raek_KY_: to correctly print a clojure form you need to use one of pr, prn, or pr-str
01:48raekfelideon: np
01:49raek_KY_: (printf "a form: %s" (pr-str a-form)) will work, but (do (print "a form: ") (pr a-form)) will be more efficient
01:50_KY_I see....
01:50raekbut this might not be an issue unless the forms are very large
01:50_KY_I was just thinking there may be a % something
01:51raekthat would be convenient I guess, but currently the format string is processed by java
01:52raekjava.util.Formatter is used as it is
01:54felideonraek: so once i add a checkouts folder and symlink, do i still need to do a lein deps again?
01:55raekfelideon: I don't think so. but you do need to restart your clojure instance
01:56raekif you run "lein classpath", the checkout project should be there
01:59felideonraek: i see. yes it works now
02:00felideonI can M-./hack/C-c C-c and it does teh right thing :)
02:01raekdon't forget to make a pull request and/or open a issue when you have a fix for korma...
02:02felideonyeah was about to open an issue. :)
02:07felideoni guess i might as well just pull request
02:11felideonhmm should i create a branch for this even if it's one commit?
02:20felideondone https://github.com/ibdknox/Korma/pull/59
02:51anekosls
02:55LuminousMonkeyAccountsSystem Documentation Jobcard dotfiles
02:55LuminousMonkey/home/anekos/ $:
02:55LuminousMonkey:P
02:56anekosLuminousMonkey: Thanks :D
03:21_ulisesI'm having issues running tests (using clojure.test) in heroku while the tests run (and pass) just fine locally. Is there anything special about the Heroku setup whereby tests would fail with java.io.FileNotFoundException?
03:56fliebelWhat is the core.reduce thing about?
04:08amalloyfliebel: i think the idea is to get a version of map and reduce and similar functions that don't use any more intermediate sequences/objects than necessary
04:10amalloyeg, (magic-reduce + 0 (magic-map inc (magic-map inc xs))) being equivalent to (loop [acc 0, xs xs] (if-let [[x & xs] (seq xs)] (recur (+ acc (inc (inc x))) xs) acc))
04:30fliebelamalloy: hm, interesting.
04:33devnhmph -- not sure what changed, but all of a sudden my clojure repl in emacs doesn't open a buffer with the stacktrace of the error with info
04:33devnit just prints ";; Evaluation aborted", no temporary buffer
04:33devnanyone have any ideas?
04:40devnugh, this feels so ugly...
04:40devn(defrecord Node [depth interpreted-type interpreted directive? selector attributes content])
04:41devnthen a moment later: (let [[a b c d e f g h] (re-find #"complicated-regex"))
04:41devnexcept imagine a-h are those long names above
04:41devnanyone have any suggested refactorings?
04:49tsdhdevn: Wrt. the ";; Evaluation aborted" issue, I've had similar problems with certain errors. The reason was that there was a buggy clj-stacktrace version packaged in leiningen. Not exactly sure, but I think it slurped backtraces containing nested classes like Foo$Bar.
04:49tsdhdevn: But you should be able to see the backtrace in the *swank* buffer.
05:00echo-areaswank-clojure uses Clojure 1.2; how to let it use Clojure 1.4?
05:07devnecho-area: dont use swank-clojure unless you are installing it as a lein plugin
05:07devnlike lein-swank
05:08echo-areadevn: But I'm using it as a lein plugin
05:08creeseI have a function that looks like (apply merge (map #(hash-map % (first z8)) (first x8)))
05:09creeseit works if I only use the first elements of z8 and x8, how can I make it work for all of them?
05:15kijcreese: (apply merge (map #(hash-map % [:a :b :c]) ["a" "b" "c"]))
05:15kij-> {"a" [:a :b :c], "b" [:a :b :c], "c" [:a :b :c]}
05:17creesez8 looks like ("one" "two"), x8 looks like ((1 2 3) (4 5 6))
05:17creeseI want the "one" to go with the (1 2 3) and the "two" to go with the (4 5 6)
05:21kij(map #(hash-map %1 %2) '("one" "two") '((1 2 3) (4 5 6)))
05:24creeseI think I wasn't clear on what I want
05:25creeselet's the inputs are x8= ((1 2 3) (4 5 6))
05:25creesez8= #{"abc" "def"}
05:25creeseI want the output to be a hash
05:26creese{1 "abc" 2 "abc" 3 "abc" 4 "def" 5 "def" 6 "def"}
05:42wei_I'm trying to call a Java function with this signature: public void emit(final String event, final Object... args), but (.emit socket "msg" "3232") gives a ClassCastException. what gives?
05:44tsdhwei_: Object... is an object array. So you want (.emit socket "msg" (to-array ["3232"]))
05:45wei_oh, that works. thanks! got confused since i thought … meant arbitrary arity in Java
05:46tsdhwei_: Yes, it means arbitrary arity in Java. But on the bytecode level, it's a method that receives an array as last parameter.
05:48wei_the java compiler's transforming the last params into an array, i see
05:59wei_creese: (let [a [[1 2 3] [4 5 6]]
05:59wei_ b ["abc" "def"]]
05:59wei_ (apply hash-map (flatten (mapcat #(map (fn [k] (list k %2)) %1) a b))))
06:00wei_-> {1 "abc", 2 "abc", 3 "abc", 4 "def", 5 "def", 6 "def"}
06:03creesewhat happens if the a is [[1 2 3] [1 5 6]] ?
06:03creesedoes the 2nd "1" clobber the first?
06:04creeseduplicate key error
06:08creeseif I have a duplicate key, do I have take these into the hash at different times. I want to store both results, so the vals of the hash are a set
06:49michaelr525any way to specify a string with qoutes without escaping them?
06:54creeseexample?
06:54clojurebotexamples is api examples
07:15fliebelmichaelr525: Not really. No multiline string syntax like Python or something like that.
07:21michaelr525yeah
07:22michaelr525what would be a good way to perform multiple operations on a map?
07:22michaelr525nm
07:22antares_michaelr525: it depends on what operations
07:23michaelr525ok
07:23michaelr525{:url :a :b :c}
07:23creeseI have a hash or sets created as a ref with empty sets. I want to fill them.
07:23michaelr525i want to url-decode :url and then conj :d :e :f to the map
07:24creeseset looks like: { a #{ } b #{ } c #{ } }
07:24fliebelmichaelr525: Have a look at &(doc ->)
07:24michaelr525{:url "http://som%et%hing" :a 1 :b 2 } -> {:url "http://something" :a 1 :b 2 :d 3}
07:25fliebel&(doc ->)
07:25lazybot⇒ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
07:25antares_michaelr525: you can do (-> m (update-in :url (fn [s] …)) (assoc :d :e)), for example
07:25michaelr525fliebel: my problem is that assoc does not mutate but rather returns a new map
07:25michaelr525ah
07:25michaelr525update-in
07:25creese(conj (@hash 1) "aaa") allows me to write but not persistently, how do I use (do sync (alter __some stuff with conj___) to get this to work?
07:26michaelr525thanks. :)
07:26antares_creese: you need to use alter! and merge-with. Here is an example that uses a custom fn + atoms: https://github.com/michaelklishin/validateur/blob/master/src/validateur/validation.clj#L76-98
07:27wei_creese: to answer your previous question, (let [a [[1 2 3] [1 5 6]] b ["abc" "def"]] (into {} (mapcat #(map (fn [k] [k %2]) %1) a b)))
07:27antares_creese: looks like alter doc example has almost what you need? http://clojuredocs.org/clojure_core/clojure.core/alter
07:29creeseantares_: almost, but the extra level of hierarchy introduces enough of a difference that I can't get it to work
07:32michaelr525does a function already exist which returns a [key val] pair from a map by the key?
07:32michaelr525of course it's not hard to write one but I wonder whether there is already something in clojure.core
07:34creesemichaelr525, have you looked here? http://clojure.org/cheatsheet
07:34michaelr525(select-keys)
07:34michaelr525haha
07:34michaelr525just what i need
07:35michaelr525cheatsheet looks useful too :)
07:36creeseI have found it to be
07:37creeseso if I, (conj (@words \b) "aaa"), I can write to the data structure, but changes don't stick
07:38creesehow can I wrap this inside a dosync( alter … ) ?
07:38antares_creese: in clojure, conj produces "copies"
07:38antares_creese: that's the whole point of immutable data structures and it makes a whole class of concurrency problems go away
07:41antares_creese: https://gist.github.com/747fd0d63e25b2fc1ebf
07:41antares_creese: are you sure you need to use refs? unless you coordinate these updates with something else, an atom will do
07:42creeseI'm not sure which one I need
07:43antares_creese: when not sure, start with an atom
07:44creeseupdate-in
07:44creesethanks
07:45antares_creese: here's a similar example with atoms (it could also be done with update-in): https://github.com/michaelklishin/validateur/blob/master/src/validateur/validation.clj#L76
07:45creeseif I use an atom, alter -> swap! and I remove dosync?
07:49antares_creese: right
07:50creesewhy do I want to use atoms instead?
07:53antares_creese: because STM has certain limitations and overhead atoms don't have, so if you don't need coordination, why use refs
08:14jweissis it correct that code passed to a macro may or may not have had its macros expanded already?
08:16jweissi guess what i'm asking is, if my macro just removes code that contained another macro call, will that prevent that macro call from ever happening?
08:18jayunit100is there a way to abort a filter
08:18jayunit100i.e. (filter-until)
08:18jweissjayunit100: yes, use take-while
08:19jayunit100ah ok . but take doesn't filter...
08:19jayunit100thats fine.
08:19jweiss,(take-while even? (filter #(> % 0) [-1 -3 4 -5 6 -3 3 8 9]))
08:20clojurebot(4 6)
08:20jweissjayunit100: you're depending on lazy evaluation there.
08:20jweissso it won't go through your whole sequence
08:20jayunit100oh ok so it doesnt start the while condition until "true" ...
08:21jayunit100i mean, it doesnt start checking to abort until the condition is found to be true.
08:21jweissjayunit100: filter produces a lazy sequence - meaning each item in the result isn't fetched until (take-while ...) asks for it.
08:21jayunit100ah nm : you apply the filter first.
08:21jayunit100yup
08:22jweiss,(take-while #(< % 10) (range 1000000))
08:22clojurebot(0 1 2 3 4 ...)
08:23jweiss,(take-while #(< % 3) (range 1000000))
08:23clojurebot(0 1 2)
08:23jweissnotice the huge list of a million numbers is never created
08:23jweiss,(take-while #(< % 3) (range 100000000))
08:23clojurebot(0 1 2)
08:25jayunit100yup
08:25jayunit100thanx
08:25jweissnp
08:38espeedIn Emacs SLIME, I can C-c, C-c over a print statement and it will display the output in the SLIME REPL. How do you display a functions value in the REPL without using print?
08:49creeseespeed: just evaluate at the command line, the return value of the function is printed
08:55espeedWell C-M-x displays the value in the minibuffer
09:10FrozenlockI have a problem with Seesaw... the hyperlink function doesn't behave like expected. In its own example, (hyperlink :text "Click Me" :uri "http://google.com&quot;) gives a link with the URI as the clickable text, instead of "Click me". Any workaround?
09:43wmealingok, this might be a too lazy of question, but can i get the output of the command lein midje --lazytest in my emacs window ?
09:43kaoDhello :)
09:44kaoDis there any way, given a symbol (+, /, *) to "cast" it to a function? using '(+ 1 3) treats + as symbol not as a function
09:49kaoDokay "resolve" does the trick
09:57gfrederickskaoD: depending on what you're doing, you might need to be aware that resolve is relative to a namespace
09:59kaoDgfredericks: nah, it's for 4clojure (a clojure problem collection, in case you don't know) but it caps resolve in the sandbox too so I ended up resolving it to a map {'* * '+ +...}
09:59kaoDwhich is what I wanted to avoid
10:00kaoDthanks anyways :)
10:08cduffymefesto: any thoughts on providing a public mechanism to rebind *connection* and kin with pre-built AMQConnection objects (and similar) rather than requiring a new broker/connection/&c. to be made every time one wants to bring them into scope?
10:12tomoj`cljsc '{:optimizations :advanced}' foo.cljs` doesn't seem to work for me
10:12tomojthe args passed to transform-cl-args in cljsc.clj are ("{:optimizations" ":advanced}" "foo.cljs")
10:13tomojany clue why? this used to work, I'm sure...
10:14tomojoh
10:14tomoj`cljsc foo.cljs '{:optimizations :advanced}'`
10:14tomojd'oh
10:43michaelr`devn: you here?
10:58jweissis there any functional difference between (ns blah (:use 'otherthing)) and (ns blah) (use 'otherthing) ? for instance maybe the macro saves some computation or loading if the current namespace gets reloaded? or is it just sugar?
10:59jweissi notice the macro calls with-loading-context, but i'm not sure what that does exactly.
11:13devngah! michaelr` shows up and then he's gone
11:13devnblast.
11:13TimMcShort-timers.
11:55dnolenjonasen: ibdknox: open to your guys thoughts about the CLJS AST based on rhickey's post since you all are consuming that stuff. children -> children keys + whatever extra data is necessary to make it work sounds like it solves a) and b)
12:06fliebeldnolen: What post?
12:07dnolenfliebel: clojure-dev post
12:08fliebelk
12:08dnolenthread on fixing on the AST emitted by the CLJS analyzer
12:08dnolenfixing the AST
12:08gfredericksfliebel: http://groups.google.com/group/clojure-dev/msg/8d62c000aa9ac80b I assume
12:14meliponehow can I modify the slots of a defstruct object? Forex, I have (def myrect (struct rect :width 5)) and I want to modify the width slot while keeping the same object.
12:15TimMcmelipone: Does assoc do it?
12:15TimMcOh wait, mutation?
12:16fliebelmelipone: Not, you can't modify a struct
12:16meliponefliebel: I can't? I know I program like Java :(
12:16fliebelmelipone: What do you want to do?
12:17TimMcmelipone: And I'm pretty sure structs are deprecated.
12:17meliponeI just want to modify one slot while keeping the other slots identical
12:17meliponeTimMc: deprecated? replaced by what?
12:17S11001001so assoc and use the new object
12:18fliebelmelipone: I mean, why do you need to modify the object, instead of continue what you where doing with the new version?
12:18fliebelmelipone: defrecord
12:18dnolenmelipone: defstruct is deprecated
12:18meliponefliebel: really, defrecord?
12:19meliponebut defstruct has been there since C ...
12:19fliebelmelipone: A clojure struct isn;t the same thing I believe.
12:19S11001001truth
12:19gfredericksmelipone: if you don't have a particular reason to use a struct/record, you're probably better off with a map
12:20fliebelYou can take a java.util variety if you *really* need the mutation, or stick it in an atom or something, but most likely you *think* you need to mutate it.
12:22fliebelI think of it like this. if I do (+ 2 1) do I change 2, or do I get a new number, 3?
12:22meliponeok, ok ...
12:24technomancy_ulises: leiningen on heroku runs with LEIN_NO_DEV=y in order to keep tests off the classpath during production
12:25technomancy_ulises: there are a few ways to work around that depending on what you're shooting for
12:46jonasendnolen: I still don't see what :children-keys would give us.
12:47dnolenjonasen: a way to walk the AST without knowing anything.
12:48jonasenThe children of an expression can't be described as just a vector of keys
12:48dnolenjonasen: yes, we know that. I'm just suggesting that we think about what it should look like.
12:49jonasenanother approach would be to (merge {:op ...} (delay {:children ...}))
12:50dnolenjonasen: that doesn't avoid the problem with the multimethod issue
12:51jonasendnolen: that's probably true
12:52platzhirschI have a checked out a clojure project and just get started, is lein the preferred tool to deal with clojure projects? Currently I just have generated the pom file and work on the maven stack
12:53mefestoplatzhirsch: lein is preferred
12:53RickInGAI am playing around with an example, trying to simulate defmacro... I can build the function but can't assign any meta data https://refheap.com/paste/2505
12:53TEttingerplatzhirsch, both are usable, maven may be more usable for mixed java/clojure projects, but lein is generally better
12:54jonasendnolen: what about *include-children*?
12:54platzhirschTEttinger: ideal, good to know
12:57TEttingerplatzhirsch, lein uses maven internally, so pretty much anything maven can do, clojure can do with a fraction of the configuration
12:57aphyrIs there any reason to prefer EPL over apache v2, for clojure projects?
12:57TEttinger*lein can do with a fraction
12:58technomancyaphyr: apache technically requires annoying license boilerplate in every file
12:58technomancyaphyr: also EPL makes users share the modifications they make to the project
12:58pjstadigtechnomancy: huh?
12:58pjstadigi don't think v2 does
12:59technomancypjstadig: that was one of the points against it when we were considering how to license mirah
12:59technomancyI think we ended up just pretending it didn't say that though.
13:01pjstadigwell regardless some kind of license notice at the top of every file isn't a bad idea in my mind
13:01pjstadigif people want to crib just one file and not the whole project, it lets people know how it's licensed
13:01ibdknoxRaynes: technomancy: finally updated lein-noir
13:02pjstadigbut yeah technomancy's second point is the biggest difference, EPL is weak copyleft, so changes to the original project must be shared
13:02technomancyyeah, I don't think the boilerplate issue is a big deal since there is probably nothing wrong with ignoring it outright =)
13:03technomancy*probably* nothing, don't trust legal advice you get on IRC, etc.
13:03aphyrNaturally.
13:03aphyrCompany I work for uses apachev2 for all their OSS stuff, but Riemann is already licensed under EPL.
13:03technomancyibdknox: great; thanks. will be nice to be able to specify the shorter invocation for docs and stuff
13:03muhoopeople have gotten rather lax in recent yearss with license stuff
13:03aphyrTrying to figure out if I should relicense it or just keep going.
13:04technomancymuhoo: yeah, the number of completely unlicensed projects on github freaks me out
13:04Miko2I prefer using BSD as I simply don't care what people do with my code.
13:04technomancyMiko2: BSD has no patent protection, so watch out
13:05technomancysomeone could submit a patch in good faith and if their employer got acquired by a hostile corp your users could be in trouble
13:05pjstadigi lean more towards public domain (like creative commons CC0) but there are issues with that, and of course patents are a problem
13:05technomancyI'm a big fan of the EPL; I like everything about it except the name =)
13:06RickInGAyou can pretend the e stands for emacs
13:06RickInGAno one will know :)
13:06Miko2technomancy: You mean, someone could take my code and create a patent over it and then sue me? :P
13:06pjstadigtechnomancy: yeah, but it requires distribution of changes to the original project
13:07pjstadigwhich isn't a terrible thing, but i'd prefer not to force people to release their code if they don't want to
13:08aphyrYeah, good point. It's probably OK if I don't follow the rules of the apache license re attributing *every change* in each file, license headers on each file, etc.
13:08solussd_I'm trying to add some items to my 'head' section using enlive's "append" transformer. The values are coming from hiccup.page/include-js, but append escapes the angle brackets. Does anyone have any insight into this?
13:08aphyrI would prefer to let people make private changes.
13:08aphyrOtherwise EPL fits my needs pretty well.
13:09technomancyMiko2: they could use a patent that applied to their contribution that you accepted
13:09pjstadigI actually like the CDDL better than EPL as a weak copy-left license
13:09technomancyRickInGA: haha
13:10pjstadigonly slightly, though, and only in the way that people can "like" open source licenses
13:10Miko2technomancy: Can you really make a patent out of something that is already out there as open source?
13:10technomancypjstadig: what's the difference?
13:10muhooi like open source licenses a LOT better than i like closed licenses
13:10technomancyMiko2: it's amazing what you can get away with
13:10technomancyamazing/depressing
13:11Miko2I think in Finland that's not possible, but may be in USA. :/
13:11muhoobut the whole licensing issue often feels like incidental complexity to me
13:11technomancyprobably true; the USA is particularly insane in that regard
13:11technomancyEPL and apache make it so if you submit a patch, you must also grant a license for any patents you own that may be covered by that patch.
13:14Miko2And adding that clause to BSD license would probably require an army of lawyers.
13:15ibdknoxis there a completely open (e.g. BSD) license that has patent protection?
13:15pjstadigthe CDDL provides a way for you to modify it if you want to, and also gives you the ability to choose a legal venue
13:15pjstadighaving the ability to evolve the license removes one of the major reasons people tend to have CAs
13:16dnolenjonasen: no configurability
13:17pjstadigCDDL is also file based which makes it easier for people to use just one file from your project, and also to add a file licensed under a different license to your project
13:17pjstadigor something...i don't know IANAL
13:17felideonibdknox: i would appreciate your comments on https://github.com/ibdknox/Korma/pull/59 when you get a chance :)
13:18Miko2I hate it there's no way to just contribute something to the world without thinking about legal issues.
13:19ibdknoxfelideon: looks like a good idea to me :)
13:19felideonwoot
13:19felideon:)
13:19pjstadigMiko2: yeah i know, that's why i've been leaning more towards public domain or a public domain like license like CC0
13:20Miko2And if my code happens to have a dependency to some other open source project, I have to read hundreds of pages of legal jargon that I don't understand. Usually faster to implement your own.
13:21fdaoudWTFPL ftw
13:24Miko2pjstadig: Doesn't that also have the patent issue?
13:25pjstadigMiko2: right, public domain only deals with copyright issues, not patents
13:25pjstadigso it's not ideal
13:27pjstadigbut the reality is that even if an OS license has some kind of patent clause, the software could still infringe on the patents of some third-party
13:27pjstadigso if you're going to be worried about it, then you do your homework
13:27pjstadigand you'd do the same homework with public domain so maybe it works just as well
13:29Miko2I'm not worried, I'm just disappointed that there is such possibility.
13:36technomancyibdknox: apache2 is the closest thing to BSD+patent protection
13:37technomancyLeiningen's own dependencies are nearly all licensed EPL or Apache2
13:37technomancylein1 had a few oddballs (including one public domain, so I guess I can't distribute the Leiningen uberjar in Germany)
13:37technomancyMiko2: you can avoid lots of issues by just not caring about what those crazy americans do =)
13:38technomancypjstadig: doing your homework re: patents makes you liable for triple damages if you're found to be infringing, so it's not the safest thing to recommend
13:38felideonwhat's the problem with public domain in germany?
13:38technomancyfelideon: it's not recognized.
13:39technomancyIIUC German copyright law is phrased in terms of inalienable "moral rights"
13:39felideonan
13:39felideonah*
13:39Miko2technomancy: Yeah, I've been following that advice very successfully. :) But of course, if the users could have an issue, then I have an issue.
13:39technomancyyou can't give them up even voluntarily
13:39technomancythere are a few other countries without public domain too
13:40jonasenI'm playing with himera which uses cljsbuild. Every time I run lein cljsbuild one it deletes parts of resources/public which is needed by the app. Anyone knows what to about that?
13:53Miko2Hmm... Is Clojure clever enough to "cache" functions returned by functions? I have some code that matches strings against a vector of rules. Those rules are given as functions, but I create those functions with another function. So, I guess, what I'm asking is, if I call "create-some-rule" repeatedly, can I improve the performance by (def some-rule (create-some-rule)) and referring that instead?
13:54TimMcNo sneaky automatic caching, no.
13:54technomancyMiko2: function classes are created at compile time, so there shouldn't be any overhead in something like that unless you're using eval
13:54dnolenjonasen: that seems really weird
13:55S11001001Miko2: you can't compare two functions
13:55jonasendnolen: it doesn't happen the first time I run it. But if I change the cljs source it does
13:56TimMcHaha, we just answered 3 completely different aspects of miko's question.
13:56TimMcI wonder which one is relevant? :-P
13:57technomancy,(let [f-maker (fn [] #(apply + %&))] (identical? (f-maker) (f-maker)))
13:57clojurebotfalse
13:58TimMcMiko2: memoize may be of interest to you.
13:58technomancy,(let [f-maker (fn [] #(apply + %&))] (= (class (f-maker)) (class (f-maker)))) ; is what I meant
13:58clojurebottrue
13:58S11001001I'm just saying that it's algorithmically impossible for function combinators to cache generically. You can cache based on function identity, and possibly function-class identity and captured binding equality, or even expression equality, but not in general. memoize will get you the former
13:58Miko2Okay, so...
13:58TimMcS11001001: I'm guessing intensional identity is sufficient here.
13:58technomancyMiko2: creating a new function object is just instantiating a pre-existing class, which is super cheap
13:59Miko2Well, that answers the question. :)
14:01Miko2I'm actually happy that it doesn't have impact, as it'd be quite tedious to "def" everything beforehand.
14:01technomancyyes, it's very important for functions to be cheap when doing functional programming =)
14:03Miko2Yeah, I was just guessing that calling a function that creates functions about 50 * 20000 times is costly. :)
14:04mdeboardpff, that's only a million
14:05pjstadigre: public domain, if you're going to go that way I think it's best to use something like CC0 or Unlicense that acts like a permissive license in countries without public domain
14:06Miko2I guess the biggest slowdown in my implementation isn't the algorithm, but the startup cost and reading of input.
14:07cduffymefesto: I'm trying to use wabbitmq from an agent without needing to generate a whole new connection for each message. Does https://gist.github.com/279a5192f1305a898c2f look sane, or can you suggest something better?
14:09Miko2Plus printing the output.
14:13BorkdudeI'm trying to make an example why auto-gensym is necessary. So I found this On Lisp example: http://www.bookshelf.jp/texi/onlisp/onlisp_10.html
14:14Borkdudeand I'm wondering: is there anything in Clojure that looks like Common Lisp's do?
14:15Borkdudeany other example of variable capture is also good
14:17S11001001Borkdude: sure: (let [&env 42] (defmacro forty-two [] &env)) (forty-two)
14:17S11001001,(do (let [&env 42] (defmacro forty-two [] &env)) (forty-two))
14:17clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
14:17S11001001heh
14:17S11001001anyway try that
14:22gfredericksBorkdude: I'd think you could contrive an example easily; e.g., rewrite with-out-str to use generic local names like foo and bar instead of autogensym
14:23Borkdudegfredericks: ok, good suggestion
14:23TimMc"it"
14:24TimMc(my-with-out-str (println "hello") (count it))
14:24Borkdudegfredericks: hmm, it has no auto-gensyms
14:25Borkdudegfredericks: with-out I mean
14:25Borkdudegfredericks: what is with-out-str.. never heard of it
14:25gfredericksa macro
14:25Borkdudegfredericks: with-open I mean
14:25TimMc&(count (with-out-str (println "hi")))
14:25lazybotjava.lang.SecurityException: You tripped the alarm! pop-thread-bindings is bad!
14:26TimMc,(count (with-out-str (println "hi")))
14:26clojurebot3
14:26Borkdudegfredericks: ah great
14:26gfredericksit does use a gensym also
14:26mefestonDuff: ping
14:26Borkdudegfredericks: I see, yes
14:26nDuffmefesto: pong
14:27mefestonDuff: just glanced at your gist. i'm wondering if a bound-fn might be a better fit?
14:27mefesto,(doc bound-fn)
14:27clojurebot"([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."
14:28mefestonot sure tho, i haven't personally tried this
14:28nDuffmefesto: oooh, nice; that _does_ make much sense.
14:28nDuff(will need to think about how it'll work with reconnecting on error conditions, though)
14:30gfredericksfntail is an odd arg-name there
14:37Borkdudethis is a quite simple example: http://cljbin.com/paste/4fa17c6de4b08bad0592745d
15:31daniel,(clojure.contrib.math/ceil (/ 63 4))
15:31clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.math>
15:31gfredericks~contrib
15:31clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
15:31AimHerecontib is out of date
15:31danielthought so, but i cant find where this has moved
15:32AimHereJava floating point Math/ceil is still there
15:32gfredericks$findfn 63/4 16
15:32lazybot[clojure.core/unchecked-inc-int]
15:32AimHereI don't know if that's the same as the function you're after
15:33danielseems to give the desired result
15:33daniel$findfc 63/2 32
15:33daniel$findfn 63/2 32
15:33lazybot[clojure.core/unchecked-inc-int]
15:33danielcheers
15:34amalloywait what the hell. that's not the ceil function, guys
15:35gfrederickslol; I was hoping nobody got that impression
15:35gfredericksI'm still not sure why that works
15:35amalloybecause it casts to int and then adds one
15:35gfrederickswhat happens when you cast a ratio to int?
15:35amalloyit rounds down
15:36amalloyso it works fine for every number that isn't an integer
15:36amalloybut for integers it adds one
15:36TimMc&(map unchecked-inc-int [3 3.5])
15:36lazybot⇒ (4 4)
15:36gfredericksare we using "cast" loosely and not in the sense of (Foo)bar?
15:36amalloyyes
15:36TimMc.intValue, perhaps
15:36gfredericksand "unchecked" means it lets you overflow
15:37gfredericksnow I understand everything!
15:37amalloy&(instance? Number 1/2)
15:37lazybot⇒ true
15:38amalloyi guess i never thought about that, TimMc. of course ratios are numbers
15:39gfredericksnow I understand even more than that!
15:41TimMcamalloy: It is implemented in Java as x + y, where x and y are ints.
15:41TimMcSo I guess java handles the "casting".
15:41TimMc*the JVM
15:42amalloyno, clojure has to do it somewhere, probably in the reflection code for finding the right java method from the clojure function
15:43danielwhat function will map (range 0 7) -> 1 (range 8 15) -> 2 (range 16 23) -> 3
15:43danielmy IQ is not high enough to work this out right now
15:43amalloyie, i'm pretty sure you can't call bar(x) with a Ratio if it expects an int (or an Integer), so clojure must be making it an int first
15:44S11001001daniel: head map floordiv 8
15:44S11001001+1
15:44TimMcamalloy: Hmm, you're right -- Java doesn't allow 5 + new BigInteger("6")
15:45TimMcoh, and of course you're right about the method's params
15:46danielS11001001: i guess i have to implement head and floordiv?
15:47danieli don't want it to literally map the range to the result, i want any input from within the range to give me the result
15:47S11001001head is first, floordiv is floor /
15:48danielright, i thought head might be first
15:48danielbut i dont want to map the range, i mean to take any input from the range
15:48S11001001right, that's what first is for
15:48danielfirst takes the first number in the range doesnt it?
15:48S11001001yep
15:48daniel,(first (range 0 7))
15:48S11001001so it works both ways
15:48clojurebot0
15:49danielbut what if i dont have a range, but i want to map 5 -> 1
15:49danieloh i see
15:50emezeskedaniel: It sounds like you just want the quotient...?
15:50jonasendnolen: I added a :children-keys colummn to the document
15:51emezeske&[(quot 3 8) (quot 11 8) (quot 20 8)]
15:51lazybot⇒ [0 1 2]
15:51daniel,(map #(floor (/ % 8) (range 0 7)))
15:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: floor in this context, compiling:(NO_SOURCE_PATH:0)>
15:51danielemezeske: yes!
15:51jonasenemezeske: Have you tried himera with cljsbuild?
15:51dnolenjonasen: have you followed the latest bits of the thread? sounds like just moving those key-values into :children might be cleaner and nicer.
15:52jonasendnolen: I have followed the thread. I'm not fast enough to reply to all the ideas :D
15:52emezeskejonasen: You mean as a compiler backend?
15:53jonasendnolen: no, just running 'lein cljsbuild once' on it
15:53jonasensorry emezeske: ^
15:53emezeskejonasen: ^_^
15:54jonasenemezeske: I deletes some of the files in resources/public which are needed by the app for me
15:54emezeskejonasen: Oh? That is not good. Let me glance at the source real quick
15:55jonasenemezeske: It happens after some .cljs files are edited
15:55emezeskejonasen: Hmm, I see that :output-dir is set to resources/public
15:55emezeskejonasen: cljsbuild deletes the :output-dir before compiling
15:56jonasenemezeske: ok. there are a few files there that should not be deleted
15:57emezeskejonasen: Would it be possible to set the :output-dir to something else? Maybe resources/public/js or something?
15:57jonasenemezeske: probably. I'll take a look. Thanks!
15:58emezeskejonasen: NP. I probably should make the "delete first" behavior optional at some point. It's the default right now, though, because it makes the builds more solid, especially in the case that the compiler crashed or something and left output files in a weird state.
15:58robermannhello, could anyone help me in understanding why [~@ks] returns the map values? See http://pastebin.com/KQUJDi1x
16:00robermannthat example is from "Clojure Programming" book, page 252
16:01metellusrobermann: it's "unquote splicing" http://clojuredocs.org/clojure_core/clojure.core/unquote-splicing
16:01danieli've forgotten how to go from (range 0 100) -> (10, 20, 30, 40, 50 ... 100)
16:01metellusbut I don't know enough to tell you more than that
16:01gfredericksrobermann: you're asking why it's the values instead of the keys?
16:01hiredman,(doc range)
16:01clojurebot"([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity."
16:01danielooh it has step
16:02danielgreat, thanks
16:03robermanngfredericks: yes, I woud expect the keys
16:03robermannwould
16:04gfredericksrobermann: because the keys are being emitted unquoted, they get eval'd to the values
16:04gfredericksrobermann: note the '~ks is quoted but [~@ks] is not
16:05gfredericks(defmacro whatisthis [arg] `['~arg ~arg]) (whatisthis (+ 1 1))
16:08robermannIn general I can understand that ({:a "a" :b "b"} :a) => "a" , but why in the macro if keys are unquoted I get their values? The first paramater is not the whole map, but just its keys
16:09N8DawgHello room
16:10danielthis is producing a lazyseq: https://gist.github.com/2579844 I want it to act on the same board for each iteration of for
16:10danielboard is a 64 bit long and this function needs to return a 64 bit long
16:11gfredericksrobermann: this has more to do with macros than it does maps
16:11gfredericksin particular the &env parameter
16:12AimHeredaniel > for returns a sequence of the evaluated things in the body
16:12AimHererewriting that with 'reduce' might be what you want
16:12N8DawgI was wondering if someone could point me in the right direction, I had a question around form analysis for macros
16:13austinh~anyone
16:13clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:13danielAimHere: yeah, i can (reduce bit-or #())
16:13danielthanks
16:14gfredericksrobermann: a key in the &env map represents a local name. When you emit it from the macro, it's just like using it in code. So the call to (spy-env) in your code gets expanded to (prn '(y x) [y x])
16:14gfredericksso it prints (y x) [2 1]
16:14N8DawgI writing a lazy-let macro, which performs lazy evaluation of the bindings, i need to rewrite terms, but symbols may be shadowed / redefined
16:15N8Dawgso I can't just do a clojure.walk/replace is there any library to help do a lexically scoped replace on a form?
16:15robermanngfredericks: ah I see now: it is evaluating a local, instead of doing a map lookup! Thank you :)
16:16gfredericksrobermann: yep that's it
16:16amalloyN8Dawg: symbol-macrolet
16:16amalloysee https://github.com/flatland/useful/blob/develop/src/useful/utils.clj#L201 for example
16:17N8Dawgamalloy: awesome thanks!
16:19dnolenmmarczyk: thx for fixing the ICounted bug. I'd like to remove extend-type default for IReduce and IIndexed as well.
16:20N8Dawgamalloy: amazing, the answer in seconds, and the function i wanted! woot for the Clojure community
16:20mmarczykdnolen: hi! np
16:21mmarczykdnolen: yeah, IReduce and IIndexed make no sense at all for default
16:22mmarczykdnolen: especially IIndexed -- that totally breaks the promise of constant time lookup
16:24dnolenmmarczyk: I think it's there for expedience (since we don't have inheritance), but easy enough to remove (I've successfully done so in a branch after many strange resulting bugs & teeth gnashing).
16:25beffbernardThere must be a cleaner way to do this - https://refheap.com/paste/2512
16:25beffbernardI'm pass in a sorted list of keywords that are the map and return a sort list of values from that map
16:25beffbernardthat are in the map and return a sorted list of values from that map*
16:26mmarczykdnolen: yeah, though in both cases we can basically assume the argument is either IReduce / IIndexed or ISeqable
16:28raekbeffbernard: (defn sort-with-order [order item] (map val (sort-by (comp (zipmap order (range)) key) item))
16:29mmarczykdnolen: I'm curious about the strange bugs though -- and I'm sure happy you've gone through the gnashing of teeth :-)
16:29mmarczykdnolen: will you be merging that branch then?
16:33beffbernardraek: fancy.. seems like there would be a function that did this: (zipmap order (range)) ?
16:34dspiteselfWould anyone be able to suggest a way to retain the power of Datomic and while adding an authorization layer. I was playing around with the idea of adding access control list facts and use macros to convert a query and a user and by adding proper expressions and unifications to ensure authorization. Is this a pipe dream i have and has played with similar security concepts?
16:36ibdknoxdspiteself: you're probably better off asking in #datomic
16:36devnAnyone know what fogus used to generate this video? chouser, do you know? http://www.youtube.com/watch?v=pTETlppW-u4
16:36dakronedevn: gource
16:36dspiteselfok sorry
16:37devndakrone: awesome! thanks.
16:37ibdknoxdspiteself: nothing to be sorry about, just think you might have a better chance of getting an answer :)
16:37dspiteselfand when i ask it there maybe i can spit proper English out;-)
16:37devndakrone: i just submitted an issue on clojuredocs -- maybe you know where the link is, but on the api.clojuredocs.org page the link to clojuredocs-client is incorrect (it's still pointing at cd-client pre-rename)
16:37technomancygource is lots of fun
16:37devndakrone: do you know where to change it?
16:37dakronedevn: yes, I'll fix it
16:38devndakrone: where is it out of curiosity? I couldn't find it.
16:39dakronedevn: https://github.com/dakrone/cd-wsapi/blob/master/resources/index.html
16:40mmarczykdnolen: just fixed the reify warning -- http://dev.clojure.org/jira/browse/CLJS-233
16:43robermanndakrone: I was just looking on it this morning, the last version is https://github.com/dakrone/cd-client or https://github.com/Raynes/cd-client ?
16:43mmarczykdnolen: actually wait, I think I missed something
16:43mmarczykdnolen: will comment on the ticket once I'm sure it works.
16:48dakronerobermann: neither, https://github.com/dakrone/clojuredocs-client
16:52robermanndakrone: BTW I noted that doing a (browse-to symbol) goes to the 1.2 version of it ?
16:53dakronerobermann: yea, there's a problem with the URLs that I need to fix
16:53robermannI worked around it with this hook: http://pastebin.com/jnHkgjrt
16:54robermann(maybe dirty, but I was just studying these hook questions)
16:56robermannIn general why for browse-to do you use *examples-api* and not *search-api*?
16:58dakroneit needs some love and updating, I haven't touched it for quite a while, so I don't recall exactly
17:01jonaskoelkerHi all. Suppose I have an quoted expr in my toy language, say '(+ (d 6) (d 6) (d 6))---and I want to write that syntax in some-namespace, and I want eval on that to call some-other-namespace/d. What's the best way to do that?
17:02jonaskoelkerAnd is that even the right way to do things? I'm very new to clojure... My best guess would be to either (use) or (require), the one which is similar to "from pkg import *" in python
17:03jonaskoelkerthat feels dirty and ghetto, however
17:04sattvikjonaskoelker: Well, the closest thing to "from pkg import *" is (use), though a blanket (use 'some.ns) seems to be discouraged these days.
17:05mmarczykdnolen: posted a correct patch @ CLJS-233 (I think) -- after gnashing my teeth a bit and dealing with some strange bugs :-)
17:05sattvikI think with Clojure 1.4 you can now just get a few named symbols from a namespace. The alternative is to use (require) which ensures they are available.
17:06jonaskoelkerI'm on clojure 1.3 ...
17:06sattvikOK, well, let's just say you used the namespace. What you probably want to syntax quote rather than quote.
17:06sattvikThat is: `(+ (d 6) ...)
17:07jonaskoelkerthat _sounds_ right, though I have no context for which to evaluate it
17:07dnolenmmarczyk: I don't think that will work with advanced compilation right?
17:07jonaskoelkerwhat's the semantic diff?
17:07mmarczyksattvik: get a few named symbols? how do you mean?
17:07sattvikThe reader will namespace-qualify the symbols.
17:07sattvikmmarczyk: Well, specific vars.
17:07mmarczykdnolen: oh. I think you're right
17:08jonaskoelkerso if I'm in namespace foo, `(+ (d 6)) will become (+ (foo/d 6))?
17:08mmarczykdnolen: wasn't my first approach, just the first one which (1) gets rid of the warning, (2) doesn't break unscientific tests at the REPL, (3) doesn't break core_test
17:08mmarczykdnolen: back to the drawing board then :-P
17:08sattvikjonaskoelker: So '(+ d) turns into just (quote (+ d)), but `(+ d) becomes something like (clojure.core/+ some.ns/d)
17:08sattvikyes.
17:08mmarczyksattvik: as in (use '[foo.core :only [...]]) ?
17:09mmarczyksattvik: or alias after require
17:09jonaskoelkersattvik: ... it sounds like it'll become (clojure.core/+ test/d) when I want (clojure.core/+ mylib/d) ?
17:10jonaskoelkerwhen I write `(+ d) in my test namespace
17:10dnolenmmarczyk: yeah it won't break it'll just never cache the type.
17:10sattvikmmarczyk: I think so. Oh, I think I remember what was different in 1.4, it wasn't use that got something new, but require? Something like require with refer?
17:10mmarczyksattvik: the new thing is (:require [foo.core :refer [...]]), but that's a step towards deprecating the still-available and for some reason much-despised use
17:11mmarczyksattvik: cache the type...?
17:11mmarczykdnolen, I mean, and I got it now :-P
17:11dnolenmmarczyk: sorry for caching the definition of the constructor.
17:11mmarczykyeah
17:11mmarczykgot mixed up re: which conversation this was part of
17:12sattvikjonaskoelker: That's a little more difficult. You can, of course, namespace qualify a symbol and just do something like '(+ mylib/d), but I don't know off-hand how that will work when evaluated.
17:12mmarczykand yeah, that's a problem -- I'll find another approach
17:13jonaskoelkersattvik: I guess I'll just import everything---can namespaces set export controls? Then whatever lump of code that needs short names can dirty itself
17:14jonaskoelkerI could presumably re-namespace the symbols, but that feels hacky and brittle
17:14sattvikjonaskoelker: Well, namespaces can make vars private, which just means they are not visible by default, rather than inaccessible.
17:15jonaskoelkerso there's a gentleman's agreement but no contract? :)
17:15brehautsome people like to create an internal NS that contains the stuff you dont want people importing
17:16jonaskoelkerand evilly rename it from release to release? :->
17:16brehauthaha
17:16brehauti think anyone importing from foo.internal deserves the pain they get
17:17jonaskoelkerthat's what she said!
17:17sattvikjonaskoelker: Well, it isn't straightforward to get to a private var, but it's not impossible
17:18jonaskoelkerintroflection and all that jazz?
17:18sattvikSo, I wouldn't count on it for security.
17:18brehaut,clojure.core/sig
17:18jonaskoelkersure
17:18clojurebot#<CompilerException java.lang.RuntimeException: No such var: clojure.core/sig, compiling:(NO_SOURCE_PATH:0)>
17:18brehaut,#'clojure.core/sig
17:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: clojure.core/sig in this context, compiling:(NO_SOURCE_PATH:0)>
17:18brehautbah
17:19brehaut,#'clojure.core/sigs
17:19clojurebot#'clojure.core/sigs
17:19jonaskoelkera more mundane problem, I'm doing (:use clojure.contrib.combinatorics) after upgrading clj 1.0->1.3 and contrib 1.0.0 to 1.1.0 and it no worky. Whys?
17:19brehaut~contrib
17:19clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
17:20jonaskoelkerOh look, a manual! :)
17:20technomancymanual is kind of a strong term
17:20brehautits more like a divining rod
17:21brehautnot to diminish the work seancorfield has done
17:25mmarczykdnolen: posted a new patch -- hopefully this one will work -- what do you think?
17:26dnolenmmarczyk: yep, looks ok.
17:26mmarczykdnolen: whew. :-)
17:26jonaskoelkerbah, anybody care to help me not have to beat my head against the wall?
17:26mmarczyka hairier ball than I originally suspected
17:27dnolenmmarczyk: at some point we're going to have to sort out this namespace / locals masking issue - but that's another series of tickets.
17:27mmarczykdnolen: I was actually thinking about this the other day
17:27jonaskoelkermylib @ http://paste.debian.net/167049/ --- tests @ http://paste.debian.net/167050/ --- ./roll.clj compile error @ http://paste.debian.net/167051/
17:28mmarczykdnolen: I've got some design notes
17:28dnolenmmarczyk: rewriting local names that are known to be nses?
17:28mmarczykdnolen: could tidy them up a bit and post them to ggroup / Confluence (assuming I've got the perms)
17:28mmarczykdnolen: yeah, plus interop story around that
17:29dnolenmmarczyk: is it big enough of an issue for Confluence? :) I'd just add those notes to the existing ticket.
17:29dnolenmmarczyk: unless it is a bigger issue.
17:29mmarczykdnolen: not really, but it's bound to complicate calling into cljs from js a (very little) bit
17:29mmarczykdnolen: which I'm not really worried about :-)
17:30mmarczykdnolen: I missed the existing ticket though, if there is one surely it's the best place for this :-)
17:30sattvikjonaskoelker: How are you running your program?
17:30jonaskoelker"./roll.clj"
17:31jonaskoelkerwith envvar CLASSPATH=/usr/share/java/clojure1.3.jar:/usr/share/java/clojure.jar:/usr/share/java/clojure-contrib.jar:.
17:31dnolenmmarczyk: http://dev.clojure.org/jira/browse/CLJS-180
17:31mmarczykdnolen: thanks! will post a comment there in a little while
17:31jonaskoelkerbtw, 'sattvik', is that norwegian? It sounds that way to my (danish) ear...
17:32mmarczykdnolen: ah, btw -- so do you have a patch for 232? could have a go at writing one in the spirit of the ICounted patch unless you're planning to do it today
17:33dnolenmmarczyk: it mixed in with some other stuff, so I don't have a patch handy.
17:34sattvikjonaskoelker: Well, I'm not what the problem is. It seems like it can't find the combinatorics class... It's hard to tell if the path is being set up properly within the program.
17:34sattvikjonaskoelker: Oh, it's Sanskrit.
17:34mmarczykdnolen: well, I'll look into how much of a hairball would result from just wiring in a satisfies? check and a linear traversal helper
17:35jonaskoelkeroh ok; in my brain it kinda' pattern-matches against boddhiSATTVa, FWIW
17:35dnolenmarchdown: minor thing - for your patches mind adding the ticket # in the commit message?
17:35jonaskoelkersattvik: path is being set up properly <-- me no gets?
17:35jonaskoelkeri.e. System/getProperty "java.class.path" ?
17:35sattvikjonaskoelker: Yes.
17:35mmarczykin an hour or so, probably, since I suddenly came over all peckish -- need to take care of that now
17:38sattvikjonaskoelker: You could try adding a line to print out that property right before your ns declaration in roll.clj, that would at least help eliminate that possibility.
17:39jonaskoelkersattvik: /usr/share/java/clojure-1.3.jar:/usr/share/java/clojure.jar:/usr/share/java/clojure-contrib.jar:.
17:40jonaskoelkerbut I have clojure-contrib 1.1.0, in which combinatorics is still in clojure/contrib/
17:40jonaskoelker^_^
17:40sattvikjonaskoelker: Ah, that may be the problem.
17:40mmarczykdnolen: oh, did you mean me about the ticket # ? sure, could add that
17:40dnolenmmarczyk: yeah
17:40mmarczykok, will do
17:41jonaskoelker... debian only has clojure-contrib 1.2 ?! (:must :use :newer :technology)
17:42AimHereThere's no later version of clojure.contrib
17:42sattvikWell, you could try to continue using the old contrib (which may or may not work), but you'll have to use the old namespace.
17:42sattvikAn alternative is to use something like Leiningen, which can help you manage your dependencies.
17:42mmarczykbbl.
17:43jonaskoelkerit may in particular not work: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V
17:43amalloyjonaskoelker: debian is great for OS components, but for keeping on top of developments in a programming language it's an awful choice
17:43amalloyjust install lein and let it do all the work you're trying to do by hand
17:44jonaskoelkeramalloy: I'll try and store that, so that when I'm finally tired of doing stuff by hand I'll remember what you said :)
17:44amalloythat's the spirit!
17:46raekjasonbray: the "RestFn" error is known to happen when you are trying to run code ahead-of-time compiled for one clojure version on another clojure version
17:46raeksorry
17:46raekjonaskoelker: ^
17:46jonaskoelkerraek: hm?!
17:46jonaskoelkeris it also known _why_?
17:47raekAOT compiled code is no guaranteed to be compatible between clojure versions
17:47jonaskoelkersure, but why specifically RestFn(I)V?
17:47raekmost libraries don't need to be AOT compiled, but a few parts of contrib did
17:47amalloythat just happens to be the first incompatibility it finds
17:48jonaskoelkerfair 'nuff
17:48amalloyraek: i thought contrib was just AOT compiled for performance/size
17:48raekcondition and error-kit needed it, afaik
17:49raeksince they provide new classes that have to be available statically
17:50jonaskoelkeranyone care to help me de-boilerplate my code in a way that could earn the Good Clojurekeeping Seal of Approval? ;-)
17:51jonaskoelkerI want to write a static analysis for my language, 'stats', which outputs the probability distribution described by a dice roll formula, e.g. "d2 + d2" -- or '(+ (d 2) (d 2)) -- should output {2 1/4, 3 1/2, 4 1/4}
17:52jonaskoelkerI have a _lot_ of functions (addition is a good example) where I just want to apply the function to the keys in some other maps, multiply the probabilities, and add that into a new map (roughly speaking)
17:53jonaskoelkerI have a lot of "} else if (function == 10) { do function 10;"-ish code going over all the functions; I was thinking about putting them in a set, but what do I put? Symbols, functions, ...?
17:53jonaskoelkerstrings?!
17:54madsyHumble question. What is the most straight-forward way to use OpenGL with Seesaw? Would I need to make my own OpenGL-enabled frame from scratch by using Swing and jOGL?
18:22gfredericksjonaskoelker: depending on where the code is coming from, you might make a map from symbols to functions
18:22gfredericks{'+ (fn [a b] ... add a and b somehow ...), '- (fn [a b] subtract...), ...}
18:23jonaskoelkergfredericks: I'm writing all of it. That sounds like a fair idea
18:26gfredericksjonaskoelker: and if a lot of the functions do the same kinds of things, a higher-order-function can probably help DRY it up
18:26jonaskoelkerin C terms, how do I make a variable static to a function? e.g. what I mean by (let [fun-data 0] (defn foo [] (increment fun-data)))
18:26jonaskoelkerDRY = don't repeat yourself?
18:26gfredericksyeah
18:26jonaskoelkeri.e. express `for' in terms of `while' -style xforms?
18:27gfredericksI'm not exactly sure what you're asking wrt making a variable "static to a function". If I had to guess what that meant, it'd be something like your (let ... (defn ...))
18:28brehautyou probably dont want to do this but
18:28brehaut,(let [c (atom 3)] (while (< 0 @c) (prn (swap! c dec))))
18:28clojurebot2
18:28clojurebot1
18:28clojurebot0
18:28technomancyjonaskoelker: functional languages don't let your change the value of locals
18:29jonaskoelkertechnomancy: the impure ones do :) [and anyways the change wasn't the point, the visibility was, but yeah, my example was bad]
18:29gfrederickstechnomancy: sounds more like unfunctional languages then amirite
18:29technomancysorite
18:29jonaskoelkerI think you mean `dysfunctional languages' ;-)
18:29technomancy"static" is such a nonsense word in Java
18:29madsyjonaskoelker: What exactly do you want to do?
18:30jonaskoelkergfredericks idea works for me
18:30gfredericksI think (let [...] (defn ...)) is good idiomatic stuff
18:30jonaskoelkerI must have typoed it when I did it the first time around
18:30madsyIf you just need a for-loop there are better ways.
18:30gfredericksbrehaut: crickey I didn't even know we had while
18:30jonaskoelkernah, I just want to make a big data structure visible to only one function, but not computed on every invocation
18:31brehautgfredericks: thats the correct response ;)
18:31brehautgfredericks: ive used it once ever, and thats for a logging loop in an IRC bot
18:31madsyjonaskoelker: Then use a closure
18:31gfredericksbrehaut: I probably could have used it a few times when I did a (loop [] ...)
18:31brehauthah yes
18:32jonaskoelkermadsy: how'd that look?
18:33brehautgfredericks: https://github.com/brehaut/burningbot/blob/master/src/burningbot/logging.clj#L105-109
18:33madsy,((fn[x] #(fn[] x)))
18:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox$eval53$fn>
18:33madsy,((fn[x] #(fn[] x)) 1)
18:33clojurebot#<sandbox$eval85$fn__86$fn__87 sandbox$eval85$fn__86$fn__87@1556157>
18:33jonaskoelkermadsy: would gfredericks (let ... (defn ...)) be another way of essentially the same?
18:34madsyYes, sure.
18:34gfredericksdepends on if your data structure is constant and hard-coded or if you want to make them on the fly
18:34gfredericksbrehaut: this "burningbot" is some kind of terrorist I assume?
18:34madsyWow.. I screwed up my example pretty bad there.
18:35brehautgfredericks: ircbot for the burning wheel RPG channel
18:35amalloytechnomancy: "static" is worse in C :P
18:35jonaskoelkergfredericks: basically, it's a sym-fn map, {'+ +, '- -, 'pow pow, ...}
18:35gfredericksbrehaut: this must be one of those "video james" I've been hearing about
18:36jonaskoelkerstatic is teh win in C ;)
18:36ejacksonfolks, is it to be expected that AOT breaks map->R ?
18:36hiredman1d6+5
18:36clojurebot11
18:36jonaskoelker^_^
18:36amalloyjonaskoelker: it means three or four completely unrelated things depending on context
18:36gfrederickshiredman and clojurebot have a very strange relationship
18:36jonaskoelkerthree
18:36brehautgfredericks: tabletop
18:36jonaskoelker1d6+5
18:36clojurebot8
18:36jonaskoelkerwth...
18:37gfredericks1d6+8
18:37clojurebot9
18:37brehauthiredman: is clojurebots dice just NdSides + mod?
18:37jonaskoelker6*3d6
18:37jonaskoelker3d6
18:37clojurebot6
18:37hiredmanyes
18:37jonaskoelker6#3d6
18:37jonaskoelkerblah
18:38jonaskoelkeramalloy: at least I count three: static functions, static globals and static locals
18:40ejacksoncheck out a minimal example: https://github.com/ejackson/aotquestion/blob/master/src/aots/death.clj#L9
18:40ejacksonthe other file, core.clj is not AOT'd and the class of map->R is what you'd expect.
18:41ejacksonbut death.clj is AOT'd, and map->R barfs.
18:41ejacksonwhile (merge (R. ...) {...}) behaves as expected.
18:47ejacksonno takers ? Cowards :D
19:11gfredericksyou could analyze irc logs to identify the most egregious conversation killers
19:22wmealingI'm usually an instigator.
19:23gfredericks"Instagator: for when you can't find a gator fast enough!"
19:24wmealingwhen you absolutely need a reptile.
19:24wmealingright now.
19:24gfredericksif only you could make money merely for having killer original business ideas
19:27technomancywhy is it the javax.servlet/servlet-api jar is distributed without a license?
19:27technomancydoes the javax package name somehow imply it shares a license with the JDK?
19:31wmealingcareful, oracle may be listening.
19:31SurlyFrogHi all, is there a way I can specify the Clojure version that Leiningen should be using? I've got clojure 1.4.0 downloaded and can start it directly, but using `lein repl` causes it to use version 1.2.1.
19:32wmealingyou mean for the project or for lein itself ?
19:33SurlyFrogum…both I guess.
19:33SurlyFrog(i'm *just* getting started with this)
19:33wmealingdont worry about modifying lein, it'll work as is,
19:33wmealingbut you can add :dependencies [[org.clojure/clojure "1.3.0"]]
19:33wmealingto your projects.clj
19:34wmealingi can paste my entire project.clj for reference if you wish
19:34SurlyFrogI guess what I'm wondering is how does lein know which clojure to load?
19:35wmealingit reads it from project.clj
19:35sritchiedo any of you guys use leiningen 2 with intellij?
19:35SurlyFrogin the event that you don't start with a project, but just use `lein repl` or, simply fire up Swank...
19:36wmealinglein looks up itself in its script
19:36wmealingthe lein executable should just be text
19:36wmealingCLOJURE_JAR in this example
19:36wmealingSurlyFrog, is there a specific need for a version ?
19:36xeqiSurlyFrog: lein 1.x uses clojure 1.2.1 for itself
19:37SurlyFrogum, not necessarily, well, not that I know of yet. I'm just getting started and just trying to make sure I understand how things are pulled together. I'll do a bit more reading.
19:37SurlyFrog:-)
19:38wmealingok
19:42RoxxiIs there a clojure idiom similar to the scheme receive-values syntax? Or a clear cut mechanism to return a set of values that are bound individually explicitly without processing a list (e.g. (receive (x1 x2 x3) (values 10 20 30) body ...))
19:45gfredericksRoxxi: is that like destructuring?
19:46gfredericks&(let [nums (range 3), [x y z] nums] (+ x y z))
19:46lazybot⇒ 3
19:47RoxxiHmm
19:47Roxxiyeah
19:49RoxxiYeah, that works great! Thanks gfredericks
19:56mrakanI cannot seem to find a function to compute n^x (n to the power of x). What is its name? Thanks.
19:57wmealingGoing to take a punt and say its Math/Pow
19:57wmealingi'm not a java programmer though
19:57mrakanAh, I had assumed it was a part of clojure.core. Okay, thanks.
19:57wmealingit may be,
19:58LuminousMonkeyhttp://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Math.html
19:58sritchie&(Math/pow 10)
19:58lazybotjava.lang.IllegalArgumentException: No matching method: pow
19:58wmealingthere is
19:58wmealinghttp://richhickey.github.com/clojure-contrib/generic.math-functions-api.html#clojure.contrib.generic.math-functions/pow
19:58lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure-contrib/generic.math-functions-api.html#clojure.contrib.generic.math-functions/pow and try to stop linking to rich's repo.
19:58LuminousMonkeyHa!
19:58wmealingmrakan, there is a native. one apparntly
19:58wmealing(pow x y)
19:59mrakanAh, great! Thanks!
19:59sritchie&(Math/exp 10)
19:59lazybot⇒ 22026.465794806718
19:59sritchiewhoops :)
19:59metellus,(pow 2 3)
19:59clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pow in this context, compiling:(NO_SOURCE_PATH:0)>
19:59sritchieoh, of course
19:59sritchie&(Math/pow 10 2)
19:59lazybot⇒ 100.0
20:00wmealing,(clojure.contrib.generic.math-functions/pow 2 2)
20:00clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.generic.math-functions>
20:00LuminousMonkeyLooks like it's just a wrapper for Math/pow anyway.
20:00wmealingyeah, probably is
20:00brehauttechnomancy: lein-licenses is a great idea
20:00LuminousMonkeyThe source uses a defmathfn-2 macro
20:00technomancybrehaut: thanks!
20:01wmealingwhats that do monkey ?
20:01brehauttechnomancy: i see amalloy needs to pick up his game and license useful though ;)
20:01technomancybrehaut: I remember spending a few hours tracking that down manually at my last job, but I figured now it could be automated with pomegranate
20:01technomancybrehaut: oh yeah absolutely =)
20:01ivan&((fn [n x] (eval (cons '* (repeat x n)))) 10 2)
20:01lazybotjava.lang.SecurityException: You tripped the alarm! eval is bad!
20:01brehauttechnomancy: oh man. doing it manual? thats got to be death
20:02technomancyit sucked =\
20:03wmealingmrakan, http://clojure.github.com/algo.generic/clojure.algo.generic.math-functions-api.html#clojure.algo.generic.math-functions/pow is the more recent way to do it.
20:03LuminousMonkeywmealing: I'm not entirely too sure, macros are still a bit magical to me.
20:04wmealingi'm slowly beginning to understand them..
20:07LuminousMonkey&(symbol "java.lang.Math" "pow")
20:07lazybot⇒ java.lang.Math/pow
20:07LuminousMonkeyNifty.
20:14mrakanIs there a way I can simply install all of the clojure.contrib libraries?
20:17gfredericksmrakan: I don't think so
20:17gfredericksclojure and its libraries aren't usually "installed"
20:18mrakanI can automatically download what I need with Leiningen, perhaps? I add the library name into the dependencies in the project file? (Yes, I'm new. :))
20:18ivanyes
20:18mrakanGreat, thanks.
20:21LuminousMonkey[org.clojure.contrib/standalone "1.3"] or similar?
20:24wmealingi have a long running process and want to deal with plugins that can be downloaded/added at runtime
20:24wmealingis there an existing project that does something similar ?
20:31xeqi~contrib
20:31clojurebotMonolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
20:31jroesso we've got compojure and we have ring and we have noir
20:32jroesso I get that ring is like rack / wsgi
20:32jroeswhat are compojure and noir equivalent to?
20:32brehautcompojure is the routing layer
20:32weavejesterjroes: Kinda equivalent to Sinatra
20:32brehauti believe its roughly comparable to sinatra in design?
20:32jroesgotcha
20:32brehautnoir is kind of like icing ontop of compojure
20:32gfredericksit's like sinatra
20:32jroesare there any other frameworks of note?
20:33jroes(web)
20:33gfredericksless frameworks more libraries
20:33weavejesterbrehaut: Noir's more like Sinatra I think. Compojure's perhaps a little lower level since it doesn't have the helpers that Sinatra and Noir do.
20:33brehautweavejester: ah thanks
20:33muhoooh gawd, i never want to deal with a framework again
20:33brehautjroes: there are some older frameworks that try to be more rails like, but they arent noteworthy
20:33jroesgfredericks: gotcha, if it's not idiomatic to do something like Rails in Clojure, that's understandable
20:33brehautmuhoo: seconded
20:34weavejesterA lot of things in Rails tend to be counter to Clojure's philosophy, I think.
20:34gfredericksI think you more pick-and-choose the features you want via middleware
20:34brehautlikewise django things
20:35gfrederickslikewise TI-BASIC things
20:35jroesI see. that philosophy seems a bit closer to node's as well
20:35brehautdue to the design of compojure (and moustache, an parallel library) middlewares are much more versatile than in other systems
20:35jroes(not that anyone here wants to be associated with the node community ;))
20:35brehautwell, the design of ring and compojure
20:36weavejesterI'd say it's more Clojure itself that makes middleware so simple to use. In Ruby middleware is similar, but because it's all objects and there's no immutable data structures it doesn't work as well.
20:36weavejesterRack's design works better in Clojure than Ruby, IMO :)
20:36brehautlol
20:36weavejesterOr maybe it's that HTTP is more suited to Clojure
20:36brehauteverytime i write a django middleware i get really furious
20:36jroeswell geez, weavejester over seems to be the original author of most of the web-related libraries, haha :)
20:37brehauthalf of
20:37brehautif you go by original author, but most of if you go by major contributor ;)
20:38weavejesterA few. There's also Mark McGranaghan and Chris Granger who do a lot of stuff of note
20:40jroesso how about a lot of the typical things you need in a web app - authentication, authorization. is sandbar still the standard (doesn't have very many recent commits)?
20:40gfredericksisn't that what cemerick's friend does?
20:41weavejesterjroes: Chas Emerick recently released Friend, which is maybe a more idiomatic approach to auth
20:41brehauti dont think sandbar was ever a standard. it is/was popular though
20:41jroesgotcha, I'll check that out
20:41gfrederickssandbar good for regular session/flash stuff
20:41weavejesterThere are parts about Friend I'm uncertain about, but I can't think of any better way of doing them :)
20:42brehautyes, cemerick was brave taking on that particular beast
20:43weavejesterbrehaut: Definitely! One need only look at all the Java auth frameworks to see how badly it can be messed up :)
20:44brehauthaha yes
20:45brehautone thing i like about the clojure web ecosystem is how the highly decoupled nature of things has let stuff like this develop gradually and with less baked in mistakes
20:45gfredericksis core.logic/logic-programming-in-general appropriate for searching a very large search space with heuristics?
20:45brehautyes??
20:45lazybotbrehaut: Definitely not.
20:45mdeboardbrehaut: What ever could you mean? Django is an enlightened web framework that perfectly encap-- I just wet myself.
20:46brehautmdeboard: django was great in 2005
20:46gfredericksI wasn't sure if it was perhaps only for situations where you can afford exhaustive dumb searches
20:46brehauti am of the opinion that it has rusted
20:46emezeskeI'm a huge fan of the decoupled nature of clojure web libraries, but I must admit it does make it a bit difficult to get started
20:47brehautmoar docs!
20:47emezeskeYeah, I think more full-featured example projects would be really beneficial
20:47weavejesterDecoupling does make it trivial to factor out components into separate services, which I especially like.
20:47mdeboardI'm of the opinion that it is a kitchen-sink approach that is great when you are starting a project and want to get it up & iterate quickly. After that phase though it's time to move on to something else. The entire Django ecosystem spawns these huge, tightly coupled apps that try to do everything and wind up falling apart at a certain level of complexity.
20:48weavejesterBut I agree it's currently hard to get started.
20:48brehautnoir is a great aid here
20:48weavejesterNoir makes it a lot easier
20:48brehautit hits a bit of a sweet spot of enough stuff together to get started, without being overbearing
20:48LuminousMonkeymdeboard: That's what I found with Rails, it was great when I first started my project, but when I progressed onto needing to do things differently, it became harder to do.
20:49brehautive been promising ibdknox that i'd write a follow up to my ring post about noir, but i have yet to write anything that is better than his existing docs
20:49ibdknoxI have some thoughts on doing all of this better
20:49ibdknoxthis being web programming in Clojure
20:49brehauti also think i sold compojure a little short in my ring article and that needs to be addressed
20:49ibdknoxI'm not happy yet
20:50weavejesterThe only thing I don't really like about Noir is the way routes are set globally. But admittedly it does make it easier to get started.
20:50ibdknoxweavejester: yeah it has advantages and disadvantages
20:50brehautthats what i dont like about noir either ;) it solves a non-problem for me. i like centralised route config
20:50brehaut(though i can understand why you might not)
20:51ibdknoxwell recently I've been of the opinion that I shouldn't have to write routes at all
20:51brehautreally‽
20:51hiredmanrouting via namespaces?
20:51ibdknoxnope
20:52jroesthe interesting thing for me is that as a Rails dev by day, whenever I found that I was doing something that went against "The Rails Way" I questioned whether my approach was correct in the first place. many times I found that I could solve the problem in another way that played nicer with the framework and made my life easier
20:52ibdknoxurls have become artifacts for the most part
20:52weavejesterI'm kinda of the opinion that you should be able to break up a web site into services as easily as you can split up a namespace.
20:52ibdknoxthey no longer correctly map to the functionality of the things we build
20:52mrakanLeiningen successfuly downloaded org.clojure/algo.generic for me, but I can seem to require it in my projects. The compiler complains it cannot find it in the classpath. (:require [clojure.algo.generic.math-functions :as math]) What am I doing wrong?
20:52mrakan*can't
20:52ibdknoxwe're not building hyperlinked pages anymore
20:52mdeboardwho's we? :P
20:52mdeboardThe royal we
20:52hiredmanibdknox: interesting
20:53ibdknoxLift has some neat ideas
20:53ibdknoxMeteor has some more
20:53weavejesteribdknox: I'm still a hyperlink fan, even if it's only for web services.
20:53ibdknoxbut I don't think either of those have it quite yet either
20:53mdeboardWe definitely utilize links & URLs to a great extent
20:53ibdknoxweavejester: well to be fair, I'm not saying get rid of it, but that our work shouldn't centralize around it
20:54ibdknoxmdeboard: shoot where the pucks going to be ;)
20:54LuminousMonkeyjroes: Sure, but I also have a problem with ORM which is very much the Rails way? Recently I've been thinking that more logic should be moved into the database than what Rails does.
20:54mdeboardin my particular domain at work, the puck is dollars and they want SEO :P
20:54weavejesteribdknox: My thought is that the idea of identity and state in clojure ties very closely to the ideas of URIs and resources in HTTP.
20:55mdeboardalthough frankly our URLs are just Solr queries.
20:55ibdknox:p
20:55ibdknoxweavejester: how so?
20:55mdeboarde.g. /ibm/careers/indianapolis/indiana/usa/jobs/
20:56jroesLuminousMonkey: a lot of the most recent literature points toward modeling domain objects in your primary development language and not in your persistence layer
20:56weavejesteribdknox: Well, a HTTP request or response is effectively an immutable value - you can't alter it after it's been sent.
20:56weavejesteribdknox: A resource is an identity, equivalent to a ref in Clojure, in that it contains a value bound to a range of time.
20:57weavejesteribdknox: You can say, "This identity had the value X from time t1 to t2"
20:57weavejesteribdknox: My favorite color was red from 2010 to 2011 or something like that.
20:57ibdknoxyeah
20:57weavejesteribdknox: A URI is similar to a namespaced var.
20:58mdeboardhm.
20:58ibdknoxthat's true so long as you're building pages
20:58weavejesterIf you're building web services that return resources as well.
20:58mdeboardinteresting way of thinking about it, and especially applicable to views like http://jobs.jobs/new-york/new-york/usa/jobs/communication-jobs/new-jobs/deloitte/careers/
20:58mdeboard@ weavejester
21:00weavejestermdeboard: Yep
21:00technomancythe difference between a resource and a representation is very key to this
21:00weavejesterA representation is just a serialization of a data structure IMO
21:01weavejesteribdknox: Out of interest, when do you think it isn't true?
21:02ibdknoxI guess it's true if you assume that those "vars" are always functions to execute
21:03ibdknoxI thought you were suggesting they were values
21:03weavejesteribdknox: I am
21:03ibdknoxhm, that's not true if I think of it as "I click this link, which adds an element to the page"
21:04ibdknoxthat url is probably something like /blah/add
21:04weavejesterBut isn't that something for Java/Clojurescript to handle?
21:04mrakanWhy does Clojure silently convert the following into a double? (class (Math/pow (java.math.BigDecimal. 2) (java.math.BigDecimal. 48))) I'd like an exact 2^48 integer value, but I'm not sure how to accomplish that.
21:04ibdknoxno
21:04ibdknoxnot if it needs to be synced across the state of the application
21:05hiredmanmrakan: Math/pow only does doubles
21:05weavejesterI mean, the Javascript would make an appropriate resource update.
21:05weavejesterSo you'd click a link, and then you'd POST to /blah to create a new /blah resource
21:05weavejesterI mean, the JS would POST in the background
21:06hiredmanclojure is actually converting your bigdecimals to doubles too, because math/pow only takes doubles as arguments and returns doubles
21:06ibdknoxweavejester: sure, that sounds like a function to me though, I didn't access a value
21:06mrakanhiredman: Ah, I see. How would one then get an exact 2^48 value, using Clojure? The algo.generic library just aliases pow to Math/pow, so I see no alternatives...
21:07hiredmanmrakan: read the docs on bigdecimals
21:07ibdknoxweavejester: I don't really think that distinction matters though, your argument makes good sense both ways
21:07weavejesteribdknox: Well, the analogy falls down a little because you don't often create vars programmatically in Clojure.
21:07weavejesterAnd in practice, you wouldn't represent routes as vars because there's too many of them
21:08dnolenmmarczyk: new CLJS optimization idea
21:08dnolenmmarczyk: making satisfies? use bit testing
21:08dnolenmmarczyk: hidden field on deftype and defrecord for storing the protocols integer
21:08gfredericksmrakan: and of course there is ##(apply * (repeat 48 2N))
21:08lazybot⇒ 281474976710656N
21:08weavejesterBut in principle you're either creating, deleting or modifying an identity with a new immutable value in HTTP
21:08mmarczykdnolen: ohhhh, that's very cool
21:08mmarczykdnolen: reserved for core protocols I guess?
21:09weavejesterOh, on a different topic, has anyone written a dynamically-compiling caching ClojureScript middleware?
21:09mmarczykdnolen: of which we have ~40, a quick M-x occur tells me
21:10gfrederickswhich lib should I look at for examples of requiring and instantiating a gclosure class? for some reason I never get this right the first try...
21:10ibdknoxweavejester: absolutely, but I think there's something that can live on top of that abstraction too - I'm not sure I should have to think about http anymore. And how I'm considering that might look actually plays really nicely with what you're talking about.
21:10mrakangfredericks: That's probably rather slow, surely? (bit-shift-left 1 48) comes to mind, but I'll into the docs to see a more readable example.
21:11mmarczykdnolen: (incidentally, I've posted patches on the IReduce & IIndexed tickets, plus the cljs.reader ticket -- CLJS-225)
21:11gfredericksmrakan: definitely, so depends on how often you do it
21:11weavejesteribdknox: I'd be interested in hearing more, if you're willing.
21:11ibdknoxweavejester: I was basically thinking of abstracting routes behind symbols that mapped to vars on the server using CLJ/CLJS
21:13weavejesteribdknox: How would it work with a route like "/users/N" where N can be any number?
21:13ibdknoxweavejester: that's a function to me :) and so you'd just say (users 5)
21:13ibdknoxvars can hold any value, right?
21:13ibdknoxthe atom one is much more interestin
21:13ibdknoxg
21:14ibdknoxif you have either websockets or a polling scheme, you could keep the atom sync'd
21:14weavejesteribdknox: Right. And… what would you get out? A ref of some description? Something derefable at least?
21:14ibdknoxweavejester: you'd get whatever that route would return
21:16weavejesteribdknox: Ah, okay. I was thinking of taking it a step futher, and instead of just returning a value, return a ref that includes some sort of time data.
21:16ibdknoxah
21:16ibdknoxinteresting
21:16wmealingi have a long running process and want to deal with plugins that can be downloaded/added at runtime is there an existing clojure project which does a live .. check'n' load ? ala plugin ?
21:16weavejesterSo you'd not only have a value, but also a time when that value was valid.
21:17weavejesterWhich would be useful for caching
21:17dnolenmmarczyk: yes JS doesn't have an efficient way to test interfaces like Java.
21:18dnolenmmarczyk: looking for a value further up the prototype chain is not particularly fast.
21:18weavejesteribdknox: But I agree that binding a route to a var is likely where we want to go.
21:18dnolenmmarczyk: JS only has 32bit ints when doing bit ops.
21:18dnolenmmarczyk: my thought was to keep the optimization modest for now.
21:18dnolenmmarczyk: only handle the most commmon protocols, specifically the ones we have predicates for that we call all the time.
21:18ibdknoxweavejester: and cljs can make that completely transparent
21:18ibdknoxwhich is the exciting part
21:18weavejesterRight :)
21:19mmarczykdnolen: ok, so just a short list of, say, ISeq, ISeqable, ICounted, IIndexed, possibly IRecord?
21:20weavejesterIt would be nice to be able to hit a route via cljs, and get back a ref representing that resource.
21:20weavejesterWhich could then be derefed anywhere in the cljs code into a value.
21:20dnolenmmarczyk: something like that
21:21mmarczykdnolen: then for those protocols we could see if a given objects prototype hasOwnProperty of, say, cljs$protocols_mask$ (which all deftype'd / defrecord'd things will have) and bit-and against that if yes
21:21mmarczykdnolen: does that sound about right?
21:21ibdknoxweavejester: yeah, definitely something to think more about :)
21:21ibdknoxI think we can beat folks like meteor at their own game pretty easily
21:23dnolenmmarczyk: I think the hasOwnProperty test was a mistake on my part
21:23weavejesterClojure's concepts of identity and state and value are basically mappable directly onto REST and HTTP
21:23mmarczykyeah, we'll be the titanic batter who bats the meteor away and proceeds to complete a home run
21:23mmarczyk(if my understanding of baseball is correct)
21:23dnolenmarchdown: I want to remove hasOwnProperty completely. I just added that so type ctors can printable - but I think that should be handled differently.
21:23weavejesterLanguages with mutable data structures tend not to map so well.
21:24dnolenmmarczyk: oops that ^ was for you. hasOwnProperty tests are also not that fast.
21:24mmarczykdnolen: hm, ok
21:25mmarczykdnolen: so just do a straight lookup and check for undefined?
21:25dnolenmmarczyk: we'll still do all the slow tests, but if we see that it's a matching protocol, we add the fast test first.
21:26dnolennot nil && (bit test || prototype chain)
21:26mmarczykdnolen: oh wait, (bit-and js/undefined 12354) works fine
21:26mmarczykdnolen: right
21:27brehautit mgiht be the confirmation bias talking, but i agree with weavejester
21:29mmarczykdnolen: actually there's no reason not to nominate 32 protos for the fast path -- changing our mind later will be no problem
21:29mmarczykdnolen: (defprotocol ^:bitmasked ISeq ...) ?
21:30mmarczykdnolen: results unspecified if >= 32 protos marked this way
21:31dnolenmmarczyk: haha, I don't want to leak the implementation yet :)
21:31dnolenmmarczyk: this about making idiomatic CLJS fast
21:32dnolenmmarczyk: deftype performance is great - but idiomatic CLJS still leaves much to be desired.
21:33mmarczykdnolen: I'm not proposing that this be advertised as available for use outside of core :-)
21:33dgrnbrgHow do I write (symbol (name (ns-name *ns*)) (name (gensym))) idiomatically?
21:33dnolenmmarczyk: even that's too much for my tastes.
21:33dgrnbrg,(symbol (name (ns-name *ns*)) (name (gensym)))
21:33dnolenmmarczyk: I prefer a map in the core.clj macros file for now.
21:33clojurebotsandbox/G__29
21:34mmarczykdnolen: sure, definitely less tempting
21:35mmarczykdnolen: is this applicable to native types? that is, should IIndexed hang something on String.prototype, say?
21:35dnolenmmarczyk: I'm fine with slow path for native types for now.
21:36dnolenmmarczyk: what drives me crazy is seq? on types we've already wrapped with IndexedSeq
21:36mmarczykdnolen: well yes
21:36dnolenfor example this is what we basically should do in the optimized rest fn case.
21:37mmarczykIFn should definitely make the list, btw
21:37dnolenmmarczyk: yeah
21:39mrakanHow come (java.math.BigDecimal. 5) works, but (java.math.BigInteger. 5) complains of a missing constructor? I tried importing by adding (:import [java.math.BigInteger]), but none of the constructors are available even then.
21:40mmarczykdnolen: ok, so for now it would be (1) a fast-path-protocols map in core.clj; (2) an extra condition in the if in satisfies? right after x# -- with a bit-and; (3) extend-type needs also to be aware and attach a bitmap when extending to a fast path proto
21:41LuminousMonkeymrakan: (java.math.BigInteger. "5") works...
21:41LuminousMonkeymrakan: http://docs.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html
21:41mrakanLuminousMonkey: Ahhh, thanks!
21:41mrakanhttp://clojure.github.com/algo.generic/clojure.algo.generic.math-f\
21:41mmarczykdnolen: does this sound about right? if so, could do a quick proof of concept
21:41mrakanWhoops.
21:42dnolenmmarczyk: cool, let me commit some optimization to satisfied right now.
21:43mmarczykdnolen: great
21:43mmarczykdnolen: I'll solicit extend-type's cooperation then
21:45dnolenmmarczyk: k pushed to master, satisfies? should be free of calls to truth_
21:46dnolenmmarczyk: in your experiments you should eliminate the hasOwnProperty test of course.
21:46dnolengotta run.
21:46mmarczykdnolen: looks greats
21:46mmarczyk^great
21:46mmarczykdnolen: ok, see you later
21:46mmarczykdnolen: I'll do a POC and create a ticket then
21:46dnolencool
21:52muhootechnomancy: deploying an app to a different heroku account than my own. is this really the most current way to do that? http://www.aeonscope.net/2010/02/22/managing-multiple-heroku-accounts/
21:55mrakanI'm new to Clojure. Is it expected that the core library is lacking somewhat, because it's still a rather new language? For instance, bit-shift-right doesn't work with clojure.lang.BigInts. I *could* just use all the java.math.BigInteger methods to manipulate the numbers, but it would be a lot uglier.
21:58LuminousMonkeymrakan: I don't know if that's something that core would take care of? If it existed it would be something in contrib?
22:00LuminousMonkeymrakan: Like pow, etc, that's in clojure.math.numeric-tower
22:01aphyrNot gonna lie, I *really* want early return right now.
22:02LuminousMonkeymrakan: http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
22:02LuminousMonkeymrakan: I think you'll have to resort to Java.
22:04creeseI need to create a function that takes a set of words and returns a hash with the letters of those words as keys.
22:05creeseI have something that works but feels like clojure anti-pattern
22:06brehaut,(do (require 'clojure.string) (frequencies (clojure.string/join #{"hello" "world"})))
22:06clojurebot{\h 1, \e 1, \l 3, \o 2, \w 1, ...}
22:07brehautyou didnt say what you wanted the values of the hash to be
22:08Raynesaphyr: I doubt that.
22:09aphyrRaynes: Yeah, I do too!
22:09aphyrRaynes: (f1 (f2 (f3)))
22:09aphyrRaynes: each of f1, f2, and f3 can throw an exception
22:09aphyrand need *separate* try/catch blocks
22:10aphyrreturning from each catch block
22:10creese#{"cat" "hat"} -> {\a #{"cat" "hat"} \c #{"cat" "hat"} \h #{"hat"} \t #{"cat" "hat"}}
22:10creesethat's what I want
22:11creeseset -> hash where letters are keys and values are sets of words
22:11aphyrRaynes: as far as I can tell, I need to either re-raise a unique exception from each layer, abuse dynamic bindings, or return [ok, x] [error, z] tuples from each stage which get automatically handled by some macro.
22:12emezeskeaphyr: Returning an ok/error tuple is a very normal thing to do in a functional language
22:13aphyremezeske: yeah, I'm used to it in erlang. I'm considering writing a macro to automatically unwind the call sequence if it sees an error in one of the inside calls.
22:13aphyrreduce through the chain, basically.
22:14emezeskeaphyr: Should be simple to do. I wrote a macro kind of like that, but only for boolean results (not ok/error tuples), and it was just a few lines
22:14aphyrI feel like this is a common enough pattern that someone has already solved it.
22:14aphyrShould I use a condition library?
22:14emezeskeaphyr: I think the premade solution is the maybe monad
22:15aphyrOh, of course! /me digs up the docs
22:16emezeskeI'm not sure if maybe-m allows information about the error to be kept around, though
22:16emezeske<-- not a monad expert
22:16brehautit doesnt
22:16brehautthe error is just nil; its a short circuit
22:16creesedoes that clarify what I'm trying to do?
22:16brehauthowever its trivial to make an error-m that does
22:17mmarczykthat's what either-m is for
22:17leo2007is var more like a global constant?
22:17mmarczyknot sure if algo.monads provides that -- probably does
22:17mmarczykbut Either's used for short-circuiting computations w/ some error state in Haskell
22:18brehautno either-m is present
22:18mmarczykone returns Right value in case of success, Left errorValue for error; >>= passes through the first Left
22:19mmarczykoh.
22:19brehauthttp://brehaut.net/blog/2011/error_monads_revisited
22:20brehaut(and for context http://brehaut.net/blog/2011/error_monads )
22:21brehauti was just using it to allow xml-rpc stuff that threw Fault records back to short circuit handlers
22:22mmarczykcool
22:22brehauti do like that the clojure monads imp allows you to define them parametrically
22:26creese(zipmap (seq (first seuss)) (repeat 3 (first seuss)))
22:26creese{\t "cat", \a "cat", \c "cat"}
22:27creesehow can I use 'merge' to get the rest of the words into the hash?
22:28aphyrcreese: I'd use merge-with
22:28aphyr(apply merge-with concat (map-of-chars-to-each-word))
22:32aphyrooh: https://github.com/scgilardi/slingshot
22:32xeqi&(reduce (partial merge-with clojure.set/union) (map (fn [w] (reduce #(assoc %1 %2 #{w}) {} w)) (clojure.string/split "the cat in the hat" #" ")))
22:32lazybot⇒ {\i #{"in"}, \n #{"in"}, \c #{"cat"}, \a #{"cat" "hat"}, \e #{"the"}, \h #{"the" "hat"}, \t #{"the" "cat" "hat"}}
22:33LuminousMonkeyThat's just cool.
22:34creese&(map #(zipmap (seq %) (repeat 3 (hash-set %))) #{"cat" "hat"})
22:34lazybot⇒ ({\t #{"cat"}, \a #{"cat"}, \c #{"cat"}} {\t #{"hat"}, \a #{"hat"}, \h #{"hat"}})
22:35creeseI can't get yours to compile: java.lang.ClassNotFoundException: clojure.set
22:35creesewhat do I need in ns?
22:35brehaut(require 'clojure.set)
22:36brehautoh, thats repl not ns
22:36creeseI'm compiling into the repl so it should be okay
22:38creese:require [clojure.set :as set]
22:38creese?
22:38brehautsure
22:38xeqithat would work, just shorten the ns in what I pasted
22:40muhoothis is interesting. i installed heroku accounts plugin via this martyhaught.com/articles/2010/12/14/managing-multiple-heroku-accounts/
22:41muhooset it up, and now, it can't find and won't let me access the 2 clojure apps i deployed
22:41muhooit does, however, show an ancient ruby app i worked on years ago.
22:41creesewhy does the repl need clojure.set but not clojure.string?
22:42muhooi suspect i must have been logged in as someone else, who now has my apps :-O
22:42muhooand i can't get them back :-(
22:42xeqicreese: perhaps you have transatively required clojure.string already
22:44creeseI don't follow
22:49xeqiwhen you require a namespace that namespace can require others, and so on
22:51creeseI see
22:51creese&(apply merge-with set/union (map #(zipmap (seq %) (repeat 3 (hash-set %))) seuss))
22:51lazybotjava.lang.RuntimeException: No such namespace: set
22:52creese&(apply merge-with clojure.set/union (map #(zipmap (seq %) (repeat 3 (hash-set %))) #{"cat" "hat"}))
22:52lazybot⇒ {\h #{"hat"}, \t #{"cat" "hat"}, \a #{"cat" "hat"}, \c #{"cat"}}
22:55xeqiclose
22:55creesemine only works with 2 words, right?
22:55xeqiwords of length <= 3
22:55creeseand 3 letters long
22:56creeseha!
22:56creeseit works for any number of words
22:58technomancymuhoo: you don't need a plugin to deploy an app owned by a different account, you just need that account to add you as a collaborator
22:58creeseyeah, I can't see how to get the 3 out
22:59xeqi&(doc repeat)
22:59lazybot⇒ "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
23:00leo2007has lein been replaced by something else?
23:01jodaroi'm going back to ant
23:01jodarocuz i love writing xml
23:02creesewow
23:03creeseI'm astounded
23:03leo2007me 2
23:06xeqimaybe by lein 2.0 previews
23:06muhootechnomancy: oh, but they haven't added the project. i have to add it.
23:06muhoowhile logged in as them
23:06muhoothen i can add myself as a collaborator.
23:06creese&(apply merge-with set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"the" "cat" "in" "the" "hat"))
23:06lazybotjava.lang.RuntimeException: Unmatched delimiter: )
23:06creese(apply merge-with set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"the" "cat" "in" "the" "hat"}))
23:07creese&(apply merge-with set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"the" "cat" "in" "the" "hat"}))
23:07lazybotjava.lang.IllegalArgumentException: Duplicate key: the
23:07creese&(apply merge-with set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"cat" "in" "the" "hat"}))
23:07lazybotjava.lang.RuntimeException: No such namespace: set
23:07creese"_"
23:07creese: &(apply merge-with clojure.set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"cat" "in" "the" "hat"}))
23:08creese&(apply merge-with clojure.set/union (map #(zipmap (seq %) (repeat (hash-set %))) #{"cat" "in" "the" "hat"}))
23:08lazybot⇒ {\c #{"cat"}, \a #{"cat" "hat"}, \t #{"the" "cat" "hat"}, \h #{"the" "hat"}, \e #{"the"}, \n #{"in"}, \i #{"in"}}
23:08creesewhew
23:09muhootechnomancy: nm, i found the problem. i had 2 accounts, different emails
23:21creesewhen I try to assign it to an atom, I get 'nil' instead of the hash. What is wrong with this?
23:22creesehttps://refheap.com/paste/2518
23:23brehautcreese: apply merge-with is passing a hash into swap! …
23:23brehaut,(swap! (atom {}) {:foo 1})
23:23clojurebotnil
23:23creesewhat should I be passing to it?
23:23brehautcreese: a function of the old map to the new map
23:24brehaut,(swap! (atom {}) (fn [m] (assoc m :foo 1)))
23:24clojurebot{:foo 1}
23:24xeqi&(doc constantly)
23:24lazybot⇒ "([x]); Returns a function that takes any number of arguments and returns x."
23:24brehautweeell no
23:24brehautyou probably want reset! at that point
23:25brehaut,(reset! (atom {}) {:foo 1})
23:25clojurebot{:foo 1}
23:25brehautbut reset! kinda violates how atoms are intended to be used
23:25brehaut(doc reset!)
23:25clojurebot"([atom newval]); Sets the value of atom to newval without regard for the current value. Returns newval."
23:25brehautviolates is too strong
23:26brehautif you are using reset! a lot, you are probably not using atoms the way they are intended
23:27creeseinitially, the hash will be empty and I need to populate it
23:27creeselater, I will delete keys and/or values
23:27brehautright
23:28brehautif you can call atom with the initial value that would be better, but one call to reset! at the start is ok
23:28creeseoh
23:28creeseok
23:29creesebut if I call atom inside a function, will it be globally available to other functions?
23:29brehautif you replace line 3's (atom {}) with (atom …)
23:29brehautthen yeah you'll be fine
23:30creesewhat does … mean?
23:30brehautyour code to generate het initial state
23:31creeseare saying delete { } and put … or put nothing?
23:32brehautput whatever you would be putting in the reset! in where … is
23:33creesewhat if I used assoc and gave swap! a list of keys?
23:33brehautthats fine
23:52ivan&(*' 99999999999 99999999999)
23:52lazybot⇒ 9999999999800000000001N
23:52ivanwtf. that overflows here
23:52ivan,(*' 99999999999 99999999999)
23:52clojurebot9999999999800000000001N
23:52RaynesThe bots never overflow.
23:53ivanmaybe this is some terrible Java 7 / Windows thing
23:54ivanuser=> (*' 99999999999 99999999999)
23:54ivanArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1388)
23:55wei_is there a good way to halt execution if any agent in a list has failed?
23:56xeqi&*clojure-version*
23:56lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
23:56ivanoh, I am an idiot who redefined *' for kicks yesterday
23:57ivanthe wonders of not closing your REPL
23:57ivanthe nil (doc *') should have given it away
23:58ivanSwing is so weird. How does a keystroke event in one window bubble up to a completely different process?