#clojure logs

2011-12-01

08:30chouserBah. Failed to log since yesterday afternoon until just now.
08:40noidiI have a vector of values, and I need to find the index of a given value in it. What's the best way to do this?
08:41Borkdudenoidi: I would use keep-indexed
08:42clgvnoidi: you might have chosen the wrong datastructure if you ant to do that often
08:42clgv*want
08:44Borkdude,(keep-indexed (fn [i e] (if (= e some-value) i))
08:44clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
08:44Borkdude,(keep-indexed (fn [i e] (when (= e 2) i)) [1 2 3])
08:44clojurebot(1)
08:44noidibasically I just want to map a set of keywords to sequential integers. the obvious way would be a map, {:foo 0, :bar 1, ...}, but I'd rather let Clojure do the work :)
08:44BorkdudeI mean (copied the wrong thing)
08:45noidiand I want the order to remain stable, that's why I use a vector and not a set
08:46Borkdudenoidi: a vector of keywords maybe?
08:46Borkdudenoidi: use map-indexed then
08:46clgvnoidi: try ##(zipmap [:foo :bar :bla :blubb] (range))
08:46lazybot⇒ {:blubb 3, :bla 2, :bar 1, :foo 0}
08:47noidiclgv, brilliant, thanks!
08:48noidiand thanks for the tips Borkdude
08:48clgvI wonder if lazybot could have done it
08:48clgv$findfn [:foo :bar] [0 1] {:foo 0, :bar 1}
08:48lazybot[clojure.core/zipmap]
08:48Borkdudenoidi: no problem. a somewhat longer version: (into {} (map-indexed (fn [i e] [e i]) [:a :b]))
08:49clgvyes he could have :)
08:49noidiwhaaat?! :D
08:49Borkdudeclgv: heheh, cool :)
08:49noidithat's crazy
08:49clgv$inc lazybot
08:49lazybot⇒ 2
08:49noidi$findfn 2 2 4
08:49lazybot[clojure.core/unchecked-multiply clojure.core/+ clojure.core/* clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-multiply-int clojure.core/*' clojure.core/unchecked-add-int]
08:50noidi$findfn [:foo :bar] {:foo 0, :bar 1}
08:50lazybot[]
08:50clgvnoidi: he cant compose functions (yet?) ;)
08:50noidiclgv, just checking whether's there's something like that in core already :)
08:51Borkdude$findarg map % [1 2 3] [-1 -2 -3]
08:51lazybot[clojure.core/-' clojure.core/unchecked-negate clojure.core/- clojure.core/unchecked-negate-int]
08:52clgvBorkdude: but thats not really composing them on his own ;)
08:52Borkdudeclgv: right, just trying out if I remembered how it worked ;)
08:52clgvyeah that one is pretty cool as well
08:53noidiis that built on clojure.core.logic?
08:53clgvnoidi: I dont think so. Just plain bruteforce ;)
08:53Borkdudenoidi: check github, it just trying all fns and see if they work ;
08:53Borkdude;)
08:54Borkdude$findarg map % [:a :b] {:a 0 :b 1}
08:54lazybot[]
08:54Borkdude$findarg mapcat % [:a :b] {:a 0 :b 1}
08:54lazybot[]
08:55Borkdude$findarg map-indexed % [:a :b] {:a 0 :b 1}
08:55lazybot[]
08:55BorkdudeI give up ;)
08:56Borkdude$findarg %1 %2 [:a :b] {:a 0 :b 1} ;; clojure.logic do your thang! ;P
08:56lazybotjava.lang.RuntimeException: Unable to resolve symbol: %1 in this context, compiling:(NO_SOURCE_PATH:0)
09:08fbru02hey guys i talked today with clgv about multiple fn sigs .. i have a problem one side i have (fn ([a] (..)) ([& b] (..)) this doesn't work b/c the compiler needs the variadic to be longer than the single parameter
09:08fbru02ways to get around this?
09:09raek(fn ([a] (..)) ([a & b] (..)) ?
09:09clgvfbru02: no. you have to have at least as many parameters in the variadic sig as in the longest non variadic one
09:09fbru02ok will try re disgning then
09:09clgvfbru02: otherwise the compiler has no clue which one to take
09:10fbru02thanks ! :)
09:13hcumberdaleAre clojure applications 'really' running in multiple parallel threads in the JVM?
09:13clgvhcumberdale: depends how you write them
09:13Wild_Catand how the JVM schedules them. As I recall it has M-N threading, right?
09:23hcumberdaleWhy is there no "default concurrency" ? clgv what are you meaning with "how"? Have I to add explicit commands to get concurrency?
09:24clgvhcumberdale: sure. did you ever see a system where thats automatic? I think thats semantically impossible
09:25kephaleclgv: well, one could rename pmap as map, then call concurrency automatic : P
09:26hcumberdaleclgv => Haskell ?
09:26clgvkephale: lol and get worse performance in a lot of cases... ;)
09:27clgvhcumberdale: sure? I dont know haskell but I dont think that it automatically tries to do everything in parallel since that would be inefficient due to scheduling overhead if you have only small tasks.
09:27kephaleclgv: sure, explicit concurrency is definitely the way to go. when it comes to a shared environment you really need it to be explicit unless you use sandboxes everywhere
09:29chouserThere are languages that have ubiquitous parallelism (a bit like Clojure has ubiquitious lazy seqs) but I don't know that any got past "research language" stage.
09:29kephalealthough i guess that comes back to just being able to control the thread pool
09:32kephalechouser: GPU languages
09:33hcumberdalehttp://www.haskell.org/haskellwiki/Parallel
09:33hcumberdaleclgv: Haskell supports both pure parallelism and explicit concurrency.
09:33cemerickis no one using fortress for real work then?
09:34hcumberdalenever heard of fortress ;(
09:35clgvhcumberdale: but that wikipage seems as if you have to use special "things" as well for pure parallelism
09:36hcumberdaleI think it does not explain anything about the pure parallelism (which must be switched explicit on by a command line switch if I remember)...
09:37clgvhcumberdale: but to answer your question - you have to tell clojure when you want to do something in parallel ;)
09:37hcumberdaleokay! ... good to know
09:38hcumberdalehttp://goo.gl/MCNi8
09:38Fossierlang programs can easily be pretty parallel, but other than that i rarely saw another example
09:38hcumberdale"To compile a Haskell program for parallel execution under PVM, use the -parallel option"
09:39hcumberdaleMhhh Intresting how they do such a parallel execution.... really everything in parallel will lead to a lot cpu time for threat management
09:39hcumberdalethreat => thread ... hmpf, new keyboard
09:39kephalehence why GPUs are the best example ; D
09:42cemerickhcumberdale: it's a modern fortran, built on the JVM. All operations are automatically parallelized.
09:42clgvhcumberdale: I remember that haskell is said to have pretty leight weight internal threads. maybe that avoids overhead.
09:42cemerickI'd point at the project's wiki, but it looks like they got migrated to java.net, so it's an impossible mess.
09:48hcumberdaleDoes anyone using clojure for real world projects?
09:48hcumberdaleWhat are your thougths about scala?
09:50samaaronso has anyone gotten avout working?
09:51samaaronI'm getting a run-in-transaction exception when i try to get the example working
09:51hhutch_samaaron: I'm interested in hearing how people are going to use it
09:51cemerickhcumberdale: a small sample: http://dev.clojure.org/display/community/Clojure+Success+Stories
09:55hcumberdaleNice samples, thx cemerick
09:56cemerickof course, there's a lot more under the surface
09:56hcumberdaleAre there tools to profile clojure performance and control flow?
09:56cemerickwith some fiddling, standard JVM profilers work well with clojure codebases
09:57cemerickyourkit is fairly popular; I've always had good results with the standard jvisualvm toolchain
10:05jweiss-bblwhen a macro expansion includes a symbol is that symbol resolved in the ns where the macro is defined, or where it's expanded? (looks to be like the latter)
10:06AWizzArd|workLein 1.6.2 ends in an NPE when doing "lein deploy" under Windows. I specified the "releases" and "snapshots" repos in :deploy-repositories. Ideas?
10:08TimMcjweiss: A bare symbol?
10:08jweissTimMc: yeah
10:10jweissTimMc: i'm testing serializable.fn, which uses its own definition of fn. but the unit test tool test.clj uses deftest, which refers to fn. So i'm wondering if the test tool is producing "tests" with the new fn rather than core's.
10:10TimMcaha
10:10TimMcSo you may actually have an excuse to care. :-)
10:12TimMc(let [x 100] (defmacro bare [& _] (list `+ 'x 3)))
10:12TimMc(let [x 4] (bare)) => 7
10:13TimMcMakes sense.
10:14TimMcThis is the opposite of capturing a symbol. What is it called?
10:15DerGuteMoritzTimMc: I think this is also referred to as capturing a binding
10:15jweissTimMc: but you're doing all this in the same ns
10:15DerGuteMoritzjweiss: x is a local binding!
10:15jweissyou'd have to defmacro, then switch ns and 'use' x
10:15jweissyeah, my issue is not with locals, but def's
10:16DerGuteMoritzoh right, defmacro works on ns level only anyway
10:16TimMcWell, I think the same stuff applies -- the result of the macro contains an unresolved symbol.
10:16TimMc(eval '(+ 3 3)) works just as well as (eval `(+ 3 3))
10:16jweissTimMc: ok so it does do what i thought, the symbol is resolved in the ns where the expansion happens
10:17TimMcthe call site of the macro, you might say
10:17DerGuteMoritzjweiss: is it clojure parlance to refer to a `let' binding as `ns'?
10:17jweissso if for instance, fn points to serializable.fn/fn then deftest will expand to use that
10:17DerGuteMoritzwell, a `let' scope
10:17jweissDerGuteMoritz: ns = namespace
10:18DerGuteMoritzjweiss: yeah but `x' is not part of a namespace as in clojure namespace
10:18jweissyeah
10:18jweissso it's not the same kind of example as mine
10:18DerGuteMoritzoh I didn't see the part of the discussion before TimMc's example
10:19TimMcjweiss: I think I see what you're getting at -- you *want* to (re-)resolve a symbol in the macro's namespace?
10:19jweisshm, so this is rather complicated. who would have thought fn serialization would be so frought with complex issues
10:19TimMcheh
10:19DerGuteMoritzTimMc: these kinds of macros are also called unhygienic in case you didn't know
10:19TimMcvery
10:20jweissyeah, but clojure.test's macro isn't unhygenic
10:20jweissis hygenic i guess
10:22DerGuteMoritzjweiss: if it shadows a binding of the environment the macro is expanded it then it is unhygienic
10:22jweissmaybe i don't know the exact meaning of hygenic. if a macro expands to a bare symbol, that symbol could be made to resolve to *anything* depending on where the macro is expanded
10:22DerGuteMoritzs,expanded it,expanded in,
10:23DerGuteMoritzjweiss: yes, thus the explicit renaming with #
10:23TimMcjweiss: So... you are concerned that in serializeable.fn's test code, deftest may be pulling in core.fn?
10:23DerGuteMoritzoh wait, I may have gotten that one wrong
10:23jweissTimMc: i think deftest is pulling in serializable.fn/fn
10:23TimMcjweiss: Just do a macroexpand, yeah?
10:23jweisswhich theoretically should be ok *if* serializable.fn/fn works, but that's what we're testing!
10:24TimMcaha
10:24jweissclojure.test i guess didn't foresee that we'd be testing a different fn macro.
10:25jweissi guess we could get around this by not "use"ing in fn in the test script.
10:25TimMcjweiss: :exclude
10:26TimMcI think that exists...
10:26jweissTimMc: you mean refer-clojure :exclude?
10:26jweissit already does that to avoid the conflict with clojure.core/fn
10:26jweissi'm saying it should leave that alone so deftest won't use the wrong one
10:27TimMcjweiss: No, like (use '[clojure.string :exclude [replace reverse]])
10:27jweissTimMc: oh, hehe there's only one var in the ns that is needed
10:27TimMcyou could exclude serializeable.fn's fn
10:27TimMchah
10:27jweissso if you exlcude it there's nothing left
10:28jweisscrap, i think this is a real dilemma.
10:29jweissif i let fn refer to clojure.core, then the "round trip" testing of serialize/deserialize/serialize/deserialize will fail
10:30jweissif i let it refer to serializable.fn/fn, then deftest will be using the code it's trying to test.
10:35jweissok, i tried just "require"ing serializable.fn, and using fully-qualified symbol fn, so deftest is happy, and the tests pass. so i guess that is the solution.
10:37jweissbut i'm using serializable.fn in a differnt way than intended (which is for it to replace fn)
10:46kzarWhat's the literal equivilent for (keyword "hello world")? (I'm not sure how to type a keyword with a space.)
10:48duck1123you can't
10:49duck1123that's why spaces in keywords are fun in #clojure, but not as great in real life
10:52gtrakso, say I want to make a DSL, how hard would it be to have a context-sensitive autocomplete facility based on the DSL? I'm thinking like declarative guis a-la mxml, though nicer because it's clojure :-).
10:54duck1123it's kind of a shame there is no XSD for clojure forms
10:55jamiltronWhat is XSD?
10:55duck1123There needs to be a documented protocol, where you can assign documentation a record's parts
10:55gtrakyea, maybe the rules engine would be useful for somethign like that?
10:55duck1123XSD is the structure language for xml
10:55jamiltronOh thanks
10:56gtrakthe dynamicity can work against you though
10:56duck1123now that I'm thinking about it, I'm not sure it would work.
10:58gtrakI'm just sad flex is dying :-(
10:58duck1123it might be kinda cool to have common html tag name completion for [:html ] forms
10:58gtrakthere were really a lot of nice things about it
10:59gtrakyea
10:59gtrakthe mxml approach wasn't too terrible actually
11:00gtrakmaybe could just write your stuff in xml and use CDATA for clojure forms :-)
11:01gtrakhttp://www.sephiroth.it/test/flex/2/checkbox3state/bin/srcview/source/example.mxml.html
11:01gtrakit looks ugly at first, but it's really easy to mess with and learn interactively
11:02jodaroflex is dying?
11:02gtrakit just got donated to apache a couple weeks ago
11:02duck1123I've been using closure templates in my personal project, and while it's nice, I have to save the file, and then go re-eval a coresponding template ns
11:02gtrakI'm guessing that means that adobe's not paying people to work on it
11:03jodarooh
11:03jodarothat'll slow it down, for sure
11:03gtrakduck1123, does that work for composing guis?
11:04duck1123there was an "apache considered harmful" article I read recently that was rather interesting
11:04jodaroi guess it depends on the project
11:04jodarobut
11:04jodaroi've had mixed experiences with apache stuff over the years
11:04jodarolike
11:04jodarodid thrift ever get a real release?
11:04duck1123gtrak: If I understand your question, you can break it down to a series of small templates and include them
11:05TimMcjweiss: I think :require is appropriate for serializeable.fn's testing.
11:05jodarooh i guess it did finally
11:05duck1123gtrak: ex https://github.com/duck1123/jiksnu/blob/master/resources/soy/jiksnu/templates/activity.soy
11:05jodaroand i guess hadoop and friends have done well
11:06duck1123I hate their insistance on SVN
11:06jweissTimMc: ok, it would appear that :use'ing it can have some unintended consequences. serializable.fn *should* be transparent
11:06jweisssince all it does is add meta to the fn object
11:07duck1123I've been using the new Abdera 2 code, and when it breaks, I would totally make fixes if I had a git repo
11:07gtrakduck1123, I've been doing something similar with stringtemplate
11:08duck1123The promise of soy templates (that I haven't used yet) is that I can use these same templates in clojurescript
11:08hhutchduck1123: you can't just use git-svn ?
11:08gtrakoo, you can call functions from the template?
11:08duck1123hhutch: the messed up nature of their repo makes that impossible. I tried
11:08gtrakor is that another template? {call jiksnu.templates.user.linkTo data="$recipient" /}
11:08hhutchduck1123: fail
11:09duck1123You can't call out from the template, you have to keep view and data separate
11:09duck1123gtrak: that's another template
11:09gtrakstringtemplate has some annoyances
11:09gtraki don't really like dynamic scoping
11:09duck1123the downside is I had to write special formatter function that converted my model to the limited set of types it supports
11:10gtrakdoesn't it handle Maps?
11:10duck1123but it forces a strict "no logic in views"
11:10hlshipIs there a link to Clojure's issue tracker anywhere on clojure.org?
11:10gtrak~jira
11:10clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
11:11duck1123it handles map. it doesn't handle jodatime dates, Mongodb object ids, or even long
11:11gtrakah
11:11duck1123wait, it might handle long
11:11gtrakdoes it just do toString?
11:13duck1123I don't believe so
11:15gtrakif so, you could just implement a new Object
11:16duck1123I really only have a few objects in my records it can't handle. When I first started youing it, my thought was "I'll just pass this whole map to the template and be done." not so. :(
11:16rickmodeI though I saw yesterday that slime could examine a Java class. What was the key combination?
11:16gtrakC-S I O or something?
11:17gtrak"technomancy_: leo2007: sure, just use C-S-i and enter a java class, it will list all the methods"
11:19AWizzArd|work$seen rhickey
11:19lazybotrhickey was last seen quitting 6 weeks and 6 days ago.
11:20jweissI think 'C-c I' will inspect the class at point
11:21rickmodegtrak: thanks... it's not working for me though. At ^C-^S and ^C-S are both undefined
11:21gtrakI think C is actually the control button
11:22rickmodegtrak - it's the slime-inspect command. So ya.. it's Ctrl-C Shift-I
11:22gtrakah ok
11:23rickmodegtrak - sweeeet... let time popping between my IDE and emacs
11:23duck1123rickmode: just so you know, that's usually written C-c M-l
11:23duck1123er S-l
11:24duck1123I never understood why Shift was more of an S than "super"
11:24jweissC-c S-i
11:25rickmodeduck1123: ah - the help (C-h m) uses ^C ⇧I and similar. I'm still like a yellow belt at my emacs-fu
11:30gtrakhmm, clojure forms schema, pattern matching?
11:36rickmodeI've been looking for a good overview of what's new in Clojure 1.3. Things like the the newer ^static and ^inline metdata for defs and such.
11:38duck1123there's the changelog, but they don't get too in-depth
11:42gfredericksdnolen: I wasn't awake 11 hours ago, but I did run the included tests this morning and saw they all passed
11:43dnolengfredericks: excellent
11:43gfredericksdnolen: I'll run mine real quick too just to be thorough
11:43dnolengreat let me know and I'll cut another alpha
11:45gfredericksdnolen: all passing
11:46dnolengreat
11:48dnolenreleasing alpha9 now
12:11jcrossley3hi, is there any way to define a multifn and declare that all existing multifns that would also match are preferred to it? (if that makes any sense)
12:12jcrossley3essentially, a wildcard passed to prefer-method, i guess
12:13michael_campbellwhat does it mean to prefer > 1?
12:13hiredmanif you call methods on a multifn you get back a map of dispatch values to fns, so you could build something like that
12:15jcrossley3hiredman: yes, i considered that, but i'm concerned about defmethods occuring *after* that.
12:17jcrossley3i'd like my method to be a fallback in case a defmethod for *any* of a types ancestors hasn't been defined
12:18jcrossley3michael_campbell: by "prefer > 1" i meant "prefer any methods defined over this one"
12:20dnolenjcrossley3: is that not satisfied by providing :default?
12:21jcrossley3dnolen: hmm... maybe! thanks :)
12:23jcrossley3dnolen: YES! (thanks again) :D
12:28michael_campbelljcrossley3: Ah, I see. I was thinking more along the lines of "I prefer blondes", but am unwilling to narrow it down much further. ;-)
12:28jcrossley3:)
12:29dnolenjcrossley3: np
12:36kzartechnomancy_: FYI I think this is a Heroku bug, I set a worker to be `worker: lein run -m app-name.worker/-main` which worked locally but on Heroku gave me an exception "Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate _main__init.class or _main.clj on classpath". When I changed the Procfile to ommit the "/-main" it worked both locally and on Heroku
12:41technomancy_kzar: that sounds more like a Leiningen bug
12:41technomancy_did you end up getting it switched to 1.6.2 or are you still on 1.5.2?
12:42kzartechnomancy: Hmm I added the buildpack to a different project, I'm not sure which is running on this project ATM but I haven't added a special buildpack
12:43technomancyoh, ok; if you haven't changed the buildpack it would be running on 1.5.2.
12:44technomancyI know there were some improvements to the -main handling in 1.6; I'm not sure app-name.worker/-main was ever supported on 1.5.2
12:44kzartechnomancy: Want me to add it and see if the problem persists?
12:44technomancyyeah, why don't you give it a go
12:53kzartechnomancy: Yea, that fixed it
12:53technomancysweet =)
12:53kzarSorry, should have tried it before
12:55technomancynah, it should be on by default for everyone
12:55technomancyI'll see if I can get a few more people testing it and hopefully make it default next week
12:56kzartechnomancy: Cool yea, I haven't had any trouble with it. Oh I wanted to ask, am I right in thinking workers are a process that gets left running all the time and can be used for processing things in the background?
12:56technomancykzar: yeah, that's the general idea. usually pulling work off a queue or out of a DB, but not directly exposed to user requests over HTTP.
12:57technomancyI'm working on a devcenter article on the topic.
12:57konrHow can I use C functions in clojure?
12:58kzartechnomancy: Cool throw it my way when you're done :) . Gotta run anyway, cya
12:58technomancycheers
13:00dnolenkonr: JNA or JNI
13:01konrdnolen: thanks!
14:01gfredericksdnolen: I just updated my deps to alpha-8, and everything looks good. Thanks for the quick fix!
14:04daniel__1can anyone tell me why `lein plugin install swank-clojure 1.3.3` is giving me:
14:04daniel__1Exception in thread "main" java.lang.RuntimeException: java.lang.NoSuchMethodError: clojure.lang.KeywordLookupSite.<init>(ILclojure/lang/Keyword;)V
14:05gfredericksdaniel__1: last time I saw that technomancy said something about clojure 1.3 in the dev deps. No clue how/if that applies to your case though.
14:05gfredericksdoesn't sound too related :/
14:06daniel__1hmmm ok
14:07technomancyit could be clojure 1.3 or it could be code compiled with clojure 1.3; one of those is sneaking into the Leiningen process where it doesn't belong
14:07technomancycheck dev-deps and user-level plugins
14:10daniel__1what am i searching for?
14:10technomancydaniel__1: just move your ~/.lein/plugins dir out of the way, and if it still breaks then the problem is in your dev deps
14:11daniel__1that did it
14:11daniel__1my only plugin was nailgun-server
14:11duck1123see if the clojure 1.3 jar is in lib/dev/
14:11daniel__1working now
14:12daniel__1thank yous!
14:13daniel__1beautiful, now i just need to learn how to use emacs
14:13technomancyjust don't let it get in the way of clojure
14:14daniel__1i think all i need to know is how to move back and forward from the swank / code windows
14:14daniel__1buffers
14:14daniel__1frames
14:14daniel__1whatever they're called
14:15duck1123if you're using the starter kit shift + arrow
14:15duck1123otherwise C-x o (for other)
14:16daniel__1C-x o :)
14:16daniel__1what starter kit?
14:17amalloy$google technomancy emacs starter kit
14:17lazybot[technomancy/emacs-starter-kit - GitHub] https://github.com/technomancy/emacs-starter-kit
14:25daniel__1how do i get the repl up if i open emacs again?
14:25daniel__1swank clojure is already running so jack-in fails
14:28patrkris_which HTTP client library are people recommending for clojure these days? clj-http? contrib.http.agent?
14:28technomancyclojurebot: http?
14:28clojurebotdakrone maintains clj-http
14:28technomancy~botsnack
14:28clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentStack>
14:28technomancy=(
14:29patrkris_:)
14:29hiredmanhuh, thats new
14:30Raynes$botsnack because clojurebot couldn't get his doesn't mean you shouldn't get one.
14:30lazybotRaynes: Thanks! Om nom nom!!
14:32gtrak$botsmack
14:32hiredman~botsnack
14:32clojurebotthanks; that was delicious. (nom nom nom)
14:33Raynesgtrak: He doesn't respond to violence thankyouverymuch.
14:33gtrakhe just takes it quietly?
14:34TimMcclever bot
14:36jweissis there a way to tell whether a fn call returns a lazy sequence (possibly infinite)? i'm writing a trace function, and when i attempt to trace a fn call like (iterate inc 1) it blows up obviously.
14:36jweiss,(class (iterate inc 1))
14:36TimMc,(class (range))
14:36clojurebotclojure.lang.Cons
14:36clojurebotclojure.lang.LazySeq
14:36jweissis (iterate inc 1) a special case?
14:37jweissor should i just consider Cons the same as LazySeq (don't try to print the return value)
14:37gtrak,(class (iterate inc 2))
14:37clojurebotclojure.lang.Cons
14:37gtrakCons is just a cons cell, value and ISeq for rest i think
14:38gtrakit doesn't say anything about its laziness
14:38jweissgtrak: right, but it could be infinite, which would blow up my trace fn
14:38gtrakright
14:38gtrakor it could not be :-)
14:38TimMcjweiss: Then don't walk down it forever, I guess.
14:38TimMcWhat is your "trace fn"?
14:39jweissTimMc: https://github.com/weissjeffm/fn.trace/blob/master/src/fn/trace.clj
14:39gtrakprivate final Object _first; private final ISeq _more;
14:39amalloyjweiss: if printing it is what's hard, then bind ##(doc *print-length*) and let clojure handle it for you
14:39lazybot⇒ "; *print-length* controls how many items of each collection the printer will print. If it is bound to logical false, there is no limit. Otherwise, it must be bound to an integer indicating the maximum number of items of each collection to print. If a collection co... https://gist.github.com/1419263
14:40jweissamalloy: ah, that's a neat solution :)
14:40jweissthought i had already set that but I guess not
14:41jweissamalloy: i'm not sure if you saw the discussing this morning around serializable.fn
14:41amalloyno
14:41jweissi think replacing fn with serializable.fn/fn isn't ideal
14:41jweissi know you did that so the double round trip test would work
14:42jweissbut like the first serialization, any subsequent one should depend on whether the namespace uses serializable.fn/fn in place of fn
14:43jweissand even weirder, it turns out that clojure.test/deftest expands into fn. so deftest is using serializable fn, which is what it is supposed to be testing.
14:43jweissso i think that (:use [serializable.fn]) is bad in that test namespace.
14:43daniel__1i cant get my repl back after re-opening emacs
14:43amalloyno, yuck. if your namespace doesn't work properly unless the client :use-s your namespace, your namespace is broken
14:44jweissamalloy: it still works properly when you just require it.
14:44jweissyou just have to refer to it with the full name
14:45jweisshttps://github.com/weissjeffm/serializable-fn
14:45amalloyright, unless you make the serialization be fn instead of serializable.fn/fn
14:45jweissthat's what i did
14:45jweissthe test namespace is doing really bad stuff otherwise
14:45amalloyuhh
14:46jweissdeftest expands into (fn ...)
14:46jweisswhich in that ns is serializable.fn/fn
14:46amalloyokay, so (a) deftest is a little broken, and (b) so what?
14:46TimMcWhy does that mean deftest is broken?
14:46jweissdeftest is broken because it doesn't explicitly say clojure.core/fn ?
14:47amalloyyes. macros shouldn't expand to unqualified symbols unless they have a good reason
14:47TimMc...
14:48jweissamalloy: but your change to use serializable.fn/fn in the meta, that was so the tests would pass :)
14:48jweissand the tests fail because deftest is broken
14:48amalloyno it wasn't. i added that test
14:48jweissoh
14:48amalloyit's because i wanted that feature
14:48TimMcamalloy: deftest uses `(fn ...)
14:48jweissi forgot i pulled from your fork
14:49amalloyTimMc: i was taking jweiss's word for it that deftest expands to 'fn
14:49amalloyin fairness though deftest is also broken in five or six other creative ways
14:49TimMcheh
14:49jweisswell in fairness to me, i did ask this channel if that is what was happening :)
14:50technomancyamalloy: the special casing of thrown? is particularly wacky
14:50technomancyactually, that's c.t/is, but whatever
14:51amalloytechnomancy: right, i'm referring to the way it plays hell with macros
14:51jweissTimMc: actually you asked me if it was a bare symbol, i said yes but didn't notice it was ` instead of '
14:51amalloylike, you can't use macrolet around (or inside of iirc) a deftest
14:52y3di,(conj [1 2 3] 4)
14:52clojurebot[1 2 3 4]
14:52amalloybecause (deftest x (y z)) expands to something bizarre like putting (y z) into the *meta* of x instead of the body, and macrolet doesn't know to go look inside the meta
14:53technomancywhat if c.j.shell had a sh! defn that threw exceptions on nonzero exit codes?
14:53technomancyis that bang-abuse?
14:53amalloytechnomancy: i prefer sh?
14:53technomancybut it's not a predicate?
14:53amalloywell i made that judgement in ten seconds, gimme a break if it's terrible
14:54amalloyor, haha, call it "ohsh!"
14:54duck1123technomancy: I would find that useful (whatever it's named)
14:54technomancyamalloy: it's ok; the non-sequitur question mark reminded me of dinosaur comics, and I had some catching up to do.
14:55y3dihow would i get all the items in a list except the last one?
14:55clojurebotPardon?
14:55amalloy&(doc butlast)
14:55lazybot⇒ "([coll]); Return a seq of all but the last item in coll, in linear time"
14:55y3dity
14:55joegallo,(doc drop-last)
14:55clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
14:55amalloydinosaur comics: leading advocate of wikipedia vandalism since, i dunno, a week or two agi?
14:55joegalloalso
14:56y3di,((fn revvv [x] (cons (first x) (revvv (butlast x)))) [1 2 3 4])
14:56clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.StackOverflowError>
14:57ggherdovHi all. I've heard that Rich Hickey doesn't have a formal background in CS. that's quite impressive. does anybody know more of his bio?
14:57gtrakggherdov, what's a formal background? :-)
14:57ggherdovok. I mean: he didn't do CS at college.
14:57gtrakyou mean like a degree?
14:58ggherdovyeah.
14:58foodoothere was a paper on C++ types that he wrote a long time ago...
14:58gtrakhe did music composition
14:58y3di,(butlast [1])
14:58clojurebotnil
14:58cemerickHe taught C++ at some college in NYC for a while. *shrug*
14:58ggherdovwhat I wander is: how did he became that good,
14:58foodoopractise
14:58gtrakas far as I can tell, he reads a LOT
14:59ggherdovfoodoo: a pointer to that paper? pun intended :)
14:59duck1123I know he worked with a lot of realtime systems. voting machines?
15:00foodooggherdov: It was mentioned in a talk. I'll check if I can find that talk
15:00foodooggherdov: it was mentioned right at the beginning
15:01duck1123it was one of the really old ones
15:01y3di,(cons 1 1)
15:01clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
15:01ggherdovI mean, realtime systems. That's hardcore stuff. How can you get involved in such a career w/o training.
15:01gtrakhe was an independent consultant for 15 years?
15:01ggherdovfoodoo: thx
15:01gtrakor more?
15:01duck1123no formal training != no training
15:01gtrakggherdov, it's really not that hard, 3-5 years of deliberate study and you can do lots of things
15:01Borkdudeisn't it a bit ugly that when you want to "use" core.logic, you have to exclude == ?
15:01ggherdovduck1123: sure. but 'formal' is somehow easier to get.
15:02y3di,(butlast [1 2])
15:02ggherdovgtrak: sure, but if you have a day job, time is an issue.
15:02clojurebot(1)
15:02ggherdov\energy too.
15:03duck1123what formal training have you had in clojure, you know clojure because you had a desire to learn it.
15:03duck1123was anyone here forced to use clojure?
15:03y3di(cons 1 nil)
15:03y3di,(cons 1 nil)
15:03clojurebot(1)
15:03ggherdovduck1123: i see the point, but i was trained to haskell, caml and stuff.
15:03TimMcy3di: You can /msg the bots
15:04y3dialright, will do
15:04gtrakggherdov, if you do 15% more studying than the average programmer, you'll learn twice as much every 5 years
15:05gtrakor something like that :-)
15:05joegallonot quite, i think, but it's a nice idea
15:05daniel__1i cant get my repl back after re-opening emacs (swank-clojure) heeeelp
15:05TimMcOnly a couple of my college courses actually helped me become a better programmer.
15:06duck1123daniel__1: M-x slime-connect
15:06Borkdudeformal training can set you on the wrong path for a long time ;)
15:06technomancydaniel__1: if you started swank via jack-in, then the swank server will not outlast emacs
15:06zakwilsonhttps://gist.github.com/1415370 <-- ClojureQL seems to be generating unreasonable output here in terms of the order of the joins. Changing the order in the Clojure code doesn't affect the order in the SQL it emits.
15:06daniel__1hmm technomancy, ok
15:07zakwilsonThough if I'm just doing something dumb, I'd like to know.
15:07duck1123I think my favorite was the class I took on C++ data structures. I was just getting into my love of Clojure and learning exactly how things like vectors and sets were supposed to work really helped
15:07daniel__1error in process filter: error during connect: connection refused
15:07daniel__1it worked the first time, now it won't open up
15:08gtrakcompilers was enlightening for me
15:08BorkdudeCommon Lisp was enlightening for me, but it wasn't taught at my CS faculty
15:09foodooggherdov: found it! http://blip.tv/clojure/michael-fogus-fertile-ground-the-roots-of-clojure-4519764 (The quote on C++ from Rich's paper is pretty much at the beginning)
15:09foodooAnd I really love the way the Clojure community does presentations :D
15:09BorkdudeThe first programming course we got was a functional programming course though
15:10BorkdudeMiranda
15:10foodooat university? We had Haskell
15:10foodooWhich is a great language but a bad choice if you want to foster enthusiasm in students when it comes learning how to programming
15:11dnolengfredericks: np
15:11gtraki had the scheme class freshman year, i didn't pay too much attention to it but i think it might be responsible for the initial mind-warp
15:11gtraksadly they're on python now
15:11jweisslooking back on my 'formal training' in CS, we used Turing, Java, Perl, C. the only one that's a good learning experience IMO is C.
15:12duck1123I wonder how well Clojure does as a introductory level when people have no pre-conceived OOP or procedural notions
15:12foodoojweiss: in the context of your studies at your university?
15:12Borkdudemaybe Haskell was a bit too new in 99, I don't know why they chose Miranda, I've never used it since
15:12Borkdudeduck1123: me 2..
15:12jweissfoodoo: no, in general, but even in the context of the classes
15:13gtrakduck1123, drscheme had various settings of having to know about details, it was helpful, there was a beginner mode
15:13gtraki think freshmen wouldn't handle clojure's stack traces well
15:14foodootrue
15:14jweissscheme would have been a much better choice for first language. i started with BASIC :)
15:14zakwilsonYeah, those aren't user-friendly.
15:14jweissnot that my commodore 64 had a scheme interpreter.
15:14foodooMy personal recommendation as a first language is Lua. It's simple, elegant but not useless.
15:15aphyrHaving some trouble with the protobuf library. I've added it as a dep in cake, I've got a protobuf-0.5.0-beta4.jar file on my project classpath, but cake test throws "could not locate protobuf__init.class or protobuf.clj".
15:15jweissi once saw a review of langauges based on speed and conciseness, lua won hands-down
15:15gtrakI remember scheme just took forever to write, it was demoralizing :-) 6 hours and all you get is 5 lines and a ton of parentheses
15:15aphyrAny ideas?
15:15daniel__1technomancy: can i get swank-clojure to open automatically when it detects a clojure file? rather than typing clojure-jack-in each time
15:15mco_Hi all, I am trying to read a binary file but I am having an issue with signed/unsigned byte..... I need to read at any offset in the file for n bytes. Is there an idiomatic way to do that ?
15:15Borkdudethe idea that code itself was data really made sense to me, it is an idea so simple, yet brilliant, I still remember when I first discovered Lisp and loved it ever since
15:15duck1123I still have my Atari XE. Had to leave it running because I didn't have the tape drive
15:15technomancydaniel__1: you could write a hook for that, sure. the start-up time is significant enough that I'd find it annoying to have it invoked automatically personally, but it's possible
15:16daniel__1hmm, yeah good point
15:16jweissgtrak: 6 hours of 'find the missing paren'?
15:16mco_I am currently using RandomAccessFile. and reading in a byte-array....
15:16duck1123I'd love to have the hook that emacs should reconnect and retry if I try to do a slime command and it fails
15:16gtrakdude, I got like a 98 in the class, and I remember it took me forever. the insertion sort is forever burned in my retina
15:17daniel__1finally my repl came back anyway
15:17daniel__1dont know what happened there
15:17gtrakjweiss, I think a lot of people would just cheat
15:18foodooggherdov: did you receive the link to the video?
15:18ggherdovfoodoo: no.
15:18ggherdovI got disconnected,
15:18ggherdovdidn't mean to be rude.
15:18foodoohttp://blip.tv/clojure/michael-fogus-fertile-ground-the-roots-of-clojure-4519764
15:18ggherdovthx
15:19foodoo(downloadable with cclive if you don't like flash)
15:19daniel__1the repl seems to load in the user namespace, can't i have it load into the current files namespace?
15:19gtrakhow does the repl know what file you're in?
15:19duck1123C-c M-p
15:20gtrakneat
15:20ggherdovfoodoo: cclive ? what's that?
15:20foodooA video downloader
15:20ggherdovok
15:21daniel__1duck1123: Command attempted to use minibuffer while in minibuffer
15:22mco_:) has anybody done that before ? reding n bytes from an offset in a binary file ? Please ?
15:22mco_ have been googling for ages
15:23mco_can't be that hard right ?
15:23raekmco_: you generally use the Java classes for IO
15:23duck1123daniel__1: you already were doing a command when you tried that. hit escape a bunch of times
15:23raekRandomAccessFile is good for this
15:23mco_@raek: thanks, that is what I did
15:23mco_I used RandomAccesFile. .skipBytes .read etc
15:24mco_but the unsigned/signed thing limitation for byte-array is driving me nuts
15:24duck1123daniel__1: C-g will also break out of stuff in most cases in emacs
15:24mco_first byte outside the limits causes an error
15:24raekon the JVM signed and unsigned bytes are stored in the same type
15:24_uliseshello all
15:24mco_user=> IllegalArgumentException Value out of range for char: -96 clojure.lang.RT.charCast (RT.java:907)
15:25mco_this is the error I get
15:25raekmco_: a character is not the same thing as a byte
15:25mco_ahhh sorry, I am a beginner :) surely it is a dumb error :)
15:25mco_I am using (.read file x 0 n)
15:25mco_to read in a byte-array
15:26mco_I allocate before
15:26daniel__1duck1123: i lost the repl buffer by pressing escape but i think its still running. how can i get it back?
15:26gtrakC-x b
15:26mco_(defn read-n-ofs [f n offset func]
15:26mco_ "Reads n bytes from file f at offset and apply func"
15:26mco_ (with-open [file (RandomAccessFile. f "r")]
15:26mco_ (.skipBytes file offset)
15:26mco_ (let [x (byte-array n)]
15:26mco_ (.read file x 0 n)
15:26mco_ (func x))))
15:26mco_ sorry guys
15:27daniel__1thanks gtrak
15:27raekmco_: ok looks fine (use http://gist.github.com/ next time). you can also use the .seek method
15:27duck1123I hightly recommend creating a binding for M-x slime-selector. I have it bound to C-c s so my repl ic C-c s r
15:27raekbut that .read call should give you an array of n bytes
15:27gtrakdaniel__1, also check out M-x describe-bindings
15:27_ulisesduck1123: I think with C-c C-z it jumps to the repl buffer
15:27TimMcgtrak: What school did you go to?
15:27gtrakgeorgia tech
15:28raekor more accurately: up to n bytes
15:28daniel__1having the same problem starting swank again now :(
15:28daniel__1clojure-jack-in-sentinel(#<process swank> "exited abnormally with code 129\n")
15:28duck1123_ulises: not for me
15:28gtrakTimMc, i think we just do whatever MIT does
15:28gtrak:-)
15:28mco_raek: but the first byte that is outside signed values causes the Exception I have noticed
15:28gtrakbut i didn't get a CS degree
15:28_ulisesduck1123: interesting; that's the binding I get in my clojure-mode
15:29duck1123_ulises: I take that back. I had to be on a clojure-mode buffer. The slime selector route is global
15:29raekmco_: what do you do with the bytes? to me it does not seem that the error is in the read-n-ofs function
15:29_ulisesah!
15:29y3dican anyone help me figure out whats wrong with this:
15:29y3di,((fn revvv [x] (cons (last x) (revvv (butlast x)))) [1 2 3])
15:29clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.StackOverflowError>
15:30mco_raek: I use func to post-process whatever I have read ( build a string or calc an integer value)
15:30duck1123y3di: I think you want to wrap that in lazy-seq
15:30mco_raek: #(apply str (map char %)) to get a string for example
15:30raekmco_: the exception you mentioned means that you are trying to turn a byte into a char incorrectly
15:31mco_raek: ah okay, here is the error : (make-byte-array [1 210 3] )
15:31TimMcgtrak: Ah, makes sense. I know that MIT switched from Lisp/Scheme to Python for intro, but I didn't think they had used DrScheme before. :-)
15:31raekmco_: you should use the classes in java.nio.charset to convert bytes to strings
15:32mco_raek: aah thanks !! I will investigate this
15:32y3diduck1123: wrap the revvv function in lazy-seq?
15:33y3diduck1123: i
15:33y3diduck1123: i'm new to clojure so excuse my lack of understanding
15:33daniel__1duck1123: i get Package: evolve.core [no match] when i try and go to this namespace :(
15:33TimMcmco_: Why does your function take a function? Just compose.
15:33TimMceasier to test and understand
15:34duck1123y3di: I'm having a hard time figureing out why that's overflowing in my head. one sec
15:34raekmco_: you first need to create a Charset instance for the encoding your text is in (def charset (Charset/forName "UTF-8"))
15:34mco_TimMC: thanks ! I'll look it up
15:34duck1123daniel__1: the namespace needs to be required first. C-c C-k to load that file
15:34raekmco_: then you can use .decode or .newDecoder
15:34daniel__1C-c C-k is undefined
15:34gtrakTimMc, yea, the CS and computer engineering guys took the scheme class, other engineerings took matlab.
15:35daniel__1sorry, was in wrong buffer
15:35raekmco_: these methods also require the input and outputs to be ByteBuffers and CharBuffers
15:35daniel__1gotchaaa
15:35TimMcmco_: No, I mean just use good ol' function composition. (func (read-n-ofs ...)) is better than (read-n-ofs ... func).
15:36raekmco_: but there is also a more minimal way: (String. the-byte-array "UTF-8")
15:36duck1123y3di: try checking if x is not empty (when (seq x) (cons ...
15:36mco_TimMC: in fact I defined two other functions on top of that one that build either a string or an integer
15:36raekjust replace "UTF-8" with whatever the encoding of your text file is
15:37duck1123y3di: it's recursively (and not the good kind) calling itself even when there are no more elements in the list
15:37TimMcmco_: OK, but it's not as clean.
15:38mco_raek: ok, thanks !
15:38duck1123y3di: generally, you would want this sequence to be lazy, so you would wrap this whole thing in a lazy-seq, and then check that there are still items left and return the cons cell, that way this whole thing will be lazy
15:38daniel__1is there an equivalent for cycling through repl history like using the arrow keys in the terminal?
15:39duck1123M-p M-n
15:39duck1123those are two commands
15:40daniel__1aaah great :)
15:40duck1123if you start typing a command and then do that, it'll cycling through matching lines
15:42TimMcdaniel__1: Analogous to C-p and C-n
15:42raek,(String. (byte-array (map byte [72 101 108 108 111 32 47 32 -50 -109 -50 -75 -50 -71 -50 -84 32 -49 -125 -50 -79 -49 -126])) "UTF-8")
15:42clojurebot"Hello / Γειά σας"
15:42BorkdudeWhy doesn't this work? (refer '[clojure.core :exclude [==]])
15:42foodooI wonder how much new stuff I will learn from "The Joy of Clojure" after having read "Programming Clojure". Is the first book much more advanced than the latter?
15:43raekBorkdude: you need to do it like this: (ns foo.bar (:refer-clojure :exclude [==]))
15:43mco_raek: cool! but change one value to , say, -166 and *boom*
15:43TimMcBorkdude: It's too late, you've already included all of core.
15:43y3dity duck1123 i finally got it, im sure my method could be alot better tho for reversing a seq
15:43raekmco_: what do you mean?
15:43y3di,((fn revvv [x] (cons (last x) (if (not (nil? (butlast x))) (revvv (butlast x)) nil))) [1 2 3])
15:43clojurebot(3 2 1)
15:44BorkdudeTimMc: not if I didn't use clojure.core right?
15:44raekmco_: you will never get a -166 from a byte
15:44TimMcBorkdude: (ns) does it automatically
15:44raekmco_: since bytes are from -128 to 127
15:44TimMc&(byte 166) ; mco_
15:44lazybotjava.lang.IllegalArgumentException: Value out of range for byte: 166
15:44BorkdudeTimMc: raek I'm on a repl here, so I don't want to type (ns ...)
15:45Borkdudedoing the examples of https://github.com/clojure/core.logic
15:45mco_raek: yes , that's what I'm having a hard time getting used to it seems :)
15:45duck1123y3di: it's recommended to prefer (seq coll) over (not (nil? coll))
15:45TimMcBorkdude: Whatever set up your REPL already pulled in core. refer can only add stuff.
15:45mco_raek: I gotta read more and understand that charset business
15:45raekBorkdude: (remove-ns 'foo.bar) (in-ns 'foo.bar) (refer-clojure '(:exclude [==]))
15:45BorkdudeTimMc: then how could the example work ;)
15:47raekmco_: the jvm is a bit weird in that bytes are represented as a value between -128 and 127 instead of between 0 and 255. you can easilly get to the latter from the former like this: (bit-and some-byte 0xff)
15:47duck1123y3di: IIRC (not (nil? coll)) is esentially (not (not (seq coll)) and that's just a waste
15:47raek,(bit-and -127 0xff)
15:47clojurebot129
15:47Borkduderaek: still getting the errors, seems to me the example is just not the good way anymore?
15:48TimMcduck1123: That's not true for collections in general.
15:48gtrakare atoms slow?
15:48TimMcnot + nil? is cheaper than seq, but seq is *correct*
15:49raekBorkdude: you can't you use ns in the repl?
15:49Borkduderaek: I can, I'm just not used to
15:49duck1123TimMc: Im'm thinking of (not (empty? ))
15:49raekBorkdude: another approach could be to do (ns-unmap *ns* '==)
15:50mco_:raek + TimMC : *thanks* guys ! I will be programming and reading now ... :)
15:50raekif you are in an already existing namespace (like user)
15:50raekmco_: a charset defines how bytes correspond to characters.
15:51Borkduderaek: I guess (ns my-logic (:refer-clojure :exclude [==])) does it then.
15:51iLeNsTRb
15:51gtrak$(doc assoc)
15:52raekmco_: for instance, what is/are the bytes(s) for the letter "ä"? it depends on which charset that byte stream has.
15:52mco_:raek: I got it to work by replacing the last line of that function with (func (map unsigned-byte x))
15:53mco_raek: looks like str was the cuplrit ...
15:53raekin a file that uses ISO 8859-1, "ä" is encoded as the byte 0xE4, but in a UTF-8 file it is encoded as 0xC3 0xA4
15:53gtraki like that rich hickey uses for(; ;), i feel vindicated :-)
15:54gtrakdid you guys know java has a do-while?
15:54raekmco_: are you turning a byte array into a string without specifying a charset? if so, your code is (probably) broken.
15:56y3di,(doc seq)
15:56clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
15:56raekmco_: if your byte array is called "byte-array", then just use (String. byte-array "UTF-8")
15:58TimMcduck1123: yup
16:01y3diinto works differently for vectors and lists?
16:01TimMcy3di: Just like conj.
16:02hiredmany3di: into uses conj
16:02hiredman,(conj '(1 2 3) 4)
16:02clojurebot(4 1 2 3)
16:02hiredman,(conj [1 2 3] 4)
16:02clojurebot[1 2 3 4]
16:02Borkdudehmm, now when I evaluate moveo it complains about the symbol pos not able to resolve
16:03y3diok thanks
16:21TimMcIt is my reasoned conclusion that having first, rest, next, and cons call seq on their argument is just plain confusing to newcomers.
16:21TimMcIt hides the fact that an API boundary is being crossed.
16:22tsallyis there a fucntion to call a function on a arg, and then call the function again on the result, n times ?
16:23duck1123TimMc: it would be chaos without though
16:23TimMctsally: iterate, I think
16:23TimMcor similar
16:23y3diis there a way to get clojurebot to understand multiline queries?
16:23y3dii doubt it, but i figured id ask
16:24TimMcduck1123: Lots more if-lets and other extra calls to seq, eh?
16:24duck1123y3di: I think the assumption is if you can't fit it on a line, then it should be a gist
16:24y3digist?
16:24TimMc~paste
16:24clojurebotpaste is http://gist.github.com/
16:25TimMcbut that's if you're trying to demonstrate something to someone on the channel
16:25TimMcy3di: If you want to just find the result, download Leiningen and run "lein repl".
16:26duck1123y3di: also tryclj.com
16:27TimMcOoh, that too.
16:27y3diright
16:27y3dihttps://gist.github.com/8d4e4bd76669846874c7
16:28TimMc$mail alexbaranosky It just occurred to me, a good project for the meetup would have been to write a "try-cljs" website.
16:28lazybotMessage saved.
16:28y3dithat works for [1 2 3 2 1] but not for "racecar"
16:28y3dianyone knows how I can fix it? I tried to call seq on racecar so that it changes it to a list, but my function still errors out
16:29hiredmany3di: your function isn't properly recursive, and (seq [x]) is always true, so your if is badly written
16:30TimMcy3di: Technically, it seq provides a sequence over the string, it doesn't convert it.
16:30y3di,(if (seq []) true false)
16:30hiredmanD
16:30clojurebotfalse
16:30gtrakwhoa, lazybot does messages?
16:30RaynesHe does a lot of things people don't know about.
16:31hiredmanI didn't say (seq []) I said (seq [x])
16:31hiredmanwhich is what you have in your if
16:31hiredman,(booealn (seq [nil]))
16:31clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: booealn in this context, compiling:(NO_SOURCE_PATH:0)>
16:31gtrakRaynes, I had already decided he was awesome so I stopped exploring
16:31RaynesHeh
16:31hiredman,(boolean (seq [nil]))
16:31clojurebottrue
16:31hiredman,(boolean (seq [:foo]))
16:31clojurebottrue
16:31hiredman,(boolean (seq [false]))
16:31clojurebottrue
16:32hiredman,(boolean (seq [true]))
16:32clojurebottrue
16:32hiredmanetc, etc, etc
16:32gtrak$fortune
16:32lazybotI have no fortune cookies. Please feed me some!
16:32y3dihmm, ok someone earlier said I can use (seq [x]) to check if a list is empty or not
16:32RaynesThat plugin is going away.
16:32TimMchiredman: I imagine you saying that in the voice of that character from The King and I.
16:32gtrakah, sad
16:33TimMc~#3
16:33clojurebot3. Syntactic sugar causes cancer of the semicolon. -- Alan J. Perlis
16:33RaynesThere are a bunch of bastardized plugins that could just be replaced with a decent factoid system.
16:33TimMcRaynes: ^ that feature is a tiny bit tricky to use over SSH.
16:33hiredmany3di: someone was wrong
16:33hiredmanor you misread what they said
16:33y3diyea alright
16:33RaynesTimMc: I have no idea what you just said.
16:33hiredmanI am inclined to believe the latter
16:34duck1123hiredman: it was a little of both :(
16:34gtrakjavabot's system seems simple enough
16:34TimMcRaynes: Are you connected over SSH?
16:34RaynesTo what?
16:34TimMcAh. You are not using a command line IRC client.
16:34RaynesGod no.
16:35TimMcRaynes: <Enter>, [~] is the SSH escape sequence. Typing <Enter> [~] [#] prints a list of connections. :-)
16:35RaynesIrssi gives me diarrhea.
16:35tscheibl@Raynes: and u don't even use emacs or vi?
16:35Raynestscheibl: I do use Emacs.
16:35rickmodeWhy does (def foo ^{:name "Foo!"} [1 2 3]) work but (def foo ^{:name "Foo!"} (list 1 2 3)) not work?
16:35duck1123,(boolean (seq []))
16:35clojurebotfalse
16:36RaynesI don't use it in a terminal.
16:36tscheiblisn't there e irc plugin for emacs?
16:36hiredmanrickmode: what does '^' do?
16:36tscheiblah xirc
16:36duck1123tscheibl: M-x erc
16:36technomancytscheibl: there are four or five
16:36technomancyonly two built-in though
16:36tscheiblthought so
16:37Rayneserc never worked very well for me.
16:38y3diso I got rid of the (seq [x]) check and used empty instead but i still have the same problem
16:38y3dihttps://gist.github.com/8d4e4bd76669846874c7
16:38rickmodehiredman adds metadata to an object: http://clojure.org/reader
16:38y3diit works with the first but not the second
16:38hiredmanrickmode: what object?
16:39hiredmana related question would be, why does ^:foo [1] add the metadata to the vectore, but ^:foo '[1] doesn't
16:40rickmodehiredman: in this case the vector or list. (meta foo) returns the metadata map for vector, but not the list
16:40hiredmanwhich vector or list? where do they come from?
16:40tscheibly3di: u mena "empty?" ?
16:40_ulisesy3di: what does (first (seq ["racecar"])) return?
16:40tscheiblmean
16:41_ulisesy3di: hint, line 13 is your problem
16:41rickmodeI'm creating a def for a list
16:41_ulisesor more like 11 and 3 too
16:41hiredmanbut there are really two lists there, right?
16:41rickmodein this case it's contant (a list of agents i'm using elsewhere)
16:42hiredmanthe list (list 1 2 3) and the list (1 2 3)
16:42hiredmanwhich one are you checking for metadata? and which one is available for the reader to attach metadata to?
16:43y3dioh wow, ty _ulises
16:43_ulisesy3di: no worries :)
16:43rickmodehiredman: you've lost me. (list 1 2 3) returns the list (1 2 3). (1 2 3) attempt a function call on 1 with params 2 3.
16:44hiredmanright, but this is lisp right? so (list 1 2 3) is a list too, right?
16:45hiredmanso you have two lists there, (list 1 2 3) ;; the list the reader creates and (1 2 3) ;; the list the function call results in
16:46rickmodeI'm assuming with (def a (b c d)), a will be a ref to the result of evaluating (b c d)
16:46hiredmanin light of the fact there are two lists, which one are you checking for metadata?
16:46hiredmancorrect
16:46rickmodeI want to add metadata such that (meta a) returns it
16:47hiredmanso you have a (list 1 2 3), which the compiler sees as a function call and generates a call to the function list with the arguments 1 2 3, the result of which is (1 2 3)
16:47hiredmanso you have two lists, (list 1 2 3) and (1 2 3), which one are you checking for metadata?
16:48TimMchiredman: May I ask a spoiler-ish question?
16:49rickmodethe list (1 2 3) is what I want.... so the question is... when does the reader attach the metadata? it's not clear
16:49hiredmanwhen can it?
16:50hiredmanwhy does ^:foo [1] add the metadata to the vector, but ^:foo '[1] doesn't
16:50mefesto,(doc with-meta)
16:50clojurebot"([obj m]); Returns an object of the same type and value as obj, with map m as its metadata."
16:50rickmodeMy mental model of Clojure tells me.. after evaluating the expression, before asigning to the Var
16:50hiredmanthe reader is not the evaluator is it?
16:50rickmode"Metadata (^) Symbols, Lists, Vector, Sets and Maps can have metadata, which is a map associated with the object. The metadata reader macro first reads the metadata and attaches it to the next form read: ^{:a 1 :b 2} [1 2 3] yields the vector [1 2 3] with a metadata map of {:a 1 :b 2}."
16:51rickmodeSo that a bit misleading
16:51hiredmanhow so?
16:51y3di_ulises: so (first (seq ["racecar"])) returns "racecar" which would be an issue, but based on my code, I don't think i ever call (seq ["racecar"]) its only (seq "racecar")
16:51hiredman(1 2 3) is not the form that is read
16:51rickmode^{:name "hi"} (list "hi") doesn't work
16:51hiredman(list 1 2 3) is the form that is read
16:51y3diunless im misunderstanding something
16:51_ulisesy3di: are you sure? your fn takes a parameter x and then you call (seq [x])
16:51rickmodebut ^{:name "hi"} ["hi"]
16:51rickmodedoes
16:52hiredman["hi"] is the form that is read
16:52rickmoderight
16:52rickmodeI'm getting what you're saying
16:52rickmodehowever
16:52hiredmanno, you don't
16:52y3di_ulises: yea, but the x that it takes is "racecar"
16:52y3dinot ["racecar"]
16:52rickmodeShould be : Metadata (^) Symbols, Lists, Vector, Sets and Maps can have metadata, which is a map associated with the object. The metadata reader macro first reads the metadata and attaches it to the next form read: ^{:a 1 :b 2} [1 2 3] yields the vector [1 2 3] with a metadata map of {:a 1 :b 2}..... But you cannot use ^ with Lists
16:52_ulisesy3di: yes, so you end up calling (seq ["racecar"])
16:52hiredman,(read-string "^{:n 1} (list 2)")
16:52clojurebot(list 2)
16:53hiredman,(meta (read-string "^{:n 1} (list 2)"))
16:53clojurebot{:n 1}
16:53hiredmanrickmode: that is not true
16:53dnolenrickmode: attaches it to next *form*, not what the next form evaluates to.
16:53hiredman,(meta ^{:n 1} (list 2))
16:53clojurebotnil
16:53rickmodesure... and so ^ won't do anything useful with a list
16:53TimMcrickmode: [1 2 3] is a literal vector. (list 1 2 3) is a function call that produces a list.
16:54TimMcliterals evaluate to themselves.
16:54rickmode,(meta {:n 1} [2])
16:54clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: core$meta>
16:54rickmode,(meta ^{:n 1} [2])
16:54clojurebot{:n 1}
16:56TimMcrickmode: ^ is used for handing metadata to the compiler -- you don't generally get access to that metadata at runtime.
16:56TimMcwith-meta is the safe way to attach metadata to runtime values
16:57TimMcso... it's not really a problem that it is awkward to attach metadata to a list literal.
16:57rickmodeTimMc: now that makes sense
16:57rickmodehold on while I reattaches the bits of my exploded head. Thanks guys.
16:58TimMcJust because ^{:n 1} [1 2 3] leaks down to the runtime doesn't mean you should rely on it. :-)
16:59TimMc(Homoiconicity makes it easy to confuse the levels.)
17:00rickmodeTimMc: that "^ is normally used to pass metadata to the compiler; with-meta is idiomatic when added metadata to your own objects" tip *could* be mentioned on the clojure.org/reader page.
17:00TimMcrickmode: Many things could. :-(
17:01rickmodeTimMc: word... the clojure.org bits and the API docs are genearlly useful if you know what you're doing. They dont' really stand alone.
17:02TimMcI have many complaints about the doc. I should really open a ticket...
17:03rickmodeHeh... If I complain much more I'd feel obligated to get off my butt and participate... :P
17:05rickmodeTimMc and hiredman: so ya.. I need a better mental model of reader-time vs evaluation-time
17:06TimMcSo do I!
17:06TimMcClojure also complicates that a bit by doing on-the-fly compilation.
17:07rickmodeWhich is pretty fly
17:08gfredericksit's read vs compile vs execute, in my head
17:08gfredericksso compile time is when macros get "run"
17:08rickmodearen't here really only 2 stages?
17:08rickmodeat least logically
17:08gfredericksI think it's confused because the compiler can be used at runtime
17:08gtrakrickmode, you'll notice there's an init class generated for each namespace, that should be helpful to think about
17:09rickmoderead time and execute time? compiling is somewhat invisible
17:09gfrederickse.g. calling eval invokes the compiler I think
17:09gfredericksrickmode: I think distinguishing compile from execute helps understand what macros can and can't do
17:09rickmodeya - I know if you put non-def forms in a file, those will be evaluated / executed when you load/use/require the file
17:09gfrederickspeople often want to "apply" a macro
17:10gtrakif you run eval, it has to create new classes and load them
17:10gtrakbefore it can actually execute the code
17:11rickmodeso in a sense def are not magically - they are "executed" in the order they appear in the file. And thus you can't refer to something defined later in the file (unlike Java)
17:11gtrakwhen you type (defn ...) in a file, you're telling it to create a class for the function, and the init class for the namespace will bind an instance of that class to the var
17:13duck1123that's also the reason you can't have circular dependencies in your namespaces
17:13gtrakrickmode, that's the dynamic binding, but there's also a more static way, I'm not clear on the details
17:13rickmodeyou can use declare to get circular refs
17:13gtrakthings can get inlined
17:14gtrakand compiling a ns will compile all the other ns's it depends on
17:15gtrakrickmode, so here's a gotcha, create 2 namespaces in two files, create a fn in 1st that refers to a fn in 2nd, change the 2nd and recompile it, the 1st will still refer to the original function
17:16gtrakif you want the lookup to be dynamic, you have to use (var or #'
17:16gtrakor recompile the 1st namespace too
17:22TimMcrickmode, gtrak: It's not defn that creates classes so much as it is fn.
17:23rickmodegtrak: I seem to hit redefinition snags doing remote debugging
17:23gtrakTimMc, yup
17:24TimMcand really fn*
17:24rickmodeI have my slime connected to a remote machine.. I can use C-c C-k
17:24gtrakit's important to superficially know about classloaders when you're talking about this stuff
17:24rickmodesorry I can't use C-c C-k
17:27gtrakthat cadaddadr macro is awesome :-)
17:28gtrakamalloy ^
17:28amalloygtrak: not my original idea, of course, but pretty easy to implement
17:28gtrakit's some deep magic nonetheless
17:29gtraki never thought about encoding semantics into a string and pulling it out with a regex
17:30TimMcgtrak: That's probably a good indicator re: your sanity.
17:30gtraknecessary but not sufficient to prove sanity :-)
17:30technomancyrickmode: that mostly has to do with filename translation IIRC
17:31technomancyeasy way out is to use C-c C-r
17:33amalloyyes, it's filename issues: such a pain. maybe i'll bind C-c C-l back to slime-eval-buffer
17:33amalloysince i never use the reload functionality (and it didn't seem to work when i tried), but remote-swank matters to me
17:34gtrak<-crazy: i wonder if you could do an inline bytecode macro?
17:35gtraklike C's drop down to assembly
17:38TimMcwut
17:41rickmodetechnomany: thanks... anothing thing, if I do a slime-connect I don't get a slime-repl window. If I do a clojure-jack-in to start a local session, I do get the slime-repl. And then after that I can hook up to the remote swank and get a slime-repl. Weirdness.
17:42technomancyrickmode: yeah, could be that slime-repl hasn't been boottrapped yet
17:42technomancybootstrapped
17:42rickmodetechnomancy: is there a way to kick it? start it manually? I looked all the slime commands but didn't one to start a repl.
17:43technomancyrickmode: you would need to manually install slime-repl if you want to use it without M-x clojure-jack-in
17:43technomancyit's a separate marmalade package from slime for some reason
17:48rickmodetechnomany: ack - well i'm Aquamacs so I'm kinda floating in my own world. The new clojure-mode makes life a lot easier though ;)
17:49technomancyah... well yeah; good luck with that =(
17:49rickmodetechnomany: I still need my training wheel! heh
18:12amalloydoes it make any sense for a single machine to have multiple private ssh keys? or does it always go the other way - create (at most) one private key per client, and tell the server that these are all acceptable keys?
18:18TimMcamalloy: I have multiple keypairs on my laptop. One is passwordless and one is not. I use them for servers of varying importance.
18:20TimMcamalloy: However, at the last Boston Clojure meetup, what's-his-face distributed a private key for everyone to use to log into a shared terminal on an EC2 machine.
18:21TimMcI think of it as group keys vs. user keys.
18:23amalloyTimMc: well, atm i'm putting together a simple tutorial on using clojars. i was going to create a new keypair for a new clojars account, but i realized i have no idea how clojars would know which key to use when i try to scp the jar
18:23ordnungswidrigin a macro I want to generate a keyword in the *current* namespace. How would I do?
18:23ordnungswidrig(defmacro foo ¢ `(keyword o
18:23ordnungswidrigups
18:24amalloyordnungswidrig: *ns*
18:24technomancyamalloy: it should just try the first thing on the list that `ssh-add -l` gives you
18:24amalloyman, i don't know how to use ssh-agent
18:25TimMcamalloy: I use a config file to tell SSH which key to use.
18:25ordnungswidriglike in (defmacro foo [bar] `(keyword ??? 'bar))
18:25RaynesI'm happy that I'm not as paranoid as you.
18:25ordnungswidrigamalloy: *ns* is of type namesapce where keyword expects a string
18:25amalloyoh, i see. didn't know you could do that. i already have a bunch of crap in .ssh/config
18:26TimMcHost clojars.org\n\tIdentityFile ....
18:26amalloy&(-> *ns* ns-name name) ; clojure is trolling us here...
18:26lazybot⇒ "sandbox17152"
18:26choffsteinOkay -- prepare yourselves -- this may be a very, very stupid question. I've been struggling to fully comprehend moads for a while now. Beside their base properties, I can't see through the fog to their "why". All of a sudden, I have either had a moment of complete enlightenment or complete stupidity. Would it be correct to say that monads give functional languages the ability to control how a function is applied to an value
18:26choffsteincontrolling the value and not the function? For example, if I wanted to create a hopelessly egocentric value (x s.t. (f x) is x for all f), it is fairly trivial in an object oriented language -- but not so trivial in a functional one. It seems to me, though, that this could be done with a monad … where m-result always returns x. Am I crazy?
18:27TimMcamalloy: ^ ignore that, look at this: https://gist.github.com/1420671
18:27technomancychoffstein: it's been my experience that if you have to ask if you're crazy, then you probably just figured out how monads work
18:28TimMcThere's a host alias in there as well as an unrelated directive listing all the keyfiles to try for arbitrary hosts.
18:28choffsteintechnomancy: mental breakthroughs always sort of require the gymnastics that make us think we are crazy, huh?
18:28technomancychoffstein: it's that or severe head trauma
18:28ordnungswidrigamalloy: thanks. weird but works.
18:29TimMcRaynes: How am I paranoid? One of my (2) keys doesn't even have a passphrase!
18:30amalloythanks TimMc. have forked gist and will maim it until it does what i wantr
18:30TimMchaha
18:31TimMcbeing able to type `ssh timmc@nfsn` is pretty nice.
18:31amalloyTimMc: you can configure it so that ssh nfsn just works; is there some reason you're using the timmc@ prefix?
18:32choffsteinI think I'm going to go with "I'm crazy" until I actually figure this out
18:32TimMcYes, I have different accounts there. It's actually phyzome_brainonfire@nfsn.
18:32amalloychoffstein: fwiw i think you're crazy but i don't really understand them either
18:33choffsteinamalloy: Yes, but your thoughts of me are horribly skewed by my previous questions in this channel that you have had to respond to … so, I don't know if this is an isolated case of crazy or just your general consensus of me
18:34amalloyTimMc: back when i was dual-booting windows/linux, i had different usernames on the same computer depending on the mode it booted. i gave them different hostnames to avoid that: ssh linux (akm@server), vs ssh windows (Alan@server)
18:34amalloyyou might like something similar, or think i'm crazy
18:35TimMcI have like 8 logins at NFSN.
18:35amalloyokay okay
18:35dnolenchoffstein: I think it's much harder to see Why Monads unless the language is nearly useless w/o them, aka Haskell.
18:35TimMcbut good idea otherwise
18:35amalloyi don't even know what nfsn is
18:35amalloyit just looks like nsfw
18:35TimMcWeb hosting. "Nearly Free Speech.net"
18:36dnolenchoffstein: I think Dan Friedman and Adam Foltzer's explanation is one of the best I've seen - https://www.cs.indiana.edu/cgi-pub/c311/lib/exe/fetch.php?media=manymonads.pdf
18:36choffsteindnolen: Yeah … i played around in haskell for a while. I should really spend some more time with it if I am ever going to reach monad enlightenment
18:36choffsteindnolen: thanks, I'll take a look
18:36TimMcamalloy: I really like their pay-for-what-you-use model, and I wish I could get the same deal with a JVM-supporting host.
18:37dnolenchoffstein: the other thing to realize is that they are about as fun as callback spaghetti unless you have compiler support.
18:37dnolenI did see something almost readable in Ruby but it used continuations
18:37choffsteindnolen: Yeah -- I haven't seen 'em much in clojure, so I assumed there was an easier way to achieve the same results
18:38dnolenchoffstein: they aren't so bad in Lisps - you have macros to do the transformations
18:39dnolenchoffstein: core.logic is basically a hyped up list monad
18:40amalloyinteresting, TimMc. it looks like they're bandwidth-priced - i don't really see where they charge you for cpu or anything? seems like a weird hack to use them as a compute-farm
18:41alexbaranoskyis there a simple way to find all fns vars ?
18:41TimMcamalloy: Bandwidth, storage, and number of sites. They looked into charging for CPU but I guess CPU is correlated enough with other factors that they just boost the other prices.
18:42alexbaranoskymeaning tell me all fns that have been def'd
18:42TimMcamalloy: I just like that pricing model in general. It incentivizes the provider to have good uptime and encourage the growth of their users' projects.
18:42amalloy&(doc ns-map) ; alexbaranosky
18:42lazybotjava.lang.SecurityException: You tripped the alarm! ns-map is bad!
18:42amalloyokay, i hate you too, lazybot
18:43technomancyalexbaranosky: (for [n (all-ns) [_ v] (ns-publics n) :when (and (bound? v) (fn? @v))] @v)
18:43amalloytechnomancy: probably v, not @v, at the end there
18:44technomancyamalloy: yep, misread the question
18:58TimMcclojurebot: monads |are| a hoax
18:58clojurebotRoger.
18:59cemerickTimMc: ouch!
18:59TimMcI'm convinced that they don't exist, and people just write about them to make other people confused. :-P
19:01TimMcHmm, does clojurebot's factoid module collapse plurals and singulars?
19:15technomancyweavejester: any further thoughts on representing migrations?
19:16weavejestertechnomancy: yeah, I think hiredman was correct when he suggested a map of functions would be most appropriate.
19:16technomancymaps are probably the most flexible. I think I like the aesthetics of multimethods a bit better just for how they lay out on the page, but that's probably not worth it.
19:16technomancyconsidering that could be addressed with a separate macro if desired
19:16weavejesterYeah, the advantage with maps though, is that you can create a map with just an :up and a :down, and add an :id later.
19:17weavejesterSince migrations need to have some sort of unique id to be stored in the database.
19:17technomancywould ordering be based upon the ID?
19:17weavejesterNo; at least not in Ragtime. I order based on creation order.
19:17weavejesterWhich does mean I need a (reset-migrations!) at the top of the namespace file...
19:18weavejesterBut overall it reads better
19:18weavejesterThe ID is so that the migrations can be stored in the database so you know what has been applied.
19:19weavejesterI thought about adding a SHA1 to the ID based on the content of the migration...
19:19weavejesterSo that if you change the migration definition, it registers the change, but that might be a bit too clever.
19:19technomancyfunctions are too opaque to pull that off well, I think
19:20weavejesterYeah. At first I was thinking that there would be no abstraction - the :up and :down would be defined in one place, so one could use a macro to capture the form.
19:20weavejesterYou could still do that really...
19:21weavejesteri.e. (defmigration foo {:up #(blah) :down #(blah)})
19:21weavejesterThe defmigration macro would be able to pr-str the form and SHA1 hash it.
19:21technomancytrue
19:21technomancyjust a question of what you would do with it
19:22technomancyif a migration changed, you'd want to reverse the old form before re-running the new up
19:22technomancybut by that point it's too late
19:22weavejesterWell, Ragtime has different strategies of applying migrations.
19:22technomancyunless you stored the down action in the DB, which is crazy =)
19:22weavejesterFor production, if there's a conflict (i.e. the database has A B C, but the migration file has A B D), it'll raise an error
19:23weavejesterBut for development, you could say (:down C) (:up D) in such a situation.
19:23technomancyisn't C gone by that point?
19:23weavejesterThat assumes you know C, of course, but if you were fiddling around and still had C in memory...
19:24weavejesterI was kinda thinking that you could write a migration, and then maybe it has a small spelling mistake or something...
19:24weavejesterIf the ID had part of a SHA1 hash, then your spelling correction would be identified, and the old migration could be pulled down, and the new one put up.
19:25weavejesterI was playing around with the idea of a migration middleware, so migrations would be applied automatically.
19:25technomancyyeah, I'm just thinking relying on stuff that's in memory but not on disk seems a bit sketchy
19:25weavejesterIn development only, of course :)
19:26technomancyit could be made to work, but it just goes against what you'd expect
19:26weavejesterTrue, but if you're working in development, you can always reset the database completely if you can't find the migration.
19:26weavejesterYou'd need some way of adding test data back in though...
19:26weavejesterMaybe it's all a little too... automated.
19:28weavejesterBut I kinda think that maybe local development databases should be looked upon as being very temporary.
19:28weavejesterAnd if you want any test data, you should put that in a file so you can reload it.
19:28technomancyyeah, that makes me think it's better to make it easy to nuke and pave rather than try to undo stuff from stuff that's hanging around in-memory
19:29weavejesterTrue... But nuke and pave might take too long if it was constantly happening.
19:29weavejesterI mean, you change a field from "emal" to "email" and suddenly a hundred migrations need to be reapplied from scratch.
19:30technomancytrue
19:30weavejesterI dunno - I'd have to see how this works in practise...
19:30technomancybut you don't need to hash the content in that case, just reverse the one you notice the typo on
19:31weavejesterYeah, but the hash means it happens without you doing anything special.
19:31weavejesterYou save the file, and the migration is magically corrected.
19:31weavejesterMaybe a little too much magic? But I kinda want to experiment :)
19:31technomancyyeah, I think there's room for that
19:32technomancybut we should figure out the basics first
19:32technomancythe advantage of one-migration-per-file is that you can get lein to spit it out in such a way that the migration reflects the timestamp at which it was created, which basically solves the ordering problem
19:33weavejesterThe ordering problem can also be solved by adding a (reset-migrations!) at the top of the migration file that clears an atom, and each defmigration adds to it.
19:33technomancyi we support (def my-migration {:up #(...) :down #(...)}) then we can't offer a way to impose ordering on it; order has to either be a key in the map or supplied when you perform the migration
19:34weavejesterIt would just be the order in which it was evaluated.
19:34technomancysure, that works if you want to introduce a macro
19:35technomancyit would be nice to support both
19:35weavejesterWell, one could easily translate a namespace into a map.
19:36technomancywhat if rather than storing the migration in an atom, defmigration just expanded to (def my-migration {:up #(...) :down #(...) :order 12}) where :order was determined from an atom getting inc'd?
19:36technomancyrather less stateful that way
19:36weavejesterHmm...
19:36jacortinasthat sounds nice, and would allow manual reordering
19:37technomancyyeah, you could slap on a manual (def my-last-migration {:order 999999 [...]})
19:37weavejesterYeah. Would that solve the reloading problem as well? Or would you still need to reset the atom when the file is reloaded?
19:37technomancyI think as long as you didn't care about the value of the :order number, you could reload all you want
19:37technomancyit would just keep incrementing, modulo integer overflow =)
19:38weavejester... yeah, it would.
19:38weavejesterThat's actually a much better solution.
19:38weavejesterI really should hang out here more often :)
19:38technomancyIRC is the best!
19:39weavejesterOn another note, does anyone know if there's an alternative to autodoc aside from margarilla (or whatever the exact name is :) ?
19:41weavejesterI'm currently building one, and I don't *think* I'm reinventing the wheel, but maybe someone else has solve the problem of API doc generation.
19:42jacortinaswhat does "-?>" do?
19:43technomancyjacortinas: it's like -> but short-circuits if there's a nil
19:43weavejesterIt's like -> but it short-
19:43weavejesterYeah, what he said :)
19:43jacortinasahh ok
19:43jacortinasthat's awesome
19:50technomancyweavejester: getting my privmsg?
19:51amalloyheh. margarilla. excellent
19:51weavejestertechnomancy: Sorry, didn't notice
19:56Raynesweavejester: There is story, a recent addition.
19:56Raynesweavejester: http://jedahu.github.com/story/
19:56RaynesI'm a fan of this one.
19:58weavejesterRaynes: Ah I see. It's not quite what I was looking for though. It's more a literate programming thing than classic API docs ala Javadoc or YARD.
20:06alexbaranoskytechnomancy, amalloy - thanks for ns-related tips... my internet died back when I asked so I hope I didn't miss anything useful
20:07alexbaranoskyI got the for expression from technomancy and the ns-map from amalloy
20:08weavejesterBye all
20:09amalloyalexbaranosky: lazybot.org/logs/#clojure
20:09amalloy(i don't think you missed anything, but you can find out from there)
20:11alexbaranoskythanks
20:21TimMcalexbaranosky: Whoa, stuff has been happening in seqs-and-colls!
20:22TimMchaha, it's all after midnight last night
20:22alexbaranoskyTimMc: I made a couple small commits
20:22alexbaranoskymostly silly stuff
20:26TimMcalexbaranosky: Any idea about how to represent "logical true" (and false) with better icons?
20:27alexbaranoskyTImMc: my thoughts are along the idea of not thinking in terms of icons, but trying to step back and feel out the page from a UX perspective
20:27TimMcI was hoping I'd come up with something better if I slept on it, but the best I can do so far is that idealized power on/off icon: http://static3.depositphotos.com/1000244/205/v/450/dep_2055290-Power-yellow-circle-icon.jpg
20:27alexbaranoskyI think the visual representation is a matter of UX, and, that could come later
20:28TimMcspecifically http://us.123rf.com/400wm/400/400/ghoststone/ghoststone1005/ghoststone100500027/7028115-close-up-of-isolated-red-power-on--off-switch.jpg
20:28TimMcThere needs to be hella more text, too.
20:28alexbaranoskyCould put a bomb on the ones that blew up, like a Nintendo type of bomb
20:28TimMchaha, I like it
20:28alexbaranoskyand a thumbs down for thefalses
20:28TimMcMaking a TODO file...
20:29alexbaranoskythumbs up for truths
20:29alexbaranoskyTODO file's a great idea, I was looking for it last night
20:29TimMcalexbaranosky: I was talking about it with tmciver today and I think we need to avoid any icons that have "good/bad" connotations.
20:30alexbaranoskyyour reasoning?
20:33TimMcWell, I don't want the viewer to see the red X on seq / nil and think "Oh, I can't call (seq nil)"
20:33TimMc...which was Rob's first impression.
20:33TimMcI think it works OK for the predicates though, e.g. counted? and associative?.
20:35TimMcMore user-testing is required. :-)
20:35alexbaranoskyI still wonder if the simplest thing isn't just like "T" with a green background, "F" with a red background, "nil" with a some-color background, and Bomb with a xyz-color background
20:36alexbaranoskyTimMc: I have Clojure question
20:36TimMcshoot
20:36alexbaranoskyI have a symbol, and want to say that it does not represent any fns that are in scope
20:37alexbaranoskyI can access stuf like such: (for [n (all-ns) [_ v] (ns-publics n) :when (and (bound? v) (fn? @v))] v)
20:38tmciverTimMc: alexbaranosky: thumbs up for truth, thumbs down for false and middle finger for "can't do that!"
20:38alexbaranoskybut am having some friction going between var and symbol to compare
20:38alexbaranoskyhehe
20:38TimMctmciver: NICE.
20:39alexbaranoskytmciver, its hard to think of pictures for true and false because they're so abstract
20:39TimMcWorse, it's *logical* true and false. :-/
20:39TimMcalexbaranosky: And that snippet doesn't work?
20:40alexbaranoskywhat do you all think of a triple quote reader macro for Clojure ?
20:40amalloyalexbaranosky: well, all-ns hits all namespaces, not just those that are "in scope"
20:40tmciverTimMc: I really think simply printing True and False would be fine too.
20:41amalloyif you only want to refer to ones that are in scope, just call (resolve sym) - if you get back nil, it's not in scope
20:42TimMcalexbaranosky: Remember that Clojure doesn't have reified environments, so you won't get locals.
20:42alexbaranoskyI don't want local, so I'm good
20:42alexbaranosky:)
20:43alexbaranoskyhowever, I am not sure how to compare a symbol with a var
20:43alexbaranosky&(var string?)
20:43lazybot⇒ #'clojure.core/string?
20:43TimMc,(name '#+)
20:43clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: +>
20:43alexbaranosky&(str (var string?))
20:43lazybot⇒ "#'clojure.core/string?"
20:43TimMchaha, whoops
20:44TimMc(.sym #'+) -> '+
20:44alexbaranosky&(= (str "#'" "string?") (str (var string?)))
20:44lazybot⇒ false
20:45alexbaranoskyTimMc, why is that last one false?
20:45alexbaranosky&(= "#'string?" (str (var string?)))
20:45lazybot⇒ false
20:45amalloyalexbaranosky: i still don't see why you want to compare symbols to vars at all
20:45alexbaranosky&(= "string?" (str (var string?)))
20:45lazybot⇒ false
20:45TimMc&(= "foobarbaz" (str "foo" "barbaz"))
20:45lazybot⇒ true
20:45TimMchrmf
20:46amalloy&(let [in-scope? (fn [name] (not (resolve name)))] (map in-scope? '[inc dec foo]))
20:46lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
20:46amalloy,(let [in-scope? (fn [name] (not (resolve name)))] (map in-scope? '[inc dec foo]))
20:46clojurebot(false false true)
20:46amalloyoh. heh, got it upside-down, but you get the idea
20:46alexbaranoskyamalloy, you da man
20:46alexbaranoskyamalloy, you're a Clojure machine
20:48alexbaranoskyamalloy, doing the binding map substituions for midje tabular tests will infinitely loop in some spots, because it was thinking of fns used as table data as being table variables
20:49alexbaranoskyat this point I think I'm just figuring it out for fun, because '?'-prefixed variables might in fact just be more readable than non '?'-prefix vars
20:55TimMcalexbaranosky: Mind if I hammer on the deftemplate thingy, or do you have WIP on that?
20:55alexbaranoskyTimMc, go for it, I have nothing in progress. I gave up on it
20:57TimMcHa, OK. I'll beat my head against it for a bit.
20:59TimMc&(counted (seq "foo"))
20:59lazybotjava.lang.RuntimeException: Unable to resolve symbol: counted in this context
20:59TimMc&(counted? (seq "foo"))
20:59lazybot⇒ true
20:59TimMc&(counted? (seq [1 2 3]))
20:59lazybot⇒ false
20:59TimMcwelp
21:13cemerick2 /join #clojure-casual
21:13cemerick2good grief
21:15TimMc?
21:21devncemerick: is it possible to get fortress?
21:24Raynescemerick: lazybot is in #clojure-casual still?
21:25RaynesIt's more appropriate to /query lazybot
21:25RaynesHe responds there the same as here.
21:26cemerickRaynes: apparently
21:28cemerickdevn: sure, why?
21:29cemerick(don't be fooled by the calamatous state of java.net)
21:29cemerickcalamitous*, apparently
21:52TimMcDoes paredit give me a way to kill the entire next form?
21:52TimMc(as opposed to the first "word" in that form)
22:10devncemerick: I was just curious. I've been toying with APL, at this point, why *not* look at fortress? :)
22:11devnTimMc: I am pretty sure it does, but my silly way is to have my point in some whitespace previous to the sexp and then I Mark, M-C-f, C-w
22:11technomancyTimMc: C-M-k, but it's stock emacs, not paredit
22:11devnd'oh
22:11cemerickdevn: dude, you're outta control ;-)
22:11devnI knew technomancy would chime in
22:11devnblasted Phil always besting me in emacs
22:12TimMcdevn: Yeah, that's what I was doing.
22:12TimMctechnomancy: Ah, thanks!
22:12devntechnomancy: yeah, i might avoid carpal tunnel a few thousand keystrokes earlier now
22:12devntechnomancy: thank you
22:14devntechnomancy: i heard through the grapevine you heroku guys were working on specifying how your app should be built, any word on that?
22:15TimMc$findarg map % [true false 5 nil] [true true false false]
22:15lazybot[]
22:31reiddraperis __meta the best way to deal with metadata for objects created with deftype?
22:32TimMcalexbaranosky: Check it out, result values are in the title text.
22:33alexbaranoskyTimMc: deployed it?
22:33technomancydevn: not sure what you mean by that
22:33alexbaranoskysweet, I see it
22:33technomancyI'm working on an article about how to set up background workers if that's what you mean
22:34TimMcneed to commit, tho
22:35TimMcOK, done.
22:36technomancydevn: oh, you mean http://12factor.net
22:36technomancyyeah, that's good stuff. definitely worth reading.
22:37TimMcalexbaranosky: Oh, and add your name (and Rob and Tim too) to the README copyright section.
22:37TimMcif you don't mind!
22:38tmciverTimMc: no need to add me; I didn't do anything!
22:38tmciverTimMc: the change you just made isn't deployed yet?
22:43tmciverTimMc: Nevermind, got it.
22:44hartohaving a little trouble with interop here - I'm trying to pass nil to an overloaded constructor
22:44tmciverTimMc: Looks good.
22:44hartoe.g. (TreeModelEvent. source ^TreePath nil) doesn't work
22:45hartoI get "Metadata can only be applied to IMetas" - any ideas?
22:48hartoOK, it looks like this works:
22:49harto(let [dummy nil] (TreeModelEvent. source ^TreePath dummy))
22:49hartois that the best way to do it?
22:49alexbaranoskyharto: funky... no idea the best way
22:50cemerickharto: yeah, you can't hint nil
22:51cemerickI think I've only ever run into that circumstance (needing to pass nil to an overloaded ctor/method) once before.
22:52hartocool
22:52cemerickharto: I think I did something like ^TypeHint (or nil) — any expression that returns nil will do.
22:54hartoah, I see
22:54hartothanks
23:20hhutchin clojurescript, if I require [goog.dom.foo :as goog-foo] and i want to do the equivalent of (goog.dom.foo.) using my clojure namespace, how would I do that? (goog-foo.) (new goog-foo) .. (goog-foo/.) actually generates "new goog.dom.foo.()"