#clojure logs

2011-12-04

00:33zakwilsonI have a Clojure project in a git repository and a Javascript project in another. The Clojure project uses the Javascript project. What's the cleanest way to make it easy for someone to get both?
00:38noto3zakwilson, a git submodule, I would say
00:39zakwilsonnoto3: I was hoping something like that existed, but I did not know what to call it.
00:39notostracagit submodules are pretty nice, they default to being a source checkout of another repo IIRC but you can have the submodule be a branch with some fixed API
00:40notostracaI am still learning git, and I have had lots of trouble getting it to work well with eclipse
00:45zakwilsonI do not use Eclipse, and just use git from the command line.
00:52notostracazakwilson, I think you are going to do better than I have then
00:52zakwilsonPerhaps.
00:52notostracaLeiningen plays nice with Git IIRC, Eclipse projects do not
00:53notostraca.classpath is needed for all eclipse projects, but it can easily containt machine-specific absolute paths
00:53notostraca*contain
00:54notostracaand when those get in git, they screw up the eclipse .classpath for anyone else who tries to open the file in eclipse...
00:54notostracadefinitely stick to leiningen, IMHO
00:57TeXnomancychecking in the .classpath file is just crazy
00:57TeXnomancyI guess the default "lein new" skeleton should put that in .gitignore
01:10zakwilsonhttps://github.com/zakwilson/timeline/blob/master/src/timeline/views/main.clj <-- these routes, adapted from a Compojure app are throwing an exception in Noir. I'm very new to Noir and the docs are still a little light on examples.
01:10zakwilsonThe ones at the end for javascript/css/widget
01:15michaelr525hey
01:17y3didoes Hickey ever chill in this irc chat?
01:20zakwilsonHe used to. I think people started demanding too much of his attention.
01:21y3dimm, makes sense
01:22zakwilsonThough I still use it as an example of why OSS has better support than expensive commercial stuff. Rich optimized a bit of code for me in this channel. Just try calling up Microsoft and asking to have Anders Hejlsberg troubleshoot a performance problem with your C# code.
01:27y3diyea, I really admire the open source movement in general
01:27y3dibut that scenario might be because clojure is a younger and less popular language?
01:28y3dishow theres less demand for personal attention from the language creator
01:29zakwilsonWell, yes. I wouldn't likely get that result now. Still, I find that genuine experts tend to be quite accessable when dealing with OSS languages and libraries.
01:53y3diim watching his lecture on simple made easy
01:54zakwilsonThat's a classic. Great stuff.
01:54zakwilsonA modern classic. anyway.
02:06RaynesI nearly made an inappropriate joke about what zakwilson just said and Rich and his toilet, but decided against it. I'm currently accepting thank you emails.
02:06zakwilsonI'm not sure I get the reference.
02:07RaynesIf I elaborated I would be making a liar out of myself.
02:07zakwilsonYou must now make the inappropriate joke anyway because you mentioned it.
02:14y3dihe only mentioned it so that he could have the chance to make the joke xD
02:15y3diok so i feel like this is an elementary concept but i don't know it
02:15y3diwhats the meaning of 'state' in programming
02:15y3diwhy is c++ stateFUL and clojure stateLEss
02:21zakwilsonState is information stored in memory that can be changed. Clojure isn't stateless. It just provides managed access to state instead of direct, uncontrolled access.
02:22mindbender1zakwilson: I don't think there is any access to state that's unmanaged
02:23mindbender1zakwilson: do you mean a different approach
02:24zakwilsonI mean Clojure provides mechanisms controlling when and how changes to state are made.
02:25mindbender1of course it does
02:25y3diok, hmm thats what I assumed state was, but the way people discuss it makes it seem more complex
02:25y3diwhy does it come up alot in conversations about programming languages
02:25y3didont yu need state in order to have a useful programming language?
02:26zakwilsonYes, just as you need access to memory. Manually managing it however can be extra work for the programmer and error-prone.
02:27mindbender1y3di: http://en.wikipedia.org/wiki/State_(computer_science)
02:30y3diso ive taken courses like foundations of computer science and theory of computation which go into the more abstract theoretical aspects of CS
02:31y3diand learned stuff like turing machines and fsms
02:31y3dibut ive never been able to make the connection between that kind of stuff and the actual programming aspect of CS
02:32mindbender1y3di: pick a language and try out some basic tutorials on that language
02:34y3dinah, ive done quite a bit of actual programming its just that i cant see how things like automata theory relate to the programming
02:34y3dimaybe its because i've been generally using imperative languages and that somewhat obscures those more theoretical concepts? idk
02:35y3dihopefully learning clojure makes me think of programming differently and it might be easier to make those connections
02:36mindbender1y3di: on wikipedia: Automata play a major role in theory of computation, compiler design and parsing.
02:37mindbender1unless you want to build a compiler I suspect
02:38mindbender1otherwise focus more on real problems you can solve with a language
02:39y3diyou're right, theres no real need to overcomplicate things
02:41mindbender1you're welcome
03:30changbeerwhy are some functions suffixed with *
03:31changbeersuch as a few in sql.internal.clj
03:34changbeertaking a look at https://github.com/richhickey/clojure-contrib/blob/40b960bba41ba02811ef0e2c632d721eb199649f/src/main/clojure/clojure/contrib/sql/internal.clj
03:34changbeerpresumably Im expected to define the symbol *db*
03:35changbeerhow does this work in clojure 1.3 since that lacks the meta-data ^:dynamic so i cant do that in a binding?
03:36hiredmanfirst richhickey/clojure and richhickey/clojure-contrib are not the correct repos
03:37hiredmanyou want clojure/clojure and clojure/clojure-contrib
03:37hiredmansecond contrib as a single unified package is dead
03:37hiredmanyou want clojure/java.jdbc
03:42changbeerwoohoo make sense now (def ^{:dynamic true} *db* {:connection nil :level 0}) but i see i dont do explicitly i use with-connection that sets the dynamic ninding, thnaks
03:57changbeerlooking at https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj and then the definition for the ns macro http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ns
03:58changbeeris there any reason he didnt use the optional docstring of the macro, rather than directly using the metadata?
05:08triyoAny sql korma users here? I have a number of queries that return only one record/row. Is there a way to just `get` a single map result instead of a vector with single map in it? Or is (-> (select...) ... first) the way to go?
05:13zakwilsonI'm a new Korma user, and that's what I've been doing.
05:13zakwilsonKorma tries to map pretty directly to SQL, and SQL doesn't generally return non-collections.
05:14zakwilsontriyo: idbknox is here often. I'm hoping he'll drop by so I can find out what happened to the examples on the Noir site.
05:15triyooh ok, thanks
05:15triyoI thought it might be because it is an DSL after all
05:16triyothat it would map on SQL and always return a sequence / vector
05:16triyoTo see those examples would be great..
05:19triyoI must say, select* for composing SQL queries is truly awesome
05:20zakwilsonLooks like the examples are all gists and perhaps github changed something.
05:20zakwilsonhttps://gist.github.com/ibdknox <-- if you want to dig through that...
05:20zakwilsonAnd yeah, composable SQL is great. SQL... isn't great at that.
05:20zakwilsonThere are ways to make it a little better, of course. That's what views are about, as I understand it.
05:21triyothanks for the link
05:34triyozakwilson: do you know if there is any function like update-in that can apply a function to a list of keys values? So I have a korma query that returns a map with some values that are decimals. So I wish to say something like (update-in mymap [:total1 :total2] round-places 2).
05:35triyoupdate-in can apply to only one key and not multiple like I have in my example above [:total1 :total2 ...]
05:36zakwilsonOh... I wrote some map utilities including exactly what you want.
05:36zakwilsonhttps://github.com/zakwilson/zutil-clj/blob/master/src/zutil/map.clj <-- see map-keys
05:36triyoHehe, nice. Is it a macro that just expands in to a (assoc m k v k v k v) :)
05:36triyothanks for the link I'll have a quick look
05:37zakwilsonIt is not, but maybe it should be.
05:37zakwilsonDon't go too hard on this code. It was really not designed for public consumption.
05:37triyoI think it just might perform a bit better. ;-)
05:38triyoNo at all, thank you for sharing; no judging :)
05:38zakwilsonI evidently didn't even decide what license to use. It says EPL in one place and BSD in another.
05:39zakwilsonYeah, a macro would likely be more performant.
05:39zakwilsonIntersection and difference are fast though.
05:41zakwilsonGood idea with the macro. I don't know why I didn't think of that. Probably because I was half asleep and in a hurry when I wrote it.
05:42triyoThere is one thing I really love in Haskell thanks to its strongly typed nature I guess and that is, Hoogle! :) You can search by what you want your type signature to look like and it will match patterns of functions signatures in the Hoggle DB .
05:42licenserWasn't rule one of Macros: don't use Macros?
05:43triyolicenser: well if it expands in to something really `simple` and that will perform better in this case, then I say macro it is.
05:43licensertriyo: Raynes has written a function that is a bit like that I think it was called what-fn
05:43zakwilsonlicenser: last I checked, it was more like "only use macros when you need to".
05:43licenserwell you still loose composability
05:43licenserzakwilson: close to it ;) also you don't need to it works fine as function
05:44rabidsnailIs there a cleaner way to test if something is a set than (= (class thing) clojure.lang.PersistentHashSet) ?
05:44zakwilsonYeah. I'm not sure if it's needed here. I should see what happens when I use it on huge maps though.
05:44triyolicenser: you don't loose composability, check: #(mymacro %) ;-)
05:44licenserhackery
05:44zakwilson,(set? #{:a :b :c})
05:44clojurebottrue
05:44rabidsnailaha
05:45rabidsnailcool
05:45zakwilsonSimilar functions exist for most common types
05:45zakwilson,(string? 'not-a-string)
05:45clojurebotfalse
05:46licenserI think the fastest way to do this would be something entirely different
05:52licenserhttps://gist.github.com/1429882 <- for example
05:56licenserzakwilson: as a hint for map map
05:56licenser,(map identity {1 1 2 2 })
05:56clojurebot([1 1] [2 2])
05:56licenseryou can simply destruct the kv instead of calling (key) and (value)
05:58zakwilsonI'm going to try to parse that when I'm awake. All I'm able to register right now is that it's not difficult to understand.
05:58zakwilsonOr should not be. I'm trying to get something online for a friend before I nap
06:06raekrabidsnail: yes: 'set?'
09:58fliebelHas anyone seen something like partition in Python?
10:14lucianfliebel: http://code.activestate.com/recipes/576785-partition-an-iterable-into-n-lists/
10:15fliebellucian: Someone in #python came up with this: http://codepad.org/LlREJRX0
10:15lucianyeah, that's the straightforward comprehension
10:15lucianwell, mostly
10:16lucianit's O(n) anyway
11:01ambrosebs,(meta ^{:a :b} 'a)
11:01clojurebotnil
11:01ambrosebswhy is there no metadata here?
11:12ambrosebs,(meta (with-meta 'a {:a :b}))
11:12clojurebot{:a :b}
11:12ambrosebswhat the difference between those two?
11:14raekambrosebs: ^{:a :b} 'a = ^{:a :b} (quote a)
11:14ambrosebsraek: ah
11:15raekambrosebs: (quote ^{:a :b} a) = ' ^{:a :b} a = a quoted symbol that has metadata (the metadata is put the by the reader at read time)
11:16ambrosebsraek: oh I see
11:16raekambrosebs: (with-meta 'a {:a :b}) = make a new symbol with the metadata at runtime
11:16raekso ^{} is for annotating code and with-meta is a function you use at runtime
11:17ambrosebs^{} metadata sticks around at runtime, right?
11:17ambrosebsas in, it doesn't disappear
11:19ambrosebs,((fn [^{:a :b} a] (meta a)) 'param)
11:19clojurebotnil
11:19ambrosebswhy don't I get {:a :b} there too?
11:20raekambrosebs: just because the datastructures that make up the code has metadata it doesn't meant that something at runtime will have that metadata too
11:22ambrosebsraek: hmm, yes that makes sense
11:22raekif I put metadata on the fn symbol here, where should that "end up": (^{:a :b} fn [...] ...)
11:23ambrosebsraek: I don't know :)
11:28ambrosebsI'm exploring this because I want to add static type annotations to forms, and I'm not sure where is the best place to extract/act on them
11:28raekmetadata on pieces of code can be useful. the compiler looks for type hints, but you can write macros that looks for any metadata you like and emit different code depending on the metadata
11:28ambrosebs:)
11:28raekmetadata on values have other uses
11:29raekand because code = data, these two categories happens to be the same
11:29raekambrosebs: if you want to do checks statically (i.e. at compile time) you need to do them in a macro
11:32raek(type-check (fn [^String s, ^int i] (+ s i)))
11:33raekhere, type-check could be a macro that walks through some code and returns it unchanged if it passes the type check and throws an exception othwerwise
11:34raektype-check has access to the {:tag String} metadata of the s symbol
11:35raekafter the compiler is done with the unmodified (fn ...) form, the type hint metadata is not stored anywhere
11:36ambrosebsraek: right, and it shouldn't be needed after compilation anyway
11:36ambrosebsI think I've missed that point
11:39ambrosebsin my case, if they persist into runtime, they will be in the form of a contract/precondition
11:39ambrosebsotherwise they are useless
11:41raekyeah, you could say that type hints persist into runtime too, since they affect what the interop calls become
11:41ambrosebsright
11:44ambrosebsraek: thanks, I've always struggled with metadata
11:44raeknp :)
11:51triyoDoes anyone have an example or experience in placing conditions on SQL Korma macros such as `aggegate`?
12:24rabidsnailThere's no regex? function in the standard lib?
12:24rabidsnailIt seems like there's a test for every other type that has a syntax literal
12:24rabidsnailliteral syntax
12:29weavejesterrabidsnail: I don't think there is. There's none for namespace? either
12:31TimMc&(instance? java.util.regex.Pattern #"")
12:31lazybot⇒ true
12:32TimMc*shrug*
12:34rabidsnailOf course that works, and in my code I'll just define my own regex? function that does exactly that. I was just noting that it seemed inconsistent that the function isn't built in.
12:35RaynesI think it just defines them for the most common ones.
12:36RaynesIf it had a function for every test, core.clj would be a couple thousand lines longer.
12:36rabidsnailEven if it only had tests for the types that have special syntax?
12:37TimMcrabidsnail: I'm pretty sure that's not the only omission. Is there also a test for 15N or 15M?
12:38TimMc(Not to say there shouldn't be...)
12:38rabidsnailthere's a test for number?
12:40rabidsnailso I guess, to be more specific, for every literal syntax there should be at least one test that checks for a type between its type and Object
12:41rabidsnailincluding its type
12:42rabidsnailnot the end of the world, though. It just means that I'm going to be defining regex? in half of my projects.
12:43TimMcrabidsnail: You have a number of DSLs where you need to distinguish regexes from other values?
12:44rabidsnailtoday I have one (I haven't used clojure in a while) but in python and javascript I find myself passing regex objects around relatively often
12:44TimMcyep
13:16triyoI find it quite cumbersome to work with macros and conditional logic
13:18triyoSay for instance, in great library such as sql Korma, you have an aggregate macro .... that goes something like this: (aggregate query (sum :name) :fname)
13:18triyohow do you make the `sum` bit generic in order to be able to switch it to `max` for example
13:18clojurebotchouser: it's tougher with guards (arbitrary tests), where grouping is less clear. I need to work that out still.
13:19triyoI can have `if` conditions around (aggregate ...)
13:20triyobut I'd like to have a condition around `sum` bit, which is a predicate but at macro level so I can't just stick a condition around the aggregate predicate such as sum or max
14:04TimMcclojurebot seems to preferentially wrongly pick up messages to chouser as factoids.
14:20zmanjiHow does one access my functions in my namespace using lein repl?
14:22tremolodoes anyone know if I can force an Emacs 24 theme to treat javadoc blocks as regular comments?
14:23tremolothey seem to be a regular case, and I keep running into otherwise nice color themes that don't handle them properly. Can't find any documentation on this
14:35TimMcWow, impatient little buggers.
14:46TimMcUgh, I can't get rid of clojurebot's ~namespaces factoid (to replace it with a cleaned-up version.)
14:46TimMcI've tried putting || around is and are but nothing has worked.
15:19fbru02Hi all ! Is there a predicate to test if a sth is a "form" i.e. a clojure.lang.PersistentList ? ?
15:19fbru02i know dumb question :)
15:23raekfbru02: you probably want 'seq?'
15:23raek,(read-string "'foo")
15:23clojurebot(quote foo)
15:23raek,(class 'foo)
15:23clojurebotclojure.lang.Symbol
15:24raek,(class ''foo)
15:24clojurebotclojure.lang.PersistentList
15:24raekhrm
15:25raekI was sure that the (quote ...) thingy was a clojure.lang.Cons and not a list...
15:25fbru02raek: thought that too
15:25raekanyway: they are both seqs so 'seq?' works for both
15:26TimMcfbru02: Writing a macro?
15:26fbru02raek: yeah, will try with that and let you know, seems kinda obvious now in retrospective
15:26raek,(class (read-string "'foo"))
15:26clojurebotclojure.lang.Cons
15:26fbru02TimMc: actually not more like a parser thingy
15:26raek,(map (comp seq? read-string) ["'foo" "(quote foo)"])
15:26clojurebot(true true)
15:26TimMcfbru02: Well, you probably want list?, vector?, and map? more than seq?.
15:27fbru02TimMc: raek thank you guys !!
15:27TimMcraek, fbru02: seq? is for the sequence abstraction, which *happens* to be implemented with lists.
15:28TimMc(usually)
15:28TimMc&(map (comp list? read-string) ["'foo" "(quote foo)"])
15:28lazybot⇒ (false true)
15:28TimMcHmm, what's going on there?
15:34TimMcWhy would the reader mix sequences in like that?
15:34gfredericks&(map (comp type read-string) ["'foo" "(quote foo)"])
15:34lazybot⇒ (clojure.lang.Cons clojure.lang.PersistentList)
15:36gfredericksmaybe it was incidental more than intentional
15:36gfredericksdoes seem inconsistent though :/
15:37TimMcMakes inspection trickier.
15:37gfredericksexactly
15:40TimMc&(type (list 1 2))
15:40lazybot⇒ clojure.lang.PersistentList
15:40TimMc&(type (list* 1 (2)))
15:40lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
15:40TimMc&(type (list* 1 '(2)))
15:40lazybot⇒ clojure.lang.Cons
15:40TimMcAha.
15:41TimMcNow *that* seems wrong right there.
15:41TimMc&(list? (list* 1 ()))
15:41lazybot⇒ false
15:43TimMc&(list? (clojure.lang.RT/list 1))
15:43lazybot⇒ true
15:43TimMc&(list? (clojure.lang.RT/list 1 2))
15:43lazybot⇒ false
15:46TimMclist* |is| <reply>list* doesn't actually make a `list?`
15:46TimMcclojurebot: list* |is| <reply>list* doesn't actually make a `list?`
15:46clojurebotOk.
15:51gfredericksTimMc: of course not, it makes a list*!
15:53tmciverTimMc: Hey. Can you tell me the difference between these destructuring forms: (fn [a b & more]...) and (fn [a b & [more]]...)
15:54TimMctmciver: Yeah, I had lazybot $mail you about it.
15:54tmciver&((fn [a b & more] [a b more]) 1 2 3 4)
15:54lazybot⇒ [1 2 (3 4)]
15:54y3difrom an abstract stand point, is recursion more like looping or parallel computation(map, reduce)?
15:54tmciver&((fn [a b & more] [a b [more]]) 1 2 3 4)
15:54lazybot⇒ [1 2 [(3 4)]]
15:54tmciverTimMc: thanks
15:55gfredericksy3di: looping, if I understand you correctly
15:55TimMcy3di: neither.
15:56tmciverTimMc: so, & [more] just takes the first element when more is a collection?
15:56tmciver&((fn [a b & more] [a b [more]]) 1 2 [3 4])
15:56lazybot⇒ [1 2 [([3 4])]]
15:56tmciverwoops
15:56y3diim watching rich hickeys talk Are we there yet, and he talks about how looping is bad because its essentially non concurrent, where as map/reduce is better because it is concurrent
15:56TimMcy3di: Well, it has absolutely nothing in common with parallel computing, and looping is a special case of recursion (in an abstract sense.)
15:56tmciver&((fn [a b & [more]] [a b more]) 1 2 [3 4])
15:56lazybot⇒ [1 2 [3 4]]
15:56y3diand i was curious with how recursion fit in that
15:57TimMctmciver: Here's a more instructive example:
15:57y3diok so its more similar to looping then
15:57y3didoes that mean recursion should also be minimizes? when trying to write concurrent programs?
15:57gfredericksy3di: you can use it to do loopy things, and you can also use it to do other things
15:57y3diminimized*
15:58TimMc&((fn [a b & [c d e f]] [a b c d e f]) 1 2 3 4 5 6 7 8 9)
15:58lazybot⇒ [1 2 3 4 5 6]
15:58TimMcy3di: Recursion is a very powerful tool that can do many, many things. Looping is just one small (but common) translation.
15:59gfredericks&((fn [a & [b & [c & [d & [e & [f]]]]]] [a b c d e f]) 1 2 3 4 5 6 7 8 9)
15:59lazybot⇒ [1 2 3 4 5 6]
16:00tmciverTimMc: gfredericks: Yeah, that's a bit clearer. Thanks.
16:00TimMcy3di: If you use a loop to do the same computation on a list of items, each computation being separate from the others, you are losing.
16:01TimMcy3di: However, if you can express it in a way that indicates to the compiler that the computations are independent, you might win.
16:01y3diwhich is why map/reduce is amazing right?
16:06Laers_UemLauetClojurebot, do you still hate me?
16:06Laers_UemLauet,(+)
16:06clojurebot0
16:06Laers_UemLauetAha
16:07Laers_UemLauetYour love I have once more regained, so merriful our future life shall be.
16:08Laers_UemLauet,(let [space " "] (append "I" space "worship" space "His" space "shadow"))
16:08clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: append in this context, compiling:(NO_SOURCE_PATH:0)>
16:08Laers_UemLauetOh wait
16:09Laers_UemLauetThat was concat right
16:09Laers_UemLauet,(let [space " "] (concat "I" space "worship" space "His" space "shadow"))
16:09clojurebot(\I \space \w \o \r ...)
16:09Laers_UemLauetWe're getting there
16:09Laers_UemLauet,(let [space " "] (apply string (concat "I" space "worship" space "His" space "shadow")))
16:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: string in this context, compiling:(NO_SOURCE_PATH:0)>
16:09Laers_UemLauet,(let [space " "] (apply str (concat "I" space "worship" space "His" space "shadow")))
16:09clojurebot"I worship His shadow"
16:09Laers_UemLauetAt last
16:10Laers_UemLauetYeeees, victory is mine
16:10Laers_UemLauetexactly as planned.
16:10Laers_UemLauetraek, nooo, my master plan
16:10Laers_UemLauetindeed you are an adversary worthy of my vast intellect
16:10Laers_UemLauethowever did you see through my disguise oh nemesis?
16:10Laers_UemLauetYour wits are indeed sharp as ever.
16:10TimMcThank god for /ignore.
16:11TimMcy3di: map/reduce is one approach to splitting concurrent computations across many machines.
16:19alexbaranosky_could someone please take a look at this gist and explain what I am misunderstanding about :when in for comprehensions? Thanks in advance: https://gist.github.com/1431309
16:25raekalexbaranosky_: what does the second for do instead of what it's supposed to?
16:25pyrtsaalexbaranosky_: Looks like the :when test should be within the brackets: (for [... :when test] ...)
16:25pyrtsaOh, it was. Sorry.
16:26alexbaranosky_raek, it is not filtering out the people... I'm getting people as wella s neighbors abck
16:27pyrtsaalexbaranosky_: Could it be there are people who are neighbors to each others too?
16:28alexbaranosky_YES!
16:28alexbaranosky_that's it
16:28alexbaranosky_thanks :)
16:28king-of-spainclojure is too good
16:28pyrtsaI live in a city, you know. ;)
16:28TimMchaha
16:28king-of-spainwhen my programs fail, i cant blame the language anymore :(
16:32alexbaranoskyking-of-spain, so true
17:05zakwilsonSomeone suggest an appropriate method of torturing the creator of java.util.Date to death.
17:09zakwilson,(java.util.Date. -62167219200000)
17:09clojurebot#<Date Fri Jan 02 16:00:00 PST 1>
17:09zakwilson,(java.util.Date. -72167219300000)
17:09clojurebot#<Date Tue Feb 14 22:11:40 PST 318>
17:18developernotesI've got swank-clojure running and I've connected with slime-connect, I've created foo.clj and entered arbitrary commands, when I C-x C-e the form gets evaluated but the output is in the repl. Is there a way to get it to just show the output below the evaluation point inside the file?
17:26moogatronicdevelopernotes: Try C-u C-x C-e maybe? This will put the output directly in your buffer.
17:27developernotesmoogatronic: thanks - that does it.
18:48TimMczakwilson: What am I supposed to see there?
18:48zakwilsonTimMc: the second one should, as far as I understand be BCE.
18:49TimMczakwilson: I see, the bit after the timezone is the year. I was wondering about that.
18:49zakwilson,(java.util.Date. 1)
18:49clojurebot#<Date Wed Dec 31 16:00:00 PST 1969>
18:53TimMczakwilson: Huh. Does Date not have a BC/AD indicator, or does it just not print it?
18:54zakwilsonTimMc: it gives the year as negative.
18:54TimMczakwilson: And prints it as positive?
18:55zakwilsonTimMc: No. If it gets the year right, it prints it as negative. The problem is that it doesn't seem to be consistent.
18:56zakwilsonI'm actually using java.sql.Date, not java.util.Date and I'm converting with clj-time. Ultimately, it's stored in Postgres. I managed to get it to work most of the time, but sometimes a wrong date still appears.
18:58TimMc,(java.util.Date. -61600000000000)
18:58clojurebot#<Date Thu Dec 23 16:53:20 PST 17>
18:58TimMc,(.getYear (java.util.Date. -61600000000000))
18:58clojurebot-1883
18:58TimMcHaha, what the actual fuck.
18:58zakwilson#<Timestamp 0045-03-17 00:00:00.0> is being converted to #<DateTime -0044-03-15T05:00:00.000Z>, which is actually the correct date stored in the database.
18:59zakwilson(ok, it's a java.sql.Timestamp, not a java.sql.Date, but the WTF is the same)
18:59TimMc&(+ -1883 17)
18:59lazybot⇒ -1866
19:00TimMc&(+ -1883 -17)
19:00lazybot⇒ -1900
19:00TimMcright
19:01zakwilsonI think somebody involved in this design was smoking crack.
19:04y3disay you're writing a random clojure library. If you define a macro in that library, does the macro get carried over to anything that uses that library?
19:04y3diare macros defined globally? (does this question even make sense)
19:06Raynesy3di: You can get at a macro in a namespace just like a function in that namespace.
19:06raekmacros belong to namespaces just like functions
19:06Raynesraek: Get your own question.
19:07y3diso if a library defines a macro in the global namespace, any code using that library has access to the macro?
19:07y3diso a library for example can overwrite the macro or into being w/e it wants
19:07y3di'or'*
19:08TimMczakwilson: I think Date should have been an abstract class with a factory, where you could ask for Dates with different levels of precision. E.g. a regular long-based Date, a BigInt Date (to milli precision), BigDecimal (for arbitrary precision), y/m/d[/h/i/s] for exact dates...
19:09raeky3di: there is no global namespace
19:10y3dioh ok
19:10raekif you define a macro or a function in your namespace foo.bar, other namespaces can use it
19:11raek(ns user (:require foo.bar)) ;; (foo.bar/the-macro ...)
19:11raek(ns user (:require [foo.bar :as f])) ;; (f/the-macro ...)
19:11y3dii see, i think i have to read up more on namespaces. I
19:11raek(ns user (:use [foo.bar :only [the-macro]])) ;; (the-macro ...)
19:11y3diI'm getting ahead of myself
19:12raeky3di: this is a great guide: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
19:12alexbaranoskyok, so I installed Emacs 24 on my machine with the start kit too -- could anyone point me to a resource for setting up a color theme in Emacs 24?
19:13zakwilsonTimMc: perhaps, but the more glaring problem is stuff like 1900-offset years, 0-offset months and eras being... at least quirky.
19:13y3diok cool, thanks raek
19:16Raynesalexbaranosky: Install the color theme package from ELPA first of all.
19:16Raynesalexbaranosky: Ping me once you've finished with that.
19:16RaynesTip: M-x package-list-packages
19:17TimMcalexbaranosky: put an "i" next to color-theme and then type "x", I think.
19:17RaynesYes.
19:20y3di,(drop 2 {:1 1 :2 2 :3 3 :4 4})
19:20clojurebot([:3 3] [:2 2])
19:21RaynesThat's a bit precarious.
19:21alexbaranoskyRaynes: how do I install a package from ELPA - I'm an utter EMacs noob, so your statement was not immediately clear to me
19:21RaynesMaps don't guarantI'd give him the command to install that specific package ee order.
19:21RaynesWhoa.
19:21TimMcy3di: maps are not sequential: http://www.brainonfire.net/files/seqs-and-colls/collection-properties-venn.png
19:21RaynesERC just exploded in my face.
19:21Raynesalexbaranosky: M-x package-list-packages
19:21alexbaranoskyy3di, if you were to use some form of ordered-map then you could get away with that though
19:21alexbaranoskyRaynes, thx
19:21Raynesalexbaranosky: 'M' is your meta key. Usually ALT.
19:21y3diword ok
19:22Raynesalexbaranosky: You should be greeted with a big ol' buffer full of packages. Look for the color theme package.
19:22y3diTimMc: useful diagram, thanks
19:22TimMcy3di: On the other hand, I think the same map is guaranteed to give the same (arbitrary) ordering every time.
19:23Raynesalexbaranosky: After that, you'll want to place the caret (the little blinky thingy that spits out text) on the gap to the left of the package's name and type 'i'. An 'i' should pop up beside the package, in which case you should type 'x' to install the package.
19:23alexbaranoskyRaynes, "Status: Installed"
19:23RaynesOkay, cool.
19:23RaynesWhat color theme are you after?
19:23alexbaranoskytango, I thought looked nice
19:24pdkALL THINGS PINK
19:24Raynestomorrow is a good one.
19:24RaynesWhere is tango?
19:24alexbaranoskycolor-theme-tango
19:24RaynesI mean, where are you getting that theme from?
19:26alexbaranoskyI did package-list-packages, and it was in the list
19:26RaynesOh, I see. Install it.
19:26alexbaranoskyRaynes, hmmm, should be installing color-theme package or color-theme-tangotango ?
19:26RaynesBoth.
19:27RaynesNote that almost all packages will spit out mucho warnings when you install them. Just ignore it.
19:28alexbaranoskyRaynes, I installed them, now what!? :)
19:28RaynesNow you let nature take its course.
19:28RaynesNo, seriously.
19:28alexbaranoskynice
19:28Raynesalexbaranosky: Open your configuration file. ~/.emacs or ~/.emacs.d/init.el
19:29alexbaranoskyyep
19:30Raynesalexbaranosky: https://gist.github.com/1431781
19:30Raynesalexbaranosky: Evaluate those in order by placing the caret after the last closing paren of each form and doing C-x C-e.
19:31RaynesYou'll also want to save them in your config file as well so that they're ran at startup.
19:32alexbaranoskynice....! It worked, thank Raynes I really appreciate it
19:33Raynesalexbaranosky: No problem at all. Color themes can be a pain in the ass if you don't do it right. I didn't want to see you suffer.
19:33alexbaranoskythanks to Raynes
19:33alexbaranoskynow I can just figure out how to use this thing ;)
19:34alexbaranoskydoes the starter kit give me SLIME ?
19:35Raynesalexbaranosky: All you need is clojure-mode (also in ELPA) and Leiningen for that.
19:35RaynesJust go to a Clojure project and open a file and run M-x clojure-jack-in and you'll have a fancy SLIME repl.
19:35alexbaranoskyI think I've got clojure-mode already from Phil's blog post
19:36alexbaranoskyRaynes do a lot of folks use clojure-refactorings ?
19:36RaynesI don't. Don't know about others.
19:37alexbaranoskycool, well thanks again
19:37alexbaranoskyadios
19:39TeXnomancyalexbaranosky: color-theme.el is the old color theme mechanism; custom-theme is the new one that's built-in to 24.
19:40RaynesTeXnomancy: Eh?
19:40TeXnomancyRaynes: the themeing engine in emacs 24 is brand new and rewritten
19:41RaynesTeXnomancy: And probably useless if it isn't compatible with existing themes.
19:45y3dijust curious: is there a clojure library that can convert an existing java codebase into all clojure?
19:45RaynesWell, there is always that wand shop from the Harry Potter series. I'm sure there is some spell somewhere.
19:46apetrescuHaha
19:46TimMcy3di: I don't think so.
19:46TimMcThe next question is: Is it possible, preserving semantics?
19:47RaynesIf there was something that could directly convert Java code to Clojure code, that Clojure code would be pretty useless anyways.
19:48TimMcright
19:48TimMcSome things sure wouldn't work, like volatile and transient.
19:48TimMcAlso, do we have access to Java's "synchronized" operator?
19:51RaynesI think we have something equivalent, right?
19:51Raynes&(doc locking)
19:51lazybot⇒ "Macro ([x & body]); Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circumstances."
19:57TimMcsweet
20:10y3diRich makes clojure seem like the most amazing thing in the world
20:11apetrescuTimMc: Of course it's possible; it's also known as "a Java compiler [which happens to emit Clojure instead of C or bytecode]". Happens all the time.
20:14apetrescuLikely won't be very nice Clojure though :P
20:33y3diin what situations would you make something a macro over a simple function?
20:33y3diinstead of*
20:35hiredmanhttp://www.bookshelf.jp/texi/onlisp/onlisp_9.html
20:37y3diamazing, ty
20:38meliponeHow do I launch a script (clojure code in a file) with leiningen so that it's running in batch mode?
20:40moogatronicmelipone: do you mean that you want to run your code from the command line?
20:41meliponemoogatronic: yes, ideally like "lein myscript.clj". Is that possible?
20:41moogatronic(i'm confused by the term "batch mode")
20:41RaynesYay.
20:42moogatronicmelipone: in your project.clj file, you can define run aliases.
20:42RaynesJust shipped another chapter to my publisher. Load off of my mind.
20:42moogatronic:run-aliases {:parse datautils.core :subj datautils.subjugator}
20:42moogatronicfor example
20:43meliponemoogatronic: ah! run aliases might work. thanks! I'll look into it
20:43moogatronicthen you can have main's in those packages that are executed like java mains
20:43moogatronicalso you can set aot in project.clj as well
20:44moogatronicbrehaut: http://soundcloud.com/moogatronic/descending-moon
20:44brehautmoogatronic: yeah, i saw the tweet :)
20:44brehautmoogatronic: im interested to see where it develops
20:45moogatronicbrehaut: haha me too. =)
20:45seancorf`Raynes: have you got a timeline for the book yet?
20:46brehauti also mean to look at your lsystem code when i have some spare time too
20:46moogatronicbrehaut: I actually want to hook up some of the graphics too, I implemented the bracketed lsystem, so I should be able to also render the sound Lsystems as graphics.
20:46Raynesseancorfield: Kind of. Depends on what you mean by timeline.
20:47Raynesseancorfield: We're aiming for a new chapter every 2-3 weeks. Three chapters (as of tonight) are currently being processed. One of them is edited and awaiting my revisions.
20:47seancorfieldand how many chapters are planned?
20:47RaynesSomewhere around 14.
20:48RaynesBut that isn't a realistic timeline because I don't know how long the editing process will take in the end.
20:48seancorfieldcool... so you're almost a quarter thru the writing... and 30-40 weeks from finishing?
20:48brehautmoogatronic: i wanted to implement brackets in my j2d turtle, but i couldnt work out how to push and pop matrix state on the graphics context
20:48moogatroniclook at my turtle.clj
20:48RaynesThat first chapter that is awaiting my revisions still has to go through tech review once all of the developmental edits are finished.
20:48moogatronicthat's how I push/pop state... i'm not sure if it's the right way
20:48moogatronic=)
20:49moogatronicbut it would probalby work if that ref maintained the graphics / etc.
20:49RaynesWell, more than a quarter through the writing. A good portion of the book is already written, but I still have to go through all of those existing partial chapters and finish them/rewrite parts of them (because I wrote them all in like a week and they all suck).
20:49brehautmoogatronic: a lot of graphics APIs have a way to save the current transformation context (eg, transposes, rotates, scales etc) built in; i didnt want to have rebuild all that machinary from scratch.
20:49seancorfieldah, cool, so you're further along than it sounds :)
20:50RaynesSorry if I'm being vague. I just haven't given much thought to timelines and such.
20:50RaynesIt would be clearer if I had any clue how long the review part of things was going to take.
20:51RaynesReview is the most painful part of this all. Especially the "you should add to this" parts. Means more writing. ;)
20:52moogatronicbrehaut: ah. I definitely don't know much about graphics. I want to play with that stuff over winter break.
20:52nsunmoogatronic: you can try lein exec plugin
20:53brehautmoogatronic: i think you want someone whose done more with STM than me, but i think your push-state etc functions are broken/racy. i *think* that by derefing turtle outside of the dosync and then using those values to calculate the new turtle that you are causing yourself problems in the future
20:54brehauteg (let [stack (:stack @turtle) state { … @turtle … }] (dosync (alter turtle …))) should be (dosync (let [stack (:stack @turtle) state { … @turtle … }] (alter …)))
20:55brehautmoogatronic (because reads outside a transaction aren't guaranteed to be consistent, and they wont be retried if the transaction fails
20:55moogatronicbrehaut: Yeah, I was wondering about that myself. I'll have to look at that some more.
20:55moogatronicWhat woudl the result of a failed read be?
20:55brehautmoogatronic: a read wont fail
20:56moogatronicTo a certain extent, it wouldn't matter... but I would like to implement it "correctly".
20:56brehautmoogatronic: but if you have (let [a @myref b @myref] (= a b))
20:56brehautmoogatronic: and (dosync (alter myref inc)) running on another thread; then you could easily get false from (= a b)
20:57brehautmoogatronic: on the other hand (dosync (let [a (@myref b @myref] (= a b))) is always true
20:58brehaut(because both reads are inside a transaction they are guaranteed to be consistent)
20:58moogatronicbrehaut: Right.
21:00brehaut,(select-keys {:a 1 :b 2 :c 3} [:a :c]) ;; moogatronic re: https://github.com/damionjunk/i601LSounder/blob/master/src/i601_project/turtle.clj#L28-32
21:00clojurebot{:c 3, :a 1}
21:01moogatronicbrehaut: lol. yeah much nicer. =)
21:03brehautmoogatronic: i think have the turtle be part of a context stack and having that stack be part of the turtle is pretty weirdo too ;)
21:04moogatronicbrehaut: eh?
21:05brehautmoogatronic: your turtle state is really all the things you have in the 'state' of push-state
21:05brehautbut due to how youve structured your turtle map, its all mashed together
21:06moogatronicyeah, that's a bit weird, becuase i'm tracking and computing time for sequencing the beats, i think.
21:06brehauti think i would write music-turtle as {:stack [{:pos … bpm}] :notes-stack []}
21:06TimMcapetrescu: Just because Java and Clojure both target the JVM doesn't mean you can do a source translation.
21:06moogatronicI wanted to be able to just say (:note @turtle) basically..
21:08brehautmoogatronic: i think id just define functions eg (def note (comp :note pop :stack deref))
21:11apetrescuTimMc: ClojureScript compiles Clojure to JS. I believe Sun had an R&D project that compiled JS source to Java source.
21:11apetrescuErgo, your Clojure->Java compiler is, turn Clojure into JS with ClojureScript, then turn the JS into Java with Phobos (Sun's weird thing)
21:11TimMchaha, nice
21:11apetrescuIt will be ungodly ugly, but most languages can be compiled into each other :P
21:14moogatronicbrehaut: in this case, the current state is all of the map keys, the notes-stack is data that will be directly used by overtone, and gets added to during the manipulation of the state-stack.
21:14moogatronicbrehaut: I don't really keep a stack of the current note, I used defrecord at some point, but it didn't seem any cleaner to me.
21:15moogatronicbrehaut: but that could be that I was using it wrong, like dosync... =)
21:16TimMcapetrescu: I guess "inner classes" could be done with Foo$Bar.clj or so.
21:18TimMcapetrescu: I'm not sure you could get full reflection parity, though. java.lang.reflect.Field.toGenericString(), for instance. And public/private/protected? Forget about it.
21:19apetrescuTimMc: Well, I guess it depends on what your definition of the source being the same in the two languages
21:19TimMcI think limiting it to non-reflective code would be fair.
21:19apetrescuIf you consider the source equal if it has the same output on the same input, then it can work even if you don't have direct mappings between certain language concepts.
21:20apetrescuProof: Let X be Java source code that implements a Clojure compiler. Then let Y = X + "code that calls X on Clojure code C".
21:21apetrescuI claim that X is a Java translation of C :P
21:21TimMcfeh
21:21apetrescuTechnically it's true although I doubt you'll find that satisfying
21:21TimMcCorrect. :-)
21:21apetrescuSo now it's just a matter of how much we can improve on that :P
21:21apetrescuI don't know enough Clojure to have an opinion on that, unfortunately
21:21apetrescuI'm just being pedantic :)
21:21TimMcI'm thinking more along the lines of "If you compiled the original and the translated versions into .class files, would any relying code notice a difference?"
21:21apetrescuAaah
21:22apetrescuThat's more of an engineering question regarding the technical implementations of Clojure and Java
21:29jgrimesy3di: that is very true :)
21:30jgrimesoh wow that was like an hour ago. Had scrolled up on accident. (RE: Rich making Clojure seem like the most amazing thing in the world.)
21:31TimMcHe's a damn good speaker.
21:35Laers_UemLauetChousuke, you know I'm right, interpretation is going on
21:35Laers_UemLauetinterpretation is the running of any code, a CPU 'interprets' machine code.
21:35Laers_UemLauetI mean, even a compiler that is working, the compiler as a program is being interpreted then.
21:37brehautLaers_UemLauet: is this an elaborate troll? common usage in programmer circles seperates interpration from execution for exactly these debates
21:38alexbaranoskyis there a way to run leiningen plugins from within Emacs? (Emacs noob here)
21:44jcrossley3alexbaranosky: 'M-x compile' will prompt you for a build command and put its output in a buffer with convenient navigation
21:45Raynesalexbaranosky: M-! will prompt you to run a shell command from within Emacs.
21:46jcrossley3Raynes: i thoroughly enjoyed your tentacles post. i smiled multiple times, and chuckled audibly at the "oh he really does have 30 followers" line. thanks! :)
21:46Raynesjcrossley3: I bet you didn't have nearly as much fun reading it as I did writing it. :)
21:48jcrossley3Raynes: it shows
21:53TimMcRaynes: Link for tentacles post?
21:53Rayneshttp://blog.raynes.me/blog/2011/12/02/waving-our-tentacles/
21:57TimMcRaynes: Does tentacles work with Clj 1.2?
21:57TimMc(If you don't know, I'll try.)
21:58RaynesTimMc: It should. I seem to recall purposely not using anything 1.3 specific.
21:58TimMcRaynes: I ask because 'lein new' uses 1.2 by default.
21:59Laers_UemLauetbrehaut, define the difference then.
22:00Laers_UemLauet'common usage' as far as I know means interpretation is the process by which code is executed
22:00brehautcode that is interpreted is done so software, executed is directly by hardware
22:01Laers_UemLauetThe execution that hardware does nowadays has embedded software in the hardware
22:01brehautbig whop
22:01Laers_UemLauetWhich is 'soft' in the sense of that it can be altered
22:02Laers_UemLauetAnyway, even idf that were the casde, it doesn't change the fact that the clojure repl is an interpreter since it is still software
22:02Laers_UemLauetAnd the statement 'that no interpretation is done' is quite simply a bit awkward
22:02brehautfail
22:03RaynesWhat an utterly useless argument.
22:03TeXnomancyalexbaranosky: I just use eshell; if you load pcmpl-lein.el you can get tab-completion in eshell for tasks and tests
22:03RaynesMight as well go debate the existence of God.
22:04Laers_UemLauetRaynes, no, it's extremely usefl.
22:04Laers_UemLauetbecause what does he then mean with 'no interpretation is going on'
22:04TeXnomancyalexbaranosky: there is something called elein.el, but I don't think you actually save any keystrokes vs using eshell
22:04RaynesTeXnomancy: I'm considering writing a lein.el thingy as an elisp exercise.
22:04Laers_UemLauetThe point is he makes a product adveritsement in that way and it's meaningful to determine the meaning.
22:05alexbaranoskyTeXnomancy, is M-! the same as eshell?
22:05gfredericksLaers_UemLauet: probably that the code gets compiled to class files before being executed, rather than interpreted in the way you might otherwise?
22:05TeXnomancyalexbaranosky: no, eshell is a full shell replacement like bash, but written in lisp
22:05Laers_UemLauetthe way I might otherwise what?
22:05Laers_UemLauetI think you a word
22:05Laers_UemLauetassume?
22:05alexbaranoskyTeXnomancy, thanks, I'll look into it
22:05Raynesalexbaranosky: The former allows you to execute a one-off shell command and the latter is an actual shell in your Emacs.
22:05Raynesalexbaranosky: M-x eshell
22:05TeXnomancygeez, you guys still don't have that guy on /ignore?
22:06TimMcTeXnomancy: Some of us do.
22:06RaynesTeXnomancy: I try to avoid being hiredmanish in most cases. I'm about to make an exception.
22:06gfredericksLaers_UemLauet: no I was just leaving out a description of how to interpret clojure, which you could do at a high level
22:06Laers_UemLauetOhh
22:06Laers_UemLauetI might otherwise do
22:06Laers_UemLauetYeah, I get.
22:06Laers_UemLauetWell, you can say that I suppose, that's a difference.
22:06Laers_UemLauetPretty vague way to say it, but I get what he means.
22:06TeXnomancyRaynes: he's just Lajla with a new nick, so it's not like he hasn't earned it
22:07TeXnomancyalexbaranosky: eshell lets you do cool things like pipe directly to a buffer and implement completion and prompts in lisp
22:08Laers_UemLauetI change my nickanme every day man.
22:08Laers_UemLauetFixed nicknames are for the weak.
22:09Laers_UemLauetAnd the weak shall perish, ask Species 8472
22:09Laers_UemLauetI hear they are quite advanced.
22:10TimMcRaynes: Would you consider putting "user=> (require '[clojure.pprint :as pp])" in your post?
22:10TimMcand maybe something for tentacles.users
22:14RaynesTimMc: I didn't? That was a mistake. I'll definitely correct it.
22:24RaynesTimMc: You plan to use tentacles for something?
23:00ambrosebsdnolen: I played some more with the cljs analyzer
23:01dnolenambrosebs: how's that going?
23:02ambrosebsdnolen: so far I've only needed to make a little modification
23:03ambrosebsI needed the metadata in (fn [^{:foo bar} a] ..) to stay around
23:04ambrosebsI should have something to show in the next few days
23:04ambrosebsthe analyzer makes it all so easy
23:07dnolenambrosebs: excellent!
23:07dnolenambrosebs: guess that means you can focus on the actual problem.
23:07ambrosebsdnolen: yep
23:22ambrosebsdnolen: hows cKanren?
23:22ambrosebslol
23:23ambrosebsdnolen: hows cKanren?
23:25dnolenambrosebs: still pondering some design things. also pondering the core.match vector/seq potential change.
23:30ambrosebsdnolen: Racket's pattern matching is pretty interesting
23:31ambrosebsit almost looks like matching type constructors
23:31dnolenambrosebs: yes, never dug into it very deeply, lot's of cool stuff there.
23:33dnolenambrosebs: tho I prefer match's behavior of matching on protocols/interfaces over actual types.
23:34dnolenit's also why people are complaining about seq/vector distinction, that's not something you have to think about when destructuring.
23:36ambrosebsdnolen: right, sounds like two different ideas complected into one
23:55radsdoes anyone know why (resolve) doesn't work in clojurescript, and if there's a way to get around it?