#clojure log - Dec 04 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:33 zakwilson: I 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?

0:38 noto3: zakwilson, a git submodule, I would say

0:39 zakwilson: noto3: I was hoping something like that existed, but I did not know what to call it.

0:39 notostraca: git 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

0:40 I am still learning git, and I have had lots of trouble getting it to work well with eclipse

0:45 zakwilson: I do not use Eclipse, and just use git from the command line.

0:52 notostraca: zakwilson, I think you are going to do better than I have then

0:52 zakwilson: Perhaps.

0:52 notostraca: Leiningen plays nice with Git IIRC, Eclipse projects do not

0:53 .classpath is needed for all eclipse projects, but it can easily containt machine-specific absolute paths

0:53 *contain

0:54 and when those get in git, they screw up the eclipse .classpath for anyone else who tries to open the file in eclipse...

0:54 definitely stick to leiningen, IMHO

0:57 TeXnomancy: checking in the .classpath file is just crazy

0:57 I guess the default "lein new" skeleton should put that in .gitignore

1:10 zakwilson: https://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.

1:10 The ones at the end for javascript/css/widget

1:15 michaelr525: hey

1:17 y3di: does Hickey ever chill in this irc chat?

1:20 zakwilson: He used to. I think people started demanding too much of his attention.

1:21 y3di: mm, makes sense

1:22 zakwilson: Though 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.

1:27 y3di: yea, I really admire the open source movement in general

1:27 but that scenario might be because clojure is a younger and less popular language?

1:28 show theres less demand for personal attention from the language creator

1:29 zakwilson: Well, 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.

1:53 y3di: im watching his lecture on simple made easy

1:54 zakwilson: That's a classic. Great stuff.

1:54 A modern classic. anyway.

2:06 Raynes: I 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.

2:06 zakwilson: I'm not sure I get the reference.

2:07 Raynes: If I elaborated I would be making a liar out of myself.

2:07 zakwilson: You must now make the inappropriate joke anyway because you mentioned it.

2:14 y3di: he only mentioned it so that he could have the chance to make the joke xD

2:15 ok so i feel like this is an elementary concept but i don't know it

2:15 whats the meaning of 'state' in programming

2:15 why is c++ stateFUL and clojure stateLEss

2:21 zakwilson: State 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.

2:22 mindbender1: zakwilson: I don't think there is any access to state that's unmanaged

2:23 zakwilson: do you mean a different approach

2:24 zakwilson: I mean Clojure provides mechanisms controlling when and how changes to state are made.

2:25 mindbender1: of course it does

2:25 y3di: ok, hmm thats what I assumed state was, but the way people discuss it makes it seem more complex

2:25 why does it come up alot in conversations about programming languages

2:25 dont yu need state in order to have a useful programming language?

2:26 zakwilson: Yes, just as you need access to memory. Manually managing it however can be extra work for the programmer and error-prone.

2:27 mindbender1: y3di: http://en.wikipedia.org/wiki/State_(computer_science)

2:30 y3di: so ive taken courses like foundations of computer science and theory of computation which go into the more abstract theoretical aspects of CS

2:31 and learned stuff like turing machines and fsms

2:31 but ive never been able to make the connection between that kind of stuff and the actual programming aspect of CS

2:32 mindbender1: y3di: pick a language and try out some basic tutorials on that language

2:34 y3di: nah, ive done quite a bit of actual programming its just that i cant see how things like automata theory relate to the programming

2:34 maybe its because i've been generally using imperative languages and that somewhat obscures those more theoretical concepts? idk

2:35 hopefully learning clojure makes me think of programming differently and it might be easier to make those connections

2:36 mindbender1: y3di: on wikipedia: Automata play a major role in theory of computation, compiler design and parsing.

2:37 unless you want to build a compiler I suspect

2:38 otherwise focus more on real problems you can solve with a language

2:39 y3di: you're right, theres no real need to overcomplicate things

2:41 mindbender1: you're welcome

3:30 changbeer: why are some functions suffixed with *

3:31 such as a few in sql.internal.clj

3:34 taking a look at https://github.com/richhickey/clojure-contrib/blob/40b960bba41ba02811ef0e2c632d721eb199649f/src/main/clojure/clojure/contrib/sql/internal.clj

3:34 presumably Im expected to define the symbol *db*

3:35 how does this work in clojure 1.3 since that lacks the meta-data ^:dynamic so i cant do that in a binding?

3:36 hiredman: first richhickey/clojure and richhickey/clojure-contrib are not the correct repos

3:37 you want clojure/clojure and clojure/clojure-contrib

3:37 second contrib as a single unified package is dead

3:37 you want clojure/java.jdbc

3:42 changbeer: woohoo 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

3:57 looking 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

3:58 is there any reason he didnt use the optional docstring of the macro, rather than directly using the metadata?

5:08 triyo: Any 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?

5:13 zakwilson: I'm a new Korma user, and that's what I've been doing.

5:13 Korma tries to map pretty directly to SQL, and SQL doesn't generally return non-collections.

5:14 triyo: 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.

5:15 triyo: oh ok, thanks

5:15 I thought it might be because it is an DSL after all

5:16 that it would map on SQL and always return a sequence / vector

5:16 To see those examples would be great..

5:19 I must say, select* for composing SQL queries is truly awesome

5:20 zakwilson: Looks like the examples are all gists and perhaps github changed something.

5:20 https://gist.github.com/ibdknox <-- if you want to dig through that...

5:20 And yeah, composable SQL is great. SQL... isn't great at that.

5:20 There are ways to make it a little better, of course. That's what views are about, as I understand it.

5:21 triyo: thanks for the link

5:34 zakwilson: 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).

5:35 update-in can apply to only one key and not multiple like I have in my example above [:total1 :total2 ...]

5:36 zakwilson: Oh... I wrote some map utilities including exactly what you want.

5:36 https://github.com/zakwilson/zutil-clj/blob/master/src/zutil/map.clj <-- see map-keys

5:36 triyo: Hehe, nice. Is it a macro that just expands in to a (assoc m k v k v k v) :)

5:36 thanks for the link I'll have a quick look

5:37 zakwilson: It is not, but maybe it should be.

5:37 Don't go too hard on this code. It was really not designed for public consumption.

5:37 triyo: I think it just might perform a bit better. ;-)

5:38 No at all, thank you for sharing; no judging :)

5:38 zakwilson: I evidently didn't even decide what license to use. It says EPL in one place and BSD in another.

5:39 Yeah, a macro would likely be more performant.

5:39 Intersection and difference are fast though.

5:41 Good 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.

5:41 * zakwilson takes pull requests.

5:42 triyo: There 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 .

5:42 licenser: Wasn't rule one of Macros: don't use Macros?

5:43 triyo: licenser: well if it expands in to something really `simple` and that will perform better in this case, then I say macro it is.

5:43 licenser: triyo: Raynes has written a function that is a bit like that I think it was called what-fn

5:43 zakwilson: licenser: last I checked, it was more like "only use macros when you need to".

5:43 licenser: well you still loose composability

5:43 zakwilson: close to it ;) also you don't need to it works fine as function

5:44 rabidsnail: Is there a cleaner way to test if something is a set than (= (class thing) clojure.lang.PersistentHashSet) ?

5:44 zakwilson: Yeah. I'm not sure if it's needed here. I should see what happens when I use it on huge maps though.

5:44 triyo: licenser: you don't loose composability, check: #(mymacro %) ;-)

5:44 licenser: hackery

5:44 zakwilson: ,(set? #{:a :b :c})

5:44 clojurebot: true

5:44 rabidsnail: aha

5:45 cool

5:45 zakwilson: Similar functions exist for most common types

5:45 ,(string? 'not-a-string)

5:45 clojurebot: false

5:46 licenser: I think the fastest way to do this would be something entirely different

5:52 https://gist.github.com/1429882 <- for example

5:56 zakwilson: as a hint for map map

5:56 ,(map identity {1 1 2 2 })

5:56 clojurebot: ([1 1] [2 2])

5:56 licenser: you can simply destruct the kv instead of calling (key) and (value)

5:58 zakwilson: I'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.

5:58 Or should not be. I'm trying to get something online for a friend before I nap

6:06 raek: rabidsnail: yes: 'set?'

9:58 fliebel: Has anyone seen something like partition in Python?

10:14 lucian: fliebel: http://code.activestate.com/recipes/576785-partition-an-iterable-into-n-lists/

10:15 fliebel: lucian: Someone in #python came up with this: http://codepad.org/LlREJRX0

10:15 lucian: yeah, that's the straightforward comprehension

10:15 well, mostly

10:16 it's O(n) anyway

11:01 ambrosebs: ,(meta ^{:a :b} 'a)

11:01 clojurebot: nil

11:01 ambrosebs: why is there no metadata here?

11:12 ,(meta (with-meta 'a {:a :b}))

11:12 clojurebot: {:a :b}

11:12 ambrosebs: what the difference between those two?

11:14 raek: ambrosebs: ^{:a :b} 'a = ^{:a :b} (quote a)

11:14 ambrosebs: raek: ah

11:15 raek: ambrosebs: (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:16 ambrosebs: raek: oh I see

11:16 raek: ambrosebs: (with-meta 'a {:a :b}) = make a new symbol with the metadata at runtime

11:16 so ^{} is for annotating code and with-meta is a function you use at runtime

11:17 ambrosebs: ^{} metadata sticks around at runtime, right?

11:17 as in, it doesn't disappear

11:19 ,((fn [^{:a :b} a] (meta a)) 'param)

11:19 clojurebot: nil

11:19 ambrosebs: why don't I get {:a :b} there too?

11:20 raek: ambrosebs: 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:22 ambrosebs: raek: hmm, yes that makes sense

11:22 raek: if I put metadata on the fn symbol here, where should that "end up": (^{:a :b} fn [...] ...)

11:23 ambrosebs: raek: I don't know :)

11:28 I'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:28 raek: metadata 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:28 ambrosebs: :)

11:28 raek: metadata on values have other uses

11:29 and because code = data, these two categories happens to be the same

11:29 ambrosebs: if you want to do checks statically (i.e. at compile time) you need to do them in a macro

11:32 (type-check (fn [^String s, ^int i] (+ s i)))

11:33 here, 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:34 type-check has access to the {:tag String} metadata of the s symbol

11:35 after the compiler is done with the unmodified (fn ...) form, the type hint metadata is not stored anywhere

11:36 ambrosebs: raek: right, and it shouldn't be needed after compilation anyway

11:36 I think I've missed that point

11:39 in my case, if they persist into runtime, they will be in the form of a contract/precondition

11:39 otherwise they are useless

11:41 raek: yeah, you could say that type hints persist into runtime too, since they affect what the interop calls become

11:41 ambrosebs: right

11:44 raek: thanks, I've always struggled with metadata

11:44 raek: np :)

11:51 triyo: Does anyone have an example or experience in placing conditions on SQL Korma macros such as `aggegate`?

12:24 rabidsnail: There's no regex? function in the standard lib?

12:24 It seems like there's a test for every other type that has a syntax literal

12:24 literal syntax

12:29 weavejester: rabidsnail: I don't think there is. There's none for namespace? either

12:31 TimMc: &(instance? java.util.regex.Pattern #"")

12:31 lazybot: ⇒ true

12:32 TimMc: *shrug*

12:34 rabidsnail: Of 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:35 Raynes: I think it just defines them for the most common ones.

12:36 If it had a function for every test, core.clj would be a couple thousand lines longer.

12:36 rabidsnail: Even if it only had tests for the types that have special syntax?

12:37 TimMc: rabidsnail: I'm pretty sure that's not the only omission. Is there also a test for 15N or 15M?

12:38 (Not to say there shouldn't be...)

12:38 rabidsnail: there's a test for number?

12:40 so 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:41 including its type

12:42 not the end of the world, though. It just means that I'm going to be defining regex? in half of my projects.

12:43 TimMc: rabidsnail: You have a number of DSLs where you need to distinguish regexes from other values?

12:44 rabidsnail: today 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:44 TimMc: yep

13:16 triyo: I find it quite cumbersome to work with macros and conditional logic

13:18 Say 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:18 how do you make the `sum` bit generic in order to be able to switch it to `max` for example

13:18 clojurebot: chouser: it's tougher with guards (arbitrary tests), where grouping is less clear. I need to work that out still.

13:19 triyo: I can have `if` conditions around (aggregate ...)

13:20 but 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:04 TimMc: clojurebot seems to preferentially wrongly pick up messages to chouser as factoids.

14:20 zmanji: How does one access my functions in my namespace using lein repl?

14:22 tremolo: does anyone know if I can force an Emacs 24 theme to treat javadoc blocks as regular comments?

14:23 they 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:35 TimMc: Wow, impatient little buggers.

14:46 Ugh, I can't get rid of clojurebot's ~namespaces factoid (to replace it with a cleaned-up version.)

14:46 I've tried putting || around is and are but nothing has worked.

15:19 fbru02: Hi all ! Is there a predicate to test if a sth is a "form" i.e. a clojure.lang.PersistentList ? ?

15:19 i know dumb question :)

15:23 raek: fbru02: you probably want 'seq?'

15:23 ,(read-string "'foo")

15:23 clojurebot: (quote foo)

15:23 raek: ,(class 'foo)

15:23 clojurebot: clojure.lang.Symbol

15:24 raek: ,(class ''foo)

15:24 clojurebot: clojure.lang.PersistentList

15:24 raek: hrm

15:25 I was sure that the (quote ...) thingy was a clojure.lang.Cons and not a list...

15:25 fbru02: raek: thought that too

15:25 raek: anyway: they are both seqs so 'seq?' works for both

15:26 TimMc: fbru02: Writing a macro?

15:26 fbru02: raek: yeah, will try with that and let you know, seems kinda obvious now in retrospective

15:26 raek: ,(class (read-string "'foo"))

15:26 clojurebot: clojure.lang.Cons

15:26 fbru02: TimMc: actually not more like a parser thingy

15:26 raek: ,(map (comp seq? read-string) ["'foo" "(quote foo)"])

15:26 clojurebot: (true true)

15:26 TimMc: fbru02: Well, you probably want list?, vector?, and map? more than seq?.

15:27 fbru02: TimMc: raek thank you guys !!

15:27 TimMc: raek, fbru02: seq? is for the sequence abstraction, which *happens* to be implemented with lists.

15:28 (usually)

15:28 &(map (comp list? read-string) ["'foo" "(quote foo)"])

15:28 lazybot: ⇒ (false true)

15:28 TimMc: Hmm, what's going on there?

15:34 Why would the reader mix sequences in like that?

15:34 gfredericks: &(map (comp type read-string) ["'foo" "(quote foo)"])

15:34 lazybot: ⇒ (clojure.lang.Cons clojure.lang.PersistentList)

15:36 gfredericks: maybe it was incidental more than intentional

15:36 does seem inconsistent though :/

15:37 TimMc: Makes inspection trickier.

15:37 gfredericks: exactly

15:40 TimMc: &(type (list 1 2))

15:40 lazybot: ⇒ clojure.lang.PersistentList

15:40 TimMc: &(type (list* 1 (2)))

15:40 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

15:40 TimMc: &(type (list* 1 '(2)))

15:40 lazybot: ⇒ clojure.lang.Cons

15:40 TimMc: Aha.

15:41 Now *that* seems wrong right there.

15:41 &(list? (list* 1 ()))

15:41 lazybot: ⇒ false

15:43 TimMc: &(list? (clojure.lang.RT/list 1))

15:43 lazybot: ⇒ true

15:43 TimMc: &(list? (clojure.lang.RT/list 1 2))

15:43 lazybot: ⇒ false

15:46 TimMc: list* |is| <reply>list* doesn't actually make a `list?`

15:46 clojurebot: list* |is| <reply>list* doesn't actually make a `list?`

15:46 clojurebot: Ok.

15:51 gfredericks: TimMc: of course not, it makes a list*!

15:53 tmciver: TimMc: Hey. Can you tell me the difference between these destructuring forms: (fn [a b & more]...) and (fn [a b & [more]]...)

15:54 TimMc: tmciver: Yeah, I had lazybot $mail you about it.

15:54 tmciver: &((fn [a b & more] [a b more]) 1 2 3 4)

15:54 lazybot: ⇒ [1 2 (3 4)]

15:54 y3di: from an abstract stand point, is recursion more like looping or parallel computation(map, reduce)?

15:54 tmciver: &((fn [a b & more] [a b [more]]) 1 2 3 4)

15:54 lazybot: ⇒ [1 2 [(3 4)]]

15:54 tmciver: TimMc: thanks

15:55 gfredericks: y3di: looping, if I understand you correctly

15:55 TimMc: y3di: neither.

15:55 * gfredericks puts on his fighting pants

15:56 tmciver: TimMc: so, & [more] just takes the first element when more is a collection?

15:56 &((fn [a b & more] [a b [more]]) 1 2 [3 4])

15:56 lazybot: ⇒ [1 2 [([3 4])]]

15:56 tmciver: woops

15:56 y3di: im 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:56 TimMc: y3di: Well, it has absolutely nothing in common with parallel computing, and looping is a special case of recursion (in an abstract sense.)

15:56 tmciver: &((fn [a b & [more]] [a b more]) 1 2 [3 4])

15:56 lazybot: ⇒ [1 2 [3 4]]

15:56 y3di: and i was curious with how recursion fit in that

15:57 TimMc: tmciver: Here's a more instructive example:

15:57 y3di: ok so its more similar to looping then

15:57 does that mean recursion should also be minimizes? when trying to write concurrent programs?

15:57 gfredericks: y3di: you can use it to do loopy things, and you can also use it to do other things

15:57 y3di: minimized*

15:58 TimMc: &((fn [a b & [c d e f]] [a b c d e f]) 1 2 3 4 5 6 7 8 9)

15:58 lazybot: ⇒ [1 2 3 4 5 6]

15:58 TimMc: y3di: Recursion is a very powerful tool that can do many, many things. Looping is just one small (but common) translation.

15:59 gfredericks: &((fn [a & [b & [c & [d & [e & [f]]]]]] [a b c d e f]) 1 2 3 4 5 6 7 8 9)

15:59 lazybot: ⇒ [1 2 3 4 5 6]

16:00 tmciver: TimMc: gfredericks: Yeah, that's a bit clearer. Thanks.

16:00 TimMc: y3di: 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:01 y3di: However, if you can express it in a way that indicates to the compiler that the computations are independent, you might win.

16:01 y3di: which is why map/reduce is amazing right?

16:06 Laers_UemLauet: Clojurebot, do you still hate me?

16:06 ,(+)

16:06 clojurebot: 0

16:06 Laers_UemLauet: Aha

16:07 Your love I have once more regained, so merriful our future life shall be.

16:08 ,(let [space " "] (append "I" space "worship" space "His" space "shadow"))

16:08 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: append in this context, compiling:(NO_SOURCE_PATH:0)>

16:08 Laers_UemLauet: Oh wait

16:09 That was concat right

16:09 ,(let [space " "] (concat "I" space "worship" space "His" space "shadow"))

16:09 clojurebot: (\I \space \w \o \r ...)

16:09 Laers_UemLauet: We're getting there

16:09 ,(let [space " "] (apply string (concat "I" space "worship" space "His" space "shadow")))

16:09 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: string in this context, compiling:(NO_SOURCE_PATH:0)>

16:09 Laers_UemLauet: ,(let [space " "] (apply str (concat "I" space "worship" space "His" space "shadow")))

16:09 clojurebot: "I worship His shadow"

16:09 Laers_UemLauet: At last

16:10 Yeeees, victory is mine

16:10 * raek notices that Lajla has a new nick

16:10 Laers_UemLauet: exactly as planned.

16:10 raek, nooo, my master plan

16:10 indeed you are an adversary worthy of my vast intellect

16:10 however did you see through my disguise oh nemesis?

16:10 Your wits are indeed sharp as ever.

16:10 TimMc: Thank god for /ignore.

16:11 y3di: map/reduce is one approach to splitting concurrent computations across many machines.

16:19 alexbaranosky_: 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:25 raek: alexbaranosky_: what does the second for do instead of what it's supposed to?

16:25 pyrtsa: alexbaranosky_: Looks like the :when test should be within the brackets: (for [... :when test] ...)

16:25 Oh, it was. Sorry.

16:26 alexbaranosky_: raek, it is not filtering out the people... I'm getting people as wella s neighbors abck

16:27 pyrtsa: alexbaranosky_: Could it be there are people who are neighbors to each others too?

16:28 alexbaranosky_: YES!

16:28 that's it

16:28 thanks :)

16:28 king-of-spain: clojure is too good

16:28 pyrtsa: I live in a city, you know. ;)

16:28 TimMc: haha

16:28 king-of-spain: when my programs fail, i cant blame the language anymore :(

16:32 alexbaranosky: king-of-spain, so true

17:05 zakwilson: Someone suggest an appropriate method of torturing the creator of java.util.Date to death.

17:09 ,(java.util.Date. -62167219200000)

17:09 clojurebot: #<Date Fri Jan 02 16:00:00 PST 1>

17:09 zakwilson: ,(java.util.Date. -72167219300000)

17:09 clojurebot: #<Date Tue Feb 14 22:11:40 PST 318>

17:09 * zakwilson doesn't understand.

17:18 developernotes: I'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:26 moogatronic: developernotes: Try C-u C-x C-e maybe? This will put the output directly in your buffer.

17:27 developernotes: moogatronic: thanks - that does it.

18:48 TimMc: zakwilson: What am I supposed to see there?

18:48 zakwilson: TimMc: the second one should, as far as I understand be BCE.

18:49 TimMc: zakwilson: I see, the bit after the timezone is the year. I was wondering about that.

18:49 zakwilson: ,(java.util.Date. 1)

18:49 clojurebot: #<Date Wed Dec 31 16:00:00 PST 1969>

18:53 TimMc: zakwilson: Huh. Does Date not have a BC/AD indicator, or does it just not print it?

18:54 zakwilson: TimMc: it gives the year as negative.

18:54 TimMc: zakwilson: And prints it as positive?

18:55 zakwilson: TimMc: No. If it gets the year right, it prints it as negative. The problem is that it doesn't seem to be consistent.

18:56 I'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:58 TimMc: ,(java.util.Date. -61600000000000)

18:58 clojurebot: #<Date Thu Dec 23 16:53:20 PST 17>

18:58 TimMc: ,(.getYear (java.util.Date. -61600000000000))

18:58 clojurebot: -1883

18:58 TimMc: Haha, what the actual fuck.

18:58 zakwilson: #<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:59 (ok, it's a java.sql.Timestamp, not a java.sql.Date, but the WTF is the same)

18:59 TimMc: &(+ -1883 17)

18:59 lazybot: ⇒ -1866

19:00 TimMc: &(+ -1883 -17)

19:00 lazybot: ⇒ -1900

19:00 TimMc: right

19:01 zakwilson: I think somebody involved in this design was smoking crack.

19:04 y3di: say 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:04 are macros defined globally? (does this question even make sense)

19:06 Raynes: y3di: You can get at a macro in a namespace just like a function in that namespace.

19:06 raek: macros belong to namespaces just like functions

19:06 Raynes: raek: Get your own question.

19:07 y3di: so if a library defines a macro in the global namespace, any code using that library has access to the macro?

19:07 so a library for example can overwrite the macro or into being w/e it wants

19:07 'or'*

19:08 TimMc: zakwilson: 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:09 raek: y3di: there is no global namespace

19:10 y3di: oh ok

19:10 raek: if you define a macro or a function in your namespace foo.bar, other namespaces can use it

19:11 (ns user (:require foo.bar)) ;; (foo.bar/the-macro ...)

19:11 (ns user (:require [foo.bar :as f])) ;; (f/the-macro ...)

19:11 y3di: i see, i think i have to read up more on namespaces. I

19:11 raek: (ns user (:use [foo.bar :only [the-macro]])) ;; (the-macro ...)

19:11 y3di: I'm getting ahead of myself

19:12 raek: y3di: 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:12 alexbaranosky: ok, 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:13 zakwilson: TimMc: perhaps, but the more glaring problem is stuff like 1900-offset years, 0-offset months and eras being... at least quirky.

19:13 y3di: ok cool, thanks raek

19:16 Raynes: alexbaranosky: Install the color theme package from ELPA first of all.

19:16 alexbaranosky: Ping me once you've finished with that.

19:16 Tip: M-x package-list-packages

19:17 TimMc: alexbaranosky: put an "i" next to color-theme and then type "x", I think.

19:17 Raynes: Yes.

19:20 y3di: ,(drop 2 {:1 1 :2 2 :3 3 :4 4})

19:20 clojurebot: ([:3 3] [:2 2])

19:21 Raynes: That's a bit precarious.

19:21 alexbaranosky: Raynes: how do I install a package from ELPA - I'm an utter EMacs noob, so your statement was not immediately clear to me

19:21 Raynes: Maps don't guarantI'd give him the command to install that specific package ee order.

19:21 Whoa.

19:21 TimMc: y3di: maps are not sequential: http://www.brainonfire.net/files/seqs-and-colls/collection-properties-venn.png

19:21 Raynes: ERC just exploded in my face.

19:21 alexbaranosky: M-x package-list-packages

19:21 alexbaranosky: y3di, if you were to use some form of ordered-map then you could get away with that though

19:21 Raynes, thx

19:21 Raynes: alexbaranosky: 'M' is your meta key. Usually ALT.

19:21 y3di: word ok

19:22 Raynes: alexbaranosky: You should be greeted with a big ol' buffer full of packages. Look for the color theme package.

19:22 y3di: TimMc: useful diagram, thanks

19:22 TimMc: y3di: On the other hand, I think the same map is guaranteed to give the same (arbitrary) ordering every time.

19:23 Raynes: alexbaranosky: 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:23 alexbaranosky: Raynes, "Status: Installed"

19:23 Raynes: Okay, cool.

19:23 What color theme are you after?

19:23 alexbaranosky: tango, I thought looked nice

19:24 pdk: ALL THINGS PINK

19:24 Raynes: tomorrow is a good one.

19:24 Where is tango?

19:24 alexbaranosky: color-theme-tango

19:24 Raynes: I mean, where are you getting that theme from?

19:26 alexbaranosky: I did package-list-packages, and it was in the list

19:26 Raynes: Oh, I see. Install it.

19:26 alexbaranosky: Raynes, hmmm, should be installing color-theme package or color-theme-tangotango ?

19:26 Raynes: Both.

19:27 Note that almost all packages will spit out mucho warnings when you install them. Just ignore it.

19:28 alexbaranosky: Raynes, I installed them, now what!? :)

19:28 Raynes: Now you let nature take its course.

19:28 No, seriously.

19:28 alexbaranosky: nice

19:28 Raynes: alexbaranosky: Open your configuration file. ~/.emacs or ~/.emacs.d/init.el

19:29 alexbaranosky: yep

19:30 Raynes: alexbaranosky: https://gist.github.com/1431781

19:30 alexbaranosky: Evaluate those in order by placing the caret after the last closing paren of each form and doing C-x C-e.

19:31 You'll also want to save them in your config file as well so that they're ran at startup.

19:32 alexbaranosky: nice....! It worked, thank Raynes I really appreciate it

19:33 * alexbaranosky has begun his rich and awesome Emacs journey

19:33 Raynes: alexbaranosky: 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:33 alexbaranosky: thanks to Raynes

19:33 now I can just figure out how to use this thing ;)

19:34 does the starter kit give me SLIME ?

19:35 Raynes: alexbaranosky: All you need is clojure-mode (also in ELPA) and Leiningen for that.

19:35 Just 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:35 alexbaranosky: I think I've got clojure-mode already from Phil's blog post

19:36 Raynes do a lot of folks use clojure-refactorings ?

19:36 Raynes: I don't. Don't know about others.

19:37 alexbaranosky: cool, well thanks again

19:37 adios

19:39 TeXnomancy: alexbaranosky: color-theme.el is the old color theme mechanism; custom-theme is the new one that's built-in to 24.

19:40 Raynes: TeXnomancy: Eh?

19:40 TeXnomancy: Raynes: the themeing engine in emacs 24 is brand new and rewritten

19:41 Raynes: TeXnomancy: And probably useless if it isn't compatible with existing themes.

19:45 y3di: just curious: is there a clojure library that can convert an existing java codebase into all clojure?

19:45 Raynes: Well, there is always that wand shop from the Harry Potter series. I'm sure there is some spell somewhere.

19:46 apetrescu: Haha

19:46 TimMc: y3di: I don't think so.

19:46 The next question is: Is it possible, preserving semantics?

19:47 Raynes: If there was something that could directly convert Java code to Clojure code, that Clojure code would be pretty useless anyways.

19:48 TimMc: right

19:48 Some things sure wouldn't work, like volatile and transient.

19:48 Also, do we have access to Java's "synchronized" operator?

19:51 Raynes: I think we have something equivalent, right?

19:51 &(doc locking)

19:51 lazybot: ⇒ "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:57 TimMc: sweet

20:10 y3di: Rich makes clojure seem like the most amazing thing in the world

20:11 apetrescu: TimMc: 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:14 Likely won't be very nice Clojure though :P

20:33 y3di: in what situations would you make something a macro over a simple function?

20:33 instead of*

20:35 hiredman: http://www.bookshelf.jp/texi/onlisp/onlisp_9.html

20:37 y3di: amazing, ty

20:38 melipone: How do I launch a script (clojure code in a file) with leiningen so that it's running in batch mode?

20:40 moogatronic: melipone: do you mean that you want to run your code from the command line?

20:41 melipone: moogatronic: yes, ideally like "lein myscript.clj". Is that possible?

20:41 moogatronic: (i'm confused by the term "batch mode")

20:41 Raynes: Yay.

20:42 moogatronic: melipone: in your project.clj file, you can define run aliases.

20:42 Raynes: Just shipped another chapter to my publisher. Load off of my mind.

20:42 moogatronic: :run-aliases {:parse datautils.core :subj datautils.subjugator}

20:42 for example

20:43 melipone: moogatronic: ah! run aliases might work. thanks! I'll look into it

20:43 moogatronic: then you can have main's in those packages that are executed like java mains

20:43 also you can set aot in project.clj as well

20:44 brehaut: http://soundcloud.com/moogatronic/descending-moon

20:44 brehaut: moogatronic: yeah, i saw the tweet :)

20:44 moogatronic: im interested to see where it develops

20:45 moogatronic: brehaut: haha me too. =)

20:45 seancorf`: Raynes: have you got a timeline for the book yet?

20:46 brehaut: i also mean to look at your lsystem code when i have some spare time too

20:46 moogatronic: brehaut: 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:46 Raynes: seancorfield: Kind of. Depends on what you mean by timeline.

20:47 seancorfield: 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:47 seancorfield: and how many chapters are planned?

20:47 Raynes: Somewhere around 14.

20:48 But that isn't a realistic timeline because I don't know how long the editing process will take in the end.

20:48 seancorfield: cool... so you're almost a quarter thru the writing... and 30-40 weeks from finishing?

20:48 brehaut: moogatronic: 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:48 moogatronic: look at my turtle.clj

20:48 Raynes: That first chapter that is awaiting my revisions still has to go through tech review once all of the developmental edits are finished.

20:48 moogatronic: that's how I push/pop state... i'm not sure if it's the right way

20:48 =)

20:49 but it would probalby work if that ref maintained the graphics / etc.

20:49 Raynes: Well, 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:49 brehaut: moogatronic: 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:49 seancorfield: ah, cool, so you're further along than it sounds :)

20:50 Raynes: Sorry if I'm being vague. I just haven't given much thought to timelines and such.

20:50 It would be clearer if I had any clue how long the review part of things was going to take.

20:51 Review is the most painful part of this all. Especially the "you should add to this" parts. Means more writing. ;)

20:52 moogatronic: brehaut: ah. I definitely don't know much about graphics. I want to play with that stuff over winter break.

20:52 nsun: moogatronic: you can try lein exec plugin

20:53 brehaut: moogatronic: 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:54 eg (let [stack (:stack @turtle) state { … @turtle … }] (dosync (alter turtle …))) should be (dosync (let [stack (:stack @turtle) state { … @turtle … }] (alter …)))

20:55 moogatronic (because reads outside a transaction aren't guaranteed to be consistent, and they wont be retried if the transaction fails

20:55 moogatronic: brehaut: Yeah, I was wondering about that myself. I'll have to look at that some more.

20:55 What woudl the result of a failed read be?

20:55 brehaut: moogatronic: a read wont fail

20:56 moogatronic: To a certain extent, it wouldn't matter... but I would like to implement it "correctly".

20:56 brehaut: moogatronic: but if you have (let [a @myref b @myref] (= a b))

20:56 moogatronic: and (dosync (alter myref inc)) running on another thread; then you could easily get false from (= a b)

20:57 moogatronic: on the other hand (dosync (let [a (@myref b @myref] (= a b))) is always true

20:58 (because both reads are inside a transaction they are guaranteed to be consistent)

20:58 moogatronic: brehaut: Right.

21:00 brehaut: ,(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:00 clojurebot: {:c 3, :a 1}

21:01 moogatronic: brehaut: lol. yeah much nicer. =)

21:03 brehaut: moogatronic: 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:04 moogatronic: brehaut: eh?

21:05 brehaut: moogatronic: your turtle state is really all the things you have in the 'state' of push-state

21:05 but due to how youve structured your turtle map, its all mashed together

21:06 moogatronic: yeah, that's a bit weird, becuase i'm tracking and computing time for sequencing the beats, i think.

21:06 brehaut: i think i would write music-turtle as {:stack [{:pos … bpm}] :notes-stack []}

21:06 TimMc: apetrescu: Just because Java and Clojure both target the JVM doesn't mean you can do a source translation.

21:06 moogatronic: I wanted to be able to just say (:note @turtle) basically..

21:08 brehaut: moogatronic: i think id just define functions eg (def note (comp :note pop :stack deref))

21:11 apetrescu: TimMc: ClojureScript compiles Clojure to JS. I believe Sun had an R&D project that compiled JS source to Java source.

21:11 Ergo, your Clojure->Java compiler is, turn Clojure into JS with ClojureScript, then turn the JS into Java with Phobos (Sun's weird thing)

21:11 TimMc: haha, nice

21:11 apetrescu: It will be ungodly ugly, but most languages can be compiled into each other :P

21:14 moogatronic: brehaut: 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:14 brehaut: 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:15 brehaut: but that could be that I was using it wrong, like dosync... =)

21:16 TimMc: apetrescu: I guess "inner classes" could be done with Foo$Bar.clj or so.

21:18 apetrescu: 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:19 apetrescu: TimMc: Well, I guess it depends on what your definition of the source being the same in the two languages

21:19 TimMc: I think limiting it to non-reflective code would be fair.

21:19 apetrescu: If 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:20 Proof: Let X be Java source code that implements a Clojure compiler. Then let Y = X + "code that calls X on Clojure code C".

21:21 I claim that X is a Java translation of C :P

21:21 TimMc: feh

21:21 apetrescu: Technically it's true although I doubt you'll find that satisfying

21:21 TimMc: Correct. :-)

21:21 apetrescu: So now it's just a matter of how much we can improve on that :P

21:21 I don't know enough Clojure to have an opinion on that, unfortunately

21:21 I'm just being pedantic :)

21:21 TimMc: I'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:21 apetrescu: Aaah

21:22 That's more of an engineering question regarding the technical implementations of Clojure and Java

21:29 jgrimes: y3di: that is very true :)

21:30 oh 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:31 TimMc: He's a damn good speaker.

21:35 Laers_UemLauet: Chousuke, you know I'm right, interpretation is going on

21:35 interpretation is the running of any code, a CPU 'interprets' machine code.

21:35 I mean, even a compiler that is working, the compiler as a program is being interpreted then.

21:37 brehaut: Laers_UemLauet: is this an elaborate troll? common usage in programmer circles seperates interpration from execution for exactly these debates

21:38 alexbaranosky: is there a way to run leiningen plugins from within Emacs? (Emacs noob here)

21:44 jcrossley3: alexbaranosky: 'M-x compile' will prompt you for a build command and put its output in a buffer with convenient navigation

21:45 Raynes: alexbaranosky: M-! will prompt you to run a shell command from within Emacs.

21:46 jcrossley3: Raynes: 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:46 Raynes: jcrossley3: I bet you didn't have nearly as much fun reading it as I did writing it. :)

21:48 jcrossley3: Raynes: it shows

21:53 TimMc: Raynes: Link for tentacles post?

21:53 Raynes: http://blog.raynes.me/blog/2011/12/02/waving-our-tentacles/

21:57 TimMc: Raynes: Does tentacles work with Clj 1.2?

21:57 (If you don't know, I'll try.)

21:58 Raynes: TimMc: It should. I seem to recall purposely not using anything 1.3 specific.

21:58 TimMc: Raynes: I ask because 'lein new' uses 1.2 by default.

21:59 Laers_UemLauet: brehaut, define the difference then.

22:00 'common usage' as far as I know means interpretation is the process by which code is executed

22:00 brehaut: code that is interpreted is done so software, executed is directly by hardware

22:01 Laers_UemLauet: The execution that hardware does nowadays has embedded software in the hardware

22:01 brehaut: big whop

22:01 Laers_UemLauet: Which is 'soft' in the sense of that it can be altered

22:02 Anyway, 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:02 And the statement 'that no interpretation is done' is quite simply a bit awkward

22:02 brehaut: fail

22:03 Raynes: What an utterly useless argument.

22:03 TeXnomancy: alexbaranosky: I just use eshell; if you load pcmpl-lein.el you can get tab-completion in eshell for tasks and tests

22:03 Raynes: Might as well go debate the existence of God.

22:04 Laers_UemLauet: Raynes, no, it's extremely usefl.

22:04 because what does he then mean with 'no interpretation is going on'

22:04 TeXnomancy: alexbaranosky: there is something called elein.el, but I don't think you actually save any keystrokes vs using eshell

22:04 Raynes: TeXnomancy: I'm considering writing a lein.el thingy as an elisp exercise.

22:04 Laers_UemLauet: The point is he makes a product adveritsement in that way and it's meaningful to determine the meaning.

22:05 alexbaranosky: TeXnomancy, is M-! the same as eshell?

22:05 gfredericks: Laers_UemLauet: probably that the code gets compiled to class files before being executed, rather than interpreted in the way you might otherwise?

22:05 TeXnomancy: alexbaranosky: no, eshell is a full shell replacement like bash, but written in lisp

22:05 Laers_UemLauet: the way I might otherwise what?

22:05 I think you a word

22:05 assume?

22:05 alexbaranosky: TeXnomancy, thanks, I'll look into it

22:05 Raynes: alexbaranosky: The former allows you to execute a one-off shell command and the latter is an actual shell in your Emacs.

22:05 alexbaranosky: M-x eshell

22:05 TeXnomancy: geez, you guys still don't have that guy on /ignore?

22:06 TimMc: TeXnomancy: Some of us do.

22:06 Raynes: TeXnomancy: I try to avoid being hiredmanish in most cases. I'm about to make an exception.

22:06 gfredericks: Laers_UemLauet: no I was just leaving out a description of how to interpret clojure, which you could do at a high level

22:06 Laers_UemLauet: Ohh

22:06 I might otherwise do

22:06 Yeah, I get.

22:06 Well, you can say that I suppose, that's a difference.

22:06 Pretty vague way to say it, but I get what he means.

22:06 TeXnomancy: Raynes: he's just Lajla with a new nick, so it's not like he hasn't earned it

22:07 alexbaranosky: eshell lets you do cool things like pipe directly to a buffer and implement completion and prompts in lisp

22:08 Laers_UemLauet: I change my nickanme every day man.

22:08 Fixed nicknames are for the weak.

22:09 And the weak shall perish, ask Species 8472

22:09 I hear they are quite advanced.

22:10 TimMc: Raynes: Would you consider putting "user=> (require '[clojure.pprint :as pp])" in your post?

22:10 and maybe something for tentacles.users

22:14 Raynes: TimMc: I didn't? That was a mistake. I'll definitely correct it.

22:24 TimMc: You plan to use tentacles for something?

23:00 ambrosebs: dnolen: I played some more with the cljs analyzer

23:01 dnolen: ambrosebs: how's that going?

23:02 ambrosebs: dnolen: so far I've only needed to make a little modification

23:03 I needed the metadata in (fn [^{:foo bar} a] ..) to stay around

23:04 I should have something to show in the next few days

23:04 the analyzer makes it all so easy

23:07 dnolen: ambrosebs: excellent!

23:07 ambrosebs: guess that means you can focus on the actual problem.

23:07 ambrosebs: dnolen: yep

23:22 dnolen: hows cKanren?

23:22 lol

23:23 dnolen: hows cKanren?

23:25 dnolen: ambrosebs: still pondering some design things. also pondering the core.match vector/seq potential change.

23:30 ambrosebs: dnolen: Racket's pattern matching is pretty interesting

23:31 it almost looks like matching type constructors

23:31 dnolen: ambrosebs: yes, never dug into it very deeply, lot's of cool stuff there.

23:33 ambrosebs: tho I prefer match's behavior of matching on protocols/interfaces over actual types.

23:34 it's also why people are complaining about seq/vector distinction, that's not something you have to think about when destructuring.

23:36 ambrosebs: dnolen: right, sounds like two different ideas complected into one

23:55 rads: does anyone know why (resolve) doesn't work in clojurescript, and if there's a way to get around it?

Logging service provided by n01se.net